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