This commit is contained in:
2026-08-25 09:52:49 +08:00
parent b211121365
commit b67217332a
37 changed files with 1009 additions and 343 deletions
@@ -1,42 +0,0 @@
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;
}
}