优化
This commit is contained in:
@@ -16,6 +16,7 @@ import com.baiyue.firstleg.entity.LoadingPlanHistoryEntity;
|
||||
import com.baiyue.firstleg.entity.LoadingPlanItemEntity;
|
||||
import com.baiyue.firstleg.repository.SmartLoadingRepository;
|
||||
import com.baiyue.firstleg.loading.bridge.service.LoadingModelBridgeService;
|
||||
import com.baiyue.firstleg.split.service.SplitPreloadService;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import feign.FeignException;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -55,6 +56,7 @@ class SmartLoadingServiceTest {
|
||||
@MockBean private OrderCargoClient cargoClient;
|
||||
@MockBean private LoadingPickService loadingPickService;
|
||||
@MockBean private LoadingModelBridgeService loadingModelBridge;
|
||||
@MockBean private SplitPreloadService splitPreloadService;
|
||||
@Resource private SmartLoadingService service;
|
||||
|
||||
@TestConfiguration
|
||||
@@ -158,6 +160,7 @@ class SmartLoadingServiceTest {
|
||||
|
||||
service.assign(1, new AssignRequest(10L, 20L, 2, 0, "assign-110-ok"), 7, "u");
|
||||
|
||||
verify(splitPreloadService).ensurePendingForLoadingAllocation(9L, 10L, 7L, "u");
|
||||
verify(repository).touch(1, 0, 7, "u");
|
||||
}
|
||||
|
||||
@@ -388,11 +391,28 @@ class SmartLoadingServiceTest {
|
||||
|
||||
assertThat(result.status()).isEqualTo("EDITING");
|
||||
verify(repository).push(1, "key", 3, 7, "u");
|
||||
var ordered = inOrder(loadingModelBridge, loadingPickService);
|
||||
var ordered = inOrder(splitPreloadService, loadingModelBridge, loadingPickService);
|
||||
ordered.verify(splitPreloadService).ensurePendingForLoadingAllocation(9L, 10L, 7L, "u");
|
||||
ordered.verify(loadingModelBridge).bindAllocatedBeforeLoading(1, 7, "u", "key");
|
||||
ordered.verify(loadingPickService).beginIfReady(99, 7, "u");
|
||||
}
|
||||
|
||||
@Test
|
||||
void editingPushReplayEnsuresPendingPreloadBeforePda() {
|
||||
LoadingPlanEntity pushed = plan("EDITING", 4);
|
||||
pushed.setPushIdempotencyKey("key");
|
||||
when(repository.plan(1)).thenReturn(pushed);
|
||||
when(repository.items(1)).thenReturn(List.of(item(8, 9, 20, 1)));
|
||||
when(repository.booking(99)).thenReturn(booking());
|
||||
|
||||
service.pushPreload(1, "key", new PushRequest(4), 7, "u");
|
||||
|
||||
verify(splitPreloadService).ensurePendingForLoadingAllocation(9L, 10L, 7L, "u");
|
||||
verify(loadingModelBridge).bindAllocatedBeforeLoading(1, 7, "u", "key");
|
||||
verify(loadingPickService).beginIfReady(99, 7, "u");
|
||||
verify(repository, never()).push(anyLong(), anyString(), anyInt(), anyLong(), anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
void rollsBackPushOrchestrationBeforePdaWhenBindingFails() {
|
||||
LoadingPlanEntity editing = plan("EDITING", 3);
|
||||
@@ -509,7 +529,7 @@ class SmartLoadingServiceTest {
|
||||
private static LoadingPlanItemEntity item(long id, long account, long detail, int boxes) {
|
||||
LoadingPlanItemEntity value = new LoadingPlanItemEntity();
|
||||
value.setId(id); value.setLoadingPlanId(1L); value.setAccountId(account);
|
||||
value.setInboundDetailId(detail); value.setPackageCount(boxes);
|
||||
value.setInboundId(10L); value.setInboundDetailId(detail); value.setPackageCount(boxes);
|
||||
value.setVersion(0); value.setDeleted(false);
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.never;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class SplitPreloadServiceTest {
|
||||
@@ -56,6 +57,34 @@ class SplitPreloadServiceTest {
|
||||
verify(repository).createPlan(any(PreloadPlanEntity.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void loadingAllocationCreatesPendingPreloadLifecycle() {
|
||||
when(repository.findInbound(10, 20)).thenReturn(new InboundSnapshot(20L, 10L, "WAIT_SPLIT", 3));
|
||||
when(repository.findPlan(10, 20)).thenReturn(null);
|
||||
|
||||
service.ensurePendingForLoadingAllocation(10, 20, 7, "admin");
|
||||
|
||||
org.mockito.ArgumentCaptor<PreloadPlanEntity> captor =
|
||||
org.mockito.ArgumentCaptor.forClass(PreloadPlanEntity.class);
|
||||
verify(repository).createPlan(captor.capture());
|
||||
assertThat(captor.getValue().getStatus()).isEqualTo("PENDING");
|
||||
assertThat(captor.getValue().getItemsJson()).isEqualTo("[]");
|
||||
assertThat(captor.getValue().getRemark()).isEqualTo("智能装柜分配自动建立");
|
||||
}
|
||||
|
||||
@Test
|
||||
void loadingAllocationDoesNotOverwriteConfirmedPreload() {
|
||||
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);
|
||||
|
||||
assertThatThrownBy(() -> service.ensurePendingForLoadingAllocation(10, 20, 7, "admin"))
|
||||
.hasMessageContaining("已进入确认流程");
|
||||
|
||||
verify(repository, never()).createPlan(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void confirmsPlanAndMovesInboundToLoading() {
|
||||
when(repository.claimOperation(anyLong(), anyLong(), anyLong(), anyString(), anyString())).thenReturn(true);
|
||||
|
||||
Reference in New Issue
Block a user