@Test(expected = CommandUnmarchelingException.class) public void testRetreiveWhenCommandNotExistInDb() throws IOException { final String eventId = "1234"; BubbleMessage message = mock(BubbleMessage.class); when(mockBubbleCache.getBubble(eventId)).thenReturn(Optional.of(message)); when(mockCommandRepository.findOne(anyString())).thenReturn(null); final Optional<TestData> result = commandOrchestratorImplUnderTest.retreive(eventId, TestData.class); }
@Override public <P> Optional<P> retreive(String eventId, Class<P> target){ Optional<P> payload = Optional.empty(); Optional<BubbleMessage> bubbleMessage = (bubbleCache.getBubble(eventId)); if (bubbleMessage.isPresent()){ AbstractCommand c = commandRepository.findOne(bubbleMessage.get().getCommandId()); try { payload = Optional.of(mapper.readValue(c.getPayload(), target)); } catch (Exception e) { throw new CommandUnmarchelingException(e.getMessage()); } } return payload; }
CommandOrchestratorImpl implements CommandOrchestrator { @Override public <P> Optional<P> retreive(String eventId, Class<P> target){ Optional<P> payload = Optional.empty(); Optional<BubbleMessage> bubbleMessage = (bubbleCache.getBubble(eventId)); if (bubbleMessage.isPresent()){ AbstractCommand c = commandRepository.findOne(bubbleMessage.get().getCommandId()); try { payload = Optional.of(mapper.readValue(c.getPayload(), target)); } catch (Exception e) { throw new CommandUnmarchelingException(e.getMessage()); } } return payload; } }
CommandOrchestratorImpl implements CommandOrchestrator { @Override public <P> Optional<P> retreive(String eventId, Class<P> target){ Optional<P> payload = Optional.empty(); Optional<BubbleMessage> bubbleMessage = (bubbleCache.getBubble(eventId)); if (bubbleMessage.isPresent()){ AbstractCommand c = commandRepository.findOne(bubbleMessage.get().getCommandId()); try { payload = Optional.of(mapper.readValue(c.getPayload(), target)); } catch (Exception e) { throw new CommandUnmarchelingException(e.getMessage()); } } return payload; } @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 <P> Optional<P> retreive(String eventId, Class<P> target){ Optional<P> payload = Optional.empty(); Optional<BubbleMessage> bubbleMessage = (bubbleCache.getBubble(eventId)); if (bubbleMessage.isPresent()){ AbstractCommand c = commandRepository.findOne(bubbleMessage.get().getCommandId()); try { payload = Optional.of(mapper.readValue(c.getPayload(), target)); } catch (Exception e) { throw new CommandUnmarchelingException(e.getMessage()); } } return payload; } @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 <P> Optional<P> retreive(String eventId, Class<P> target){ Optional<P> payload = Optional.empty(); Optional<BubbleMessage> bubbleMessage = (bubbleCache.getBubble(eventId)); if (bubbleMessage.isPresent()){ AbstractCommand c = commandRepository.findOne(bubbleMessage.get().getCommandId()); try { payload = Optional.of(mapper.readValue(c.getPayload(), target)); } catch (Exception e) { throw new CommandUnmarchelingException(e.getMessage()); } } return payload; } @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);  }