@Test public void testReceiveBaseTransactionCommand() throws JsonProcessingException { final BaseTransactionCommand command = mock(BaseTransactionCommand.class); final AbstractCommand abstractCommand = mock(AbstractCommand.class); ArgumentCaptor<OutboundCommand> commandArgumentCaptor = ArgumentCaptor.forClass(OutboundCommand.class); BubbleMessage message = mock(BubbleMessage.class); when(mockBubbleCache.getBubble(anyString())).thenReturn(Optional.of(message)); when(mockMapper.writeValueAsString(anyString())).thenReturn(PAYLOAD); when(abstractCommand.buildMeta()).thenReturn(mockCommandMeta); when(mockCommandRepository.save(any(AbstractCommand.class))).thenReturn(abstractCommand); when(mockEnvironment.getProperty(same("kermoss.serviceName"), anyString())).thenReturn("source"); commandOrchestratorImplUnderTest.receive(command); verify(mockCommandRepository).save(commandArgumentCaptor.capture()); OutboundCommand mappedCommand = commandArgumentCaptor.getValue(); verify(mockPublisher).publishEvent(any(OutboundCommandStarted.class)); Assert.assertEquals(mappedCommand.getPayload(), PAYLOAD); Assert.assertEquals(mappedCommand.getSource(), "source"); verify(mockPublisher).publishEvent(any(OutboundCommandStarted.class)); }
@Override public void receive(final InboundCommand command) { txLogger.logTransactionState(txstatus -> log.info( "Transaction {} for InboundCommand: {}", txstatus, txLogger.printJsonObject(command))); this.receiveCommand( command, (meta) -> this.publisher.publishEvent(new InboundCommandStarted(meta)) ); }
CommandOrchestratorImpl implements CommandOrchestrator { @Override public void receive(final InboundCommand command) { txLogger.logTransactionState(txstatus -> log.info( "Transaction {} for InboundCommand: {}", txstatus, txLogger.printJsonObject(command))); this.receiveCommand( command, (meta) -> this.publisher.publishEvent(new InboundCommandStarted(meta)) ); } }
CommandOrchestratorImpl implements CommandOrchestrator { @Override public void receive(final InboundCommand command) { txLogger.logTransactionState(txstatus -> log.info( "Transaction {} for InboundCommand: {}", txstatus, txLogger.printJsonObject(command))); this.receiveCommand( command, (meta) -> this.publisher.publishEvent(new InboundCommandStarted(meta)) ); } @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 receive(final InboundCommand command) { txLogger.logTransactionState(txstatus -> log.info( "Transaction {} for InboundCommand: {}", txstatus, txLogger.printJsonObject(command))); this.receiveCommand( command, (meta) -> this.publisher.publishEvent(new InboundCommandStarted(meta)) ); } @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 receive(final InboundCommand command) { txLogger.logTransactionState(txstatus -> log.info( "Transaction {} for InboundCommand: {}", txstatus, txLogger.printJsonObject(command))); this.receiveCommand( command, (meta) -> this.publisher.publishEvent(new InboundCommandStarted(meta)) ); } @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);  }