| | |
| | | @Mock private PlatformTransactionManager transactionManager; |
| | | @InjectMocks private MdmAgentImportCommandService service; |
| | | |
| | | private final AgentPrincipal principal = new AgentPrincipal(7L, 0L, "live"); |
| | | private final AgentPrincipal principal = new AgentPrincipal(7L, "live"); |
| | | |
| | | @BeforeEach |
| | | void setUp() { |
| | |
| | | AtomicReference<MdmAgentImportCommandDO> inserted = captureInsertedCommand(); |
| | | |
| | | MdmAgentImportReceiptRespVO first = service.commit(request("物料A"), principal); |
| | | when(commandMapper.selectByCommandId(0L, 7L, "cmd-1")).thenReturn(inserted.get()); |
| | | when(commandMapper.selectByCommandId(7L, "cmd-1")).thenReturn(inserted.get()); |
| | | MdmAgentImportReceiptRespVO second = service.commit(request("物料A"), principal); |
| | | |
| | | assertEquals("SUCCEEDED", first.getStatus()); |
| | |
| | | when(preflightService.preflight(any(), any())).thenReturn(preflight(PREFLIGHT_HASH)); |
| | | AtomicReference<MdmAgentImportCommandDO> inserted = captureInsertedCommand(); |
| | | service.commit(request("物料A"), principal); |
| | | when(commandMapper.selectByCommandId(0L, 7L, "cmd-1")).thenReturn(inserted.get()); |
| | | when(commandMapper.selectByIdempotencyKey(0L, 7L, "idem-1")).thenReturn(null); |
| | | when(commandMapper.selectByCommandId(7L, "cmd-1")).thenReturn(inserted.get()); |
| | | when(commandMapper.selectByIdempotencyKey(7L, "idem-1")).thenReturn(null); |
| | | |
| | | AgentBridgeException ex = assertThrows(AgentBridgeException.class, |
| | | () -> service.commit(request("物料B"), principal)); |
| | |
| | | |
| | | @Test |
| | | void missingCommandReturnsNotFound() { |
| | | when(commandMapper.selectByCommandId(0L, 7L, "cmd-x")).thenReturn(null); |
| | | when(commandMapper.selectByCommandId(7L, "cmd-x")).thenReturn(null); |
| | | |
| | | AgentBridgeException ex = assertThrows(AgentBridgeException.class, |
| | | () -> service.getCommand("cmd-x", principal)); |