@Test public void testRetreiveWhenCommandNotExistInBubbleMessage() throws IOException { final String eventId = "1234"; final TestData someData = new TestData("test user", "20"); final AbstractCommand command = mock(AbstractCommand.class); String payload = "{\"name\":\"test user\", \"age\":\"20\"}"; BubbleMessage message = mock(BubbleMessage.class); when(mockBubbleCache.getBubble(eventId)).thenReturn(Optional.empty()); final Optional<TestData> result = commandOrchestratorImplUnderTest.retreive(eventId, TestData.class); assertEquals( Optional.empty(), result); }
@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);  }