fix(firstleg): refresh inbound picking progress after task completion
This commit is contained in:
@@ -1060,6 +1060,41 @@ class LoadingPickServiceTest {
|
||||
verify(completionCommands).complete(900L, "worker-1");
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"COMPLETING", "COMPLETED"})
|
||||
void workerRefreshesInboundProgressAfterTaskCompletionIncludingRetry(String initialTaskStatus) {
|
||||
LoadingPickTaskEntity task = task();
|
||||
task.setTaskStatus(initialTaskStatus);
|
||||
when(repository.task(20L)).thenReturn(task);
|
||||
when(repository.inboundOwners(20L)).thenReturn(List.of(
|
||||
new LoadingPickItemMapper.InboundOwner(101L, 50L)));
|
||||
when(repository.allPlanItemsPicked(10L)).thenReturn(true);
|
||||
when(repository.approve(20L, 9L, "operator", "checked")).thenReturn(1);
|
||||
when(repository.completeAccepted(20L, 9L, "operator")).thenAnswer(invocation -> {
|
||||
task.setTaskStatus("COMPLETED");
|
||||
return 1;
|
||||
});
|
||||
AtomicReference<String> projectedStatus = new AtomicReference<>();
|
||||
doAnswer(invocation -> {
|
||||
projectedStatus.set("COMPLETED".equals(task.getTaskStatus()) ? "COMPLETED" : "IN_PROGRESS");
|
||||
return null;
|
||||
}).when(repository).syncInboundProjections(20L, 9L, "operator");
|
||||
when(completionCommands.complete(925L, "worker-projection")).thenReturn(true);
|
||||
|
||||
service.processCompletion(completionCommand(925L, "async-projection"), "worker-projection");
|
||||
|
||||
assertThat(projectedStatus.get()).isEqualTo("COMPLETED");
|
||||
verify(repository, times(1)).syncInboundProjections(20L, 9L, "operator");
|
||||
if ("COMPLETING".equals(initialTaskStatus)) {
|
||||
InOrder finalization = inOrder(repository, completionCommands);
|
||||
finalization.verify(repository).completeAccepted(20L, 9L, "operator");
|
||||
finalization.verify(repository).syncInboundProjections(20L, 9L, "operator");
|
||||
finalization.verify(completionCommands).complete(925L, "worker-projection");
|
||||
} else {
|
||||
verify(repository, never()).completeAccepted(anyLong(), anyLong(), anyString());
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "truck state {0} never participates in PDA completion")
|
||||
@ValueSource(strings = {"NO_APPOINTMENT", "DRAFT", "IN_PROGRESS", "COMPLETED"})
|
||||
void completionWorkerIsIndependentOfEveryTruckAppointmentState(String truckState) {
|
||||
|
||||
Reference in New Issue
Block a user