feat(lastleg): expose inbound PDA work instructions
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
||||
package com.baiyue.lastleg.inboundplan.pda.controller;
|
||||
|
||||
import com.baiyue.common.security.AuthenticatedUser;
|
||||
import com.baiyue.lastleg.inboundplan.pda.dto.PdaRequests;
|
||||
import com.baiyue.lastleg.inboundplan.pda.service.InboundPdaWorkflowService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
class InboundPalletAssignmentControllerTest {
|
||||
private final InboundPdaWorkflowService service = mock(InboundPdaWorkflowService.class);
|
||||
private final InboundPalletAssignmentController controller = controller();
|
||||
private final PdaRequests.Assign request = new PdaRequests.Assign(1L, 2L, 3L, "assign-key");
|
||||
|
||||
@Test
|
||||
void assignmentRequiresPdaOperatePermissionAndExplicitPlatformCustomer() {
|
||||
assertThrows(ResponseStatusException.class,
|
||||
() -> controller.assign(user(Set.of()), "PLAN-1", 4L, "100", request));
|
||||
assertThrows(ResponseStatusException.class,
|
||||
() -> controller.assign(user(Set.of(InboundPdaController.OPERATE_PERMISSION)), "PLAN-1", 4L, null, request));
|
||||
|
||||
controller.assign(user(Set.of(InboundPdaController.OPERATE_PERMISSION)), "PLAN-1", 4L, "100", request);
|
||||
|
||||
verify(service).assign("100", "PLAN-1", 4L, request);
|
||||
}
|
||||
|
||||
private AuthenticatedUser user(Set<String> permissions) {
|
||||
return new AuthenticatedUser(7L, 0L, 0L, 8L, "operator", "PLATFORM", "PDA", permissions);
|
||||
}
|
||||
|
||||
private InboundPalletAssignmentController controller() {
|
||||
InboundPalletAssignmentController value = new InboundPalletAssignmentController();
|
||||
ReflectionTestUtils.setField(value, "service", service);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
+16
-1
@@ -95,6 +95,21 @@ class InboundPdaWorkflowServiceTest {
|
||||
verify(repository, never()).insert(any(InboundPdaTask.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void taskReturnsPalletAndAllocationWorkInstructions() {
|
||||
when(repository.task("100", plan.getId())).thenReturn(task);
|
||||
when(repository.pallets(plan.getId())).thenReturn(List.of(targetPallet));
|
||||
when(repository.allocations(plan.getId())).thenReturn(List.of(target));
|
||||
when(repository.lines(plan.getId())).thenReturn(List.of(targetLine));
|
||||
|
||||
var result = service.task("100", "LIP1");
|
||||
|
||||
assertEquals(targetPallet.getId(), result.pallets().get(0).planPalletId());
|
||||
assertEquals(target.getId(), result.allocations().get(0).allocationId());
|
||||
assertEquals("RK-A", result.allocations().get(0).inboundCode());
|
||||
assertEquals(3, result.allocations().get(0).plannedPackageCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
void assignmentReservesWarehouseResourcesAndPersistsTheLock() {
|
||||
targetPallet.setDestinationWarehouseId("88");
|
||||
@@ -427,7 +442,7 @@ class InboundPdaWorkflowServiceTest {
|
||||
|
||||
assertEquals("COMPLETED", result.status());
|
||||
verify(stockReceipts, never()).stockIn(any(), any(), any(), any(), any(), any(), any());
|
||||
verify(repository, never()).allocations(plan.getId());
|
||||
verify(repository, never()).update(task);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user