This commit is contained in:
2026-09-11 11:15:01 +08:00
parent a4b7247c57
commit 7fd2e70024
5 changed files with 36 additions and 21 deletions
@@ -278,6 +278,20 @@ class LoadingModelBridgeServiceTest {
verify(repository).confirmIncrementalPreload(30L, 10L, 20L, 4, 7L, "admin");
}
@Test
void bindsConfirmingPreloadToEditingPlanWithoutFinalizingIt() {
when(repository.byPair(10, 20, 40)).thenReturn(null);
when(repository.loadingPlan(40)).thenReturn(new LoadingPlanSnapshot(40L, 50L, "C1", "EDITING", 3));
when(repository.allocatedPackages(10, 20, 40)).thenReturn(2);
when(repository.preload(10, 20)).thenReturn(new PreloadSnapshot(30L, 10L, 20L, "CONFIRMING", 4));
service.bindIncrementalAllocation(40L, 10L, 20L, 7L, "admin", "assign-confirming-editing");
verify(repository).insert(any());
verify(repository, never()).confirmIncrementalPreload(anyLong(), anyLong(), anyLong(),
anyInt(), anyLong(), anyString());
}
private static Link link(String preloadStatus, int preloadVersion, String loadingStatus,
int loadingVersion, int packages) {
return new Link(1L, 10L, 20L, 30L, preloadStatus, preloadVersion, 40L, 50L, "C1",
@@ -84,14 +84,16 @@ class SplitPreloadServiceTest {
}
@Test
void loadingAllocationDoesNotOverwriteConfirmedPreload() {
void loadingAllocationMayReuseConfirmingAndConfirmedPreloads() {
when(repository.findInbound(10, 20)).thenReturn(new InboundSnapshot(20L, 10L, "WAIT_SPLIT", 3));
PreloadPlanEntity plan = new PreloadPlanEntity();
plan.setStatus("CONFIRMING");
when(repository.findPlan(10, 20)).thenReturn(plan);
PreloadPlanEntity confirming = new PreloadPlanEntity();
confirming.setStatus("CONFIRMING");
PreloadPlanEntity confirmed = new PreloadPlanEntity();
confirmed.setStatus("CONFIRMED");
when(repository.findPlan(10, 20)).thenReturn(confirming, confirmed);
assertThatThrownBy(() -> service.ensurePendingForLoadingAllocation(10, 20, 7, "admin"))
.hasMessageContaining("已进入确认流程");
service.ensurePendingForLoadingAllocation(10, 20, 7, "admin");
service.ensurePendingForLoadingAllocation(10, 20, 7, "admin");
verify(repository, never()).createPlan(any());
}