CommandOrchestratorImpl implements CommandOrchestrator { @Override public boolean isInboundCommandWithStatusExist(String refId, InboundCommand.Status status) { if (commandRepository.findByIdAndStatus(refId, status).isPresent()){ return true; } return false; } @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);  }
@Test public void testIsInboundCommandWithStatusExistWhenCommandInDB() { final String refId = "123"; final InboundCommand.Status status = InboundCommand.Status.STARTED; final InboundCommand command = mock(InboundCommand.class); when(mockCommandRepository.findByIdAndStatus(refId, status)).thenReturn(Optional.of(command)); final boolean result = commandOrchestratorImplUnderTest.isInboundCommandWithStatusExist(refId, status); assertEquals(true, result); }
@Test public void testIsInboundCommandWithStatusExistWhenCommandNotInDB() { final String refId = "123"; final InboundCommand.Status status = InboundCommand.Status.STARTED; when(mockCommandRepository.findByIdAndStatus(refId, status)).thenReturn(Optional.empty()); final boolean result = commandOrchestratorImplUnderTest.isInboundCommandWithStatusExist(refId, status); assertEquals(false, result); }