1
This commit is contained in:
+9
-7
@@ -33,20 +33,21 @@ class SmartDispatchControllerTest {
|
||||
@Test
|
||||
void candidatesResolveCustomerScopeFromSelectedPlans() {
|
||||
when(service.resolveCustomerScopeForPlans(List.of(1L, 2L))).thenReturn("100");
|
||||
when(service.candidates("100", List.of(1L, 2L), "LMO-1", "ONT8", "PLAN")).thenReturn(List.of());
|
||||
when(service.candidates("100", List.of(1L, 2L), "LMO-1", "ONT8", "PLAN", "draft-1"))
|
||||
.thenReturn(List.of());
|
||||
|
||||
controller.candidates(platform(), List.of(1L, 2L), "LMO-1", "ONT8", "PLAN");
|
||||
controller.candidates(platform(), List.of(1L, 2L), "LMO-1", "ONT8", "PLAN", "draft-1");
|
||||
|
||||
verify(service).candidates("100", List.of(1L, 2L), "LMO-1", "ONT8", "PLAN");
|
||||
verify(service).candidates("100", List.of(1L, 2L), "LMO-1", "ONT8", "PLAN", "draft-1");
|
||||
}
|
||||
|
||||
@Test
|
||||
void candidatesWithoutSelectedPlansUsePlatformScope() {
|
||||
when(service.platformCandidates(null, null, "RECEIVED")).thenReturn(List.of());
|
||||
when(service.platformCandidates(null, null, "RECEIVED", "draft-2")).thenReturn(List.of());
|
||||
|
||||
controller.candidates(platform(), null, null, null, "RECEIVED");
|
||||
controller.candidates(platform(), null, null, null, "RECEIVED", "draft-2");
|
||||
|
||||
verify(service).platformCandidates(null, null, "RECEIVED");
|
||||
verify(service).platformCandidates(null, null, "RECEIVED", "draft-2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,7 +64,8 @@ class SmartDispatchControllerTest {
|
||||
@Test
|
||||
void endpointsUseInboundOrderListAndDedicatedSmartDispatchAuthorities() throws Exception {
|
||||
PreAuthorize candidates = SmartDispatchController.class
|
||||
.getMethod("candidates", AuthenticatedUser.class, List.class, String.class, String.class, String.class)
|
||||
.getMethod("candidates", AuthenticatedUser.class, List.class, String.class, String.class, String.class,
|
||||
String.class)
|
||||
.getAnnotation(PreAuthorize.class);
|
||||
PreAuthorize preArrange = SmartDispatchController.class
|
||||
.getMethod("preArrange", AuthenticatedUser.class, DispatchRequests.PreArrange.class)
|
||||
|
||||
+12
-6
@@ -7,6 +7,8 @@ import com.baiyue.lastleg.dispatch.entity.DispatchItem;
|
||||
import com.baiyue.lastleg.dispatch.entity.DispatchOrder;
|
||||
import com.baiyue.lastleg.dispatch.entity.DispatchPalletLock;
|
||||
import com.baiyue.lastleg.dispatch.mapper.DispatchCandidateMapper;
|
||||
import com.baiyue.lastleg.dispatch.mapper.DispatchDraftContainerMapper;
|
||||
import com.baiyue.lastleg.dispatch.mapper.DispatchDraftMapper;
|
||||
import com.baiyue.lastleg.dispatch.mapper.DispatchItemMapper;
|
||||
import com.baiyue.lastleg.dispatch.mapper.DispatchOrderMapper;
|
||||
import com.baiyue.lastleg.dispatch.mapper.DispatchPalletLockMapper;
|
||||
@@ -41,6 +43,8 @@ class DispatchServiceTest {
|
||||
@Mock DispatchItemMapper items;
|
||||
@Mock DispatchPalletLockMapper locks;
|
||||
@Mock DispatchCandidateMapper candidates;
|
||||
@Mock DispatchDraftMapper drafts;
|
||||
@Mock DispatchDraftContainerMapper draftContainers;
|
||||
private DispatchService service;
|
||||
|
||||
@BeforeEach
|
||||
@@ -50,6 +54,8 @@ class DispatchServiceTest {
|
||||
ReflectionTestUtils.setField(service, "items", items);
|
||||
ReflectionTestUtils.setField(service, "locks", locks);
|
||||
ReflectionTestUtils.setField(service, "candidates", candidates);
|
||||
ReflectionTestUtils.setField(service, "drafts", drafts);
|
||||
ReflectionTestUtils.setField(service, "draftContainers", draftContainers);
|
||||
lenient().when(items.findByDispatchOrder(any(), any())).thenReturn(List.of());
|
||||
}
|
||||
|
||||
@@ -154,16 +160,16 @@ class DispatchServiceTest {
|
||||
void invalidCandidateStageIsRejected() {
|
||||
assertThrows(ResponseStatusException.class,
|
||||
() -> service.candidates("100", List.of(1L), null, null, "INVALID"));
|
||||
verify(candidates, never()).available(any(), any(), any(), any(), any());
|
||||
verify(candidates, never()).available(any(), any(), any(), any(), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void platformCandidatesQueryAcrossCustomersWithoutPlanScope() {
|
||||
when(candidates.available(null, null, null, null, "RECEIVED")).thenReturn(List.of());
|
||||
when(candidates.available(null, null, null, null, "RECEIVED", "draft-1")).thenReturn(List.of());
|
||||
|
||||
service.platformCandidates(null, null, "RECEIVED");
|
||||
service.platformCandidates(null, null, "RECEIVED", "draft-1");
|
||||
|
||||
verify(candidates).available(null, null, null, null, "RECEIVED");
|
||||
verify(candidates).available(null, null, null, null, "RECEIVED", "draft-1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -187,8 +193,8 @@ class DispatchServiceTest {
|
||||
|
||||
@Test
|
||||
void emptyCustomerScopeProducesEmptyCandidatesAndRejectsPreArrange() {
|
||||
assertEquals(List.of(), service.candidates(null, null, null, null, null));
|
||||
verify(candidates, never()).available(any(), any(), any(), any(), any());
|
||||
assertEquals(List.of(), service.candidates(null, null, null, null, null, "draft-1"));
|
||||
verify(candidates, never()).available(any(), any(), any(), any(), any(), any());
|
||||
|
||||
ResponseStatusException exception = assertThrows(ResponseStatusException.class,
|
||||
() -> service.preArrange(null, "7",
|
||||
|
||||
Reference in New Issue
Block a user