fix(firstleg): reuse running preload lifecycle

This commit is contained in:
2026-08-25 14:07:52 +08:00
parent 9093550615
commit 5fb80d7624
2 changed files with 48 additions and 5 deletions
@@ -82,7 +82,7 @@ class SplitPreloadServiceTest {
@Test
void runningLoadingAllocationMayReuseConfirmedPreload() {
when(repository.findInbound(10, 20)).thenReturn(new InboundSnapshot(20L, 10L, "WAIT_SPLIT", 3));
when(repository.findInbound(10, 20)).thenReturn(new InboundSnapshot(20L, 10L, "LOADING", 3));
PreloadPlanEntity plan = new PreloadPlanEntity();
plan.setStatus("CONFIRMED");
when(repository.findPlan(10, 20)).thenReturn(plan);
@@ -92,9 +92,45 @@ class SplitPreloadServiceTest {
verify(repository, never()).createPlan(any());
}
@Test
void runningLoadingAllocationMayReusePendingPreload() {
when(repository.findInbound(10, 20)).thenReturn(new InboundSnapshot(20L, 10L, "LOADING", 3));
PreloadPlanEntity plan = new PreloadPlanEntity();
plan.setStatus("PENDING");
when(repository.findPlan(10, 20)).thenReturn(plan);
service.ensureForRunningLoadingAllocation(10, 20, 7, "admin");
verify(repository, never()).createPlan(any());
}
@Test
void runningLoadingAllocationMustNotCreateMissingPreload() {
when(repository.findInbound(10, 20)).thenReturn(new InboundSnapshot(20L, 10L, "LOADING", 3));
when(repository.findPlan(10, 20)).thenReturn(null);
assertThatThrownBy(() -> service.ensureForRunningLoadingAllocation(10, 20, 7, "admin"))
.hasMessageContaining("缺少既有预装计划");
verify(repository, never()).createPlan(any());
}
@Test
void ordinaryLoadingAllocationStillRequiresWaitingSplit() {
when(repository.findInbound(10, 20)).thenReturn(new InboundSnapshot(20L, 10L, "LOADING", 3));
PreloadPlanEntity plan = new PreloadPlanEntity();
plan.setStatus("PENDING");
when(repository.findPlan(10, 20)).thenReturn(plan);
assertThatThrownBy(() -> service.ensurePendingForLoadingAllocation(10, 20, 7, "admin"))
.hasMessageContaining("仅待分柜订单");
verify(repository, never()).createPlan(any());
}
@Test
void runningLoadingAllocationStillRejectsConfirmingPreload() {
when(repository.findInbound(10, 20)).thenReturn(new InboundSnapshot(20L, 10L, "WAIT_SPLIT", 3));
when(repository.findInbound(10, 20)).thenReturn(new InboundSnapshot(20L, 10L, "LOADING", 3));
PreloadPlanEntity plan = new PreloadPlanEntity();
plan.setStatus("CONFIRMING");
when(repository.findPlan(10, 20)).thenReturn(plan);