@Test public void testPrepareInboundCommand() { final InboundCommand command = mock(InboundCommand.class); ArgumentCaptor<InboundCommand> commandArgumentCaptor = ArgumentCaptor.forClass(InboundCommand.class); BubbleMessage message = mock(BubbleMessage.class); when(mockBubbleCache.getBubble(anyString())).thenReturn(Optional.of(message)); when(command.buildMeta()).thenReturn(mockCommandMeta); when(mockCommandRepository.save(any(AbstractCommand.class))).thenReturn(command); doCallRealMethod().when(command).setStatus(InboundCommand.Status.PREPARED); doCallRealMethod().when(command).getStatus(); commandOrchestratorImplUnderTest.prepare(command); verify(mockPublisher).publishEvent(any(InboundCommandStarted.class)); Assert.assertEquals(command.getStatus(), InboundCommand.Status.PREPARED); verify(mockPublisher).publishEvent(any(InboundCommandPrepared.class)); }
@Override public void prepare(BaseTransactionCommand command) { OutboundCommand obc = this.commandMapper(command); obc.setStatus(OutboundCommand.Status.PREPARED); AbstractCommand cmd = this.setCommandSource(obc); txLogger.logTransactionState(txstatus -> log.info( "Transaction {} for Prepared OutboundCommand: {}", txstatus, txLogger.printJsonObject(cmd))); this.receiveCommand( cmd, (meta) -> this.publisher.publishEvent(new OutboundCommandPrepared(obc.buildMeta())) ); }
CommandOrchestratorImpl implements CommandOrchestrator { @Override public void prepare(BaseTransactionCommand command) { OutboundCommand obc = this.commandMapper(command); obc.setStatus(OutboundCommand.Status.PREPARED); AbstractCommand cmd = this.setCommandSource(obc); txLogger.logTransactionState(txstatus -> log.info( "Transaction {} for Prepared OutboundCommand: {}", txstatus, txLogger.printJsonObject(cmd))); this.receiveCommand( cmd, (meta) -> this.publisher.publishEvent(new OutboundCommandPrepared(obc.buildMeta())) ); } }
CommandOrchestratorImpl implements CommandOrchestrator { @Override public void prepare(BaseTransactionCommand command) { OutboundCommand obc = this.commandMapper(command); obc.setStatus(OutboundCommand.Status.PREPARED); AbstractCommand cmd = this.setCommandSource(obc); txLogger.logTransactionState(txstatus -> log.info( "Transaction {} for Prepared OutboundCommand: {}", txstatus, txLogger.printJsonObject(cmd))); this.receiveCommand( cmd, (meta) -> this.publisher.publishEvent(new OutboundCommandPrepared(obc.buildMeta())) ); } @Autowired  CommandOrchestratorImpl(
        final CommandRepository commandRepository,
        final ApplicationEventPublisher publisher,
        final BubbleCache bubbleCache,
        final ObjectMapper mapper,
        final Environment environment,
        final KermossTxLogger txLogger
    ); }
CommandOrchestratorImpl implements CommandOrchestrator { @Override public void prepare(BaseTransactionCommand command) { OutboundCommand obc = this.commandMapper(command); obc.setStatus(OutboundCommand.Status.PREPARED); AbstractCommand cmd = this.setCommandSource(obc); txLogger.logTransactionState(txstatus -> log.info( "Transaction {} for Prepared OutboundCommand: {}", txstatus, txLogger.printJsonObject(cmd))); this.receiveCommand( cmd, (meta) -> this.publisher.publishEvent(new OutboundCommandPrepared(obc.buildMeta())) ); } @Autowired  CommandOrchestratorImpl(
        final CommandRepository commandRepository,
        final ApplicationEventPublisher publisher,
        final BubbleCache bubbleCache,
        final ObjectMapper mapper,
        final Environment environment,
        final KermossTxLogger txLogger
    ); @Override void receive(final InboundCommand command); @Override void receive(final OutboundCommand command); @Override void receive(BaseTransactionCommand command); @Override void prepare(BaseTransactionCommand command); @Override void prepare(InboundCommand command); @Override boolean isInboundCommandExist(String refId); @Override boolean isInboundCommandWithStatusExist(String refId, InboundCommand.Status status); @Override Optional<P> retreive(String eventId, Class<P> target); }
CommandOrchestratorImpl implements CommandOrchestrator { @Override public void prepare(BaseTransactionCommand command) { OutboundCommand obc = this.commandMapper(command); obc.setStatus(OutboundCommand.Status.PREPARED); AbstractCommand cmd = this.setCommandSource(obc); txLogger.logTransactionState(txstatus -> log.info( "Transaction {} for Prepared OutboundCommand: {}", txstatus, txLogger.printJsonObject(cmd))); this.receiveCommand( cmd, (meta) -> this.publisher.publishEvent(new OutboundCommandPrepared(obc.buildMeta())) ); } @Autowired  CommandOrchestratorImpl(
        final CommandRepository commandRepository,
        final ApplicationEventPublisher publisher,
        final BubbleCache bubbleCache,
        final ObjectMapper mapper,
        final Environment environment,
        final KermossTxLogger txLogger
    ); @Override void receive(final InboundCommand command); @Override void receive(final OutboundCommand command); @Override void receive(BaseTransactionCommand command); @Override void prepare(BaseTransactionCommand command); @Override void prepare(InboundCommand command); @Override boolean isInboundCommandExist(String refId); @Override boolean isInboundCommandWithStatusExist(String refId, InboundCommand.Status status); @Override Optional<P> retreive(String eventId, Class<P> target);  }