This commit is contained in:
2026-08-21 11:43:03 +08:00
parent dceec6cbed
commit 5fd00d3151
25 changed files with 507 additions and 44 deletions
@@ -86,6 +86,28 @@ class DispatchServiceTest {
verify(candidates, never()).available(any(), any(), any(), any());
}
@Test
void resolvesOnlyCustomerScopeAndRejectsMultipleCustomers() {
when(candidates.findCustomerScopes()).thenReturn(List.of("100"));
assertEquals("100", service.resolveSingleCustomerScope());
when(candidates.findCustomerScopes()).thenReturn(List.of("100", "200"));
ResponseStatusException exception = assertThrows(ResponseStatusException.class,
() -> service.resolveSingleCustomerScope());
assertEquals(409, exception.getStatusCode().value());
}
@Test
void emptyCustomerScopeProducesEmptyCandidatesAndRejectsPreArrange() {
assertEquals(List.of(), service.candidates(null, null, null, null));
verify(candidates, never()).available(any(), any(), any(), any());
ResponseStatusException exception = assertThrows(ResponseStatusException.class,
() -> service.preArrange(null, "7",
new DispatchRequests.PreArrange(List.of(10L), null, null, null, null)));
assertEquals(409, exception.getStatusCode().value());
}
@Test
void editCannotBypassPdaManagedDispatchStatus() {
DispatchOrder dispatch = new DispatchOrder();
@@ -105,14 +127,14 @@ class DispatchServiceTest {
}
@Test
void platformDetailFindsDispatchGloballyAndLoadsItemsWithRecordCustomer() {
void detailUsesResolvedCustomerScopeAndLoadsItems() {
DispatchOrder dispatch = new DispatchOrder();
dispatch.setId(1L);
dispatch.setCustomerId("200");
dispatch.setDispatchNo("PC1");
when(orders.findAnyByDispatchNo("PC1")).thenReturn(dispatch);
when(orders.findByDispatchNo("200", "PC1")).thenReturn(dispatch);
service.detail(null, "PC1");
service.detail("200", "PC1");
verify(items).findByDispatchOrder("200", 1L);
}