fix: isolate invalid container progress snapshots
This commit is contained in:
+30
-5
@@ -30,7 +30,9 @@ import java.time.LocalDateTime;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
@@ -319,16 +321,39 @@ class LastlegOrderServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void containerProgressDetailFailsClosedWhenContainerNumberFactHasDrifted() {
|
||||
void containerProgressDetailKeepsInvalidHistoricalContainerReadableAndBlocked() {
|
||||
var drifted = new ContainerPlanProgressSummary("BOOKING-1", null, 2, 2, 0,
|
||||
2, 2, 0, LocalDateTime.of(2026, 10, 3, 9, 0), false, "柜号缺失或不一致");
|
||||
when(orders.findContainerProgress("BOOKING-1")).thenReturn(drifted);
|
||||
when(orders.findContainerProgressItems("BOOKING-1")).thenReturn(List.of());
|
||||
|
||||
ResponseStatusException error = assertThrows(ResponseStatusException.class,
|
||||
() -> service.containerProgressDetail("BOOKING-1"));
|
||||
var result = service.containerProgressDetail("BOOKING-1");
|
||||
|
||||
assertEquals(409, error.getStatusCode().value());
|
||||
verify(orders, never()).findContainerProgressItems(any());
|
||||
assertFalse(result.summary().allPlansReady());
|
||||
assertFalse(result.summary().canChangeReceivingWarehouse());
|
||||
assertEquals("来源柜真实集装箱号缺失、格式无效或存在漂移",
|
||||
result.summary().blockingReason());
|
||||
assertEquals(result.summary().blockingReason(), result.summary().receivingWarehouseLockReason());
|
||||
verify(orders).findContainerProgressItems("BOOKING-1");
|
||||
}
|
||||
|
||||
@Test
|
||||
void containerProgressPageKeepsMissingWarehouseSnapshotFromBreakingHealthyContainers() {
|
||||
var query = new LastlegOrderRequests.ContainerProgressQuery(1, 10, null, null, null);
|
||||
var healthy = summary(false, 3, "存在3票尚未生成有效入库计划");
|
||||
var missingWarehouse = new ContainerPlanProgressSummary("BOOKING-2", "MSCU6639870",
|
||||
null, null, null, 0, true, null, 2, 2, 0, 0, 0, 2,
|
||||
LocalDateTime.of(2026, 10, 4, 9, 0), false, "存在2票尚未生成有效入库计划");
|
||||
when(orders.countContainerProgress(query)).thenReturn(2L);
|
||||
when(orders.pageContainerProgress(query, 0, 10)).thenReturn(List.of(healthy, missingWarehouse));
|
||||
|
||||
var result = service.containerProgressPage(query);
|
||||
|
||||
assertEquals(2, result.records().size());
|
||||
assertSame(healthy, result.records().get(0));
|
||||
assertEquals("柜内接柜仓业务快照不一致", result.records().get(1).blockingReason());
|
||||
assertFalse(result.records().get(1).allPlansReady());
|
||||
assertTrue(result.records().get(1).canChangeReceivingWarehouse());
|
||||
}
|
||||
|
||||
private static ContainerPlanProgressSummary summary(boolean ready, long pending, String reason) {
|
||||
|
||||
Reference in New Issue
Block a user