This commit is contained in:
2026-08-22 09:51:01 +08:00
parent 1a67b3404d
commit 988d1bee7c
2 changed files with 21 additions and 13 deletions
@@ -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",