fix: hold blocked outbound before WCS dispatch
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
package com.ruoyi.api.service.impl;
|
||||
|
||||
import com.ruoyi.job.mydojob.domain.MydoJob;
|
||||
import com.ruoyi.job.mydojob.service.IMydoJobService;
|
||||
import com.ruoyi.log.domain.RequestLog;
|
||||
import com.ruoyi.log.service.IRequestLogService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class ToWcsServiceImplTest {
|
||||
|
||||
@Test
|
||||
void blockedRearOutboundWaitsWithoutCallingWcsOrAdvancingStatus() {
|
||||
IRequestLogService requests = mock(IRequestLogService.class);
|
||||
IMydoJobService jobs = mock(IMydoJobService.class);
|
||||
MydoJob rear = outbound("OUT-REAR", "120803");
|
||||
when(jobs.selectMydoJobListApi(org.mockito.ArgumentMatchers.any())).thenReturn(List.of(rear));
|
||||
when(jobs.isOutboundDispatchBlocked("OUT-REAR")).thenReturn(true);
|
||||
ToWcsServiceImpl service = service(requests, jobs);
|
||||
|
||||
service.pushOutMydoJob();
|
||||
|
||||
verify(requests, never()).getRequestLog(anyString(), anyString(), anyString(), anyString(), anyString());
|
||||
verify(jobs, never()).updateMydoJob(rear);
|
||||
}
|
||||
|
||||
@Test
|
||||
void unblockedOutboundDispatchesAndAdvancesExactlyOnce() {
|
||||
IRequestLogService requests = mock(IRequestLogService.class);
|
||||
IMydoJobService jobs = mock(IMydoJobService.class);
|
||||
MydoJob front = outbound("OUT-FRONT", "120703");
|
||||
when(jobs.selectMydoJobListApi(org.mockito.ArgumentMatchers.any())).thenReturn(List.of(front));
|
||||
when(jobs.isOutboundDispatchBlocked("OUT-FRONT")).thenReturn(false);
|
||||
RequestLog accepted = new RequestLog();
|
||||
accepted.setIsSuccessful("1");
|
||||
when(requests.getRequestLog(eq(ToWcsServiceImpl.PUSH_OUT_MYDO_JOB), anyString(),
|
||||
eq("推送出库任务"), eq("wms"), eq("wcs"))).thenReturn(accepted);
|
||||
ToWcsServiceImpl service = service(requests, jobs);
|
||||
|
||||
service.pushOutMydoJob();
|
||||
|
||||
verify(requests).getRequestLog(eq(ToWcsServiceImpl.PUSH_OUT_MYDO_JOB), anyString(),
|
||||
eq("推送出库任务"), eq("wms"), eq("wcs"));
|
||||
verify(jobs).updateMydoJob(front);
|
||||
org.assertj.core.api.Assertions.assertThat(front.getStatus()).isEqualTo("3");
|
||||
}
|
||||
|
||||
private ToWcsServiceImpl service(IRequestLogService requests, IMydoJobService jobs) {
|
||||
ToWcsServiceImpl service = new ToWcsServiceImpl();
|
||||
ReflectionTestUtils.setField(service, "requestLogService", requests);
|
||||
ReflectionTestUtils.setField(service, "mydoJobService", jobs);
|
||||
return service;
|
||||
}
|
||||
|
||||
private MydoJob outbound(String jobId, String spaceId) {
|
||||
MydoJob job = new MydoJob();
|
||||
job.setJobId(jobId);
|
||||
job.setCargoSpaceId(spaceId);
|
||||
job.setInOrOut("21");
|
||||
job.setStatus("1");
|
||||
return job;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user