@Test public void testFindTransactionByIdReturnsATransactionView() { TransactionView testView = new TransactionView(); when(transactionViewRepository.getOne(transactionId.getIdentifier())).thenReturn(testView); TransactionView result = testSubject.find(new TransactionByIdQuery(transactionId)); assertNotNull(result); assertEquals(testView, result); }
@QueryHandler public TransactionView find(TransactionByIdQuery query) { String transactionId = query.getTransactionId().getIdentifier(); return Optional.ofNullable(transactionViewRepository.getOne(transactionId)) .orElseGet(() -> { logger.warn( "Tried to retrieve a Transaction query model with a non existent transaction id [{}]", transactionId ); return null; }); }
TransactionEventHandler { @QueryHandler public TransactionView find(TransactionByIdQuery query) { String transactionId = query.getTransactionId().getIdentifier(); return Optional.ofNullable(transactionViewRepository.getOne(transactionId)) .orElseGet(() -> { logger.warn( "Tried to retrieve a Transaction query model with a non existent transaction id [{}]", transactionId ); return null; }); } }
TransactionEventHandler { @QueryHandler public TransactionView find(TransactionByIdQuery query) { String transactionId = query.getTransactionId().getIdentifier(); return Optional.ofNullable(transactionViewRepository.getOne(transactionId)) .orElseGet(() -> { logger.warn( "Tried to retrieve a Transaction query model with a non existent transaction id [{}]", transactionId ); return null; }); } TransactionEventHandler(OrderBookViewRepository orderBookViewRepository,
                                   TransactionViewRepository transactionViewRepository); }
TransactionEventHandler { @QueryHandler public TransactionView find(TransactionByIdQuery query) { String transactionId = query.getTransactionId().getIdentifier(); return Optional.ofNullable(transactionViewRepository.getOne(transactionId)) .orElseGet(() -> { logger.warn( "Tried to retrieve a Transaction query model with a non existent transaction id [{}]", transactionId ); return null; }); } TransactionEventHandler(OrderBookViewRepository orderBookViewRepository,
                                   TransactionViewRepository transactionViewRepository); @EventHandler void on(BuyTransactionStartedEvent event); @EventHandler void on(SellTransactionStartedEvent event); @EventHandler void on(BuyTransactionCancelledEvent event); @EventHandler void on(SellTransactionCancelledEvent event); @EventHandler void on(BuyTransactionConfirmedEvent event); @EventHandler void on(SellTransactionConfirmedEvent event); @EventHandler void on(BuyTransactionExecutedEvent event); @EventHandler void on(SellTransactionExecutedEvent event); @EventHandler void on(BuyTransactionPartiallyExecutedEvent event); @EventHandler void on(SellTransactionPartiallyExecutedEvent event); @QueryHandler TransactionView find(TransactionByIdQuery query); @QueryHandler List<TransactionView> find(TransactionsByPortfolioIdQuery query); }
TransactionEventHandler { @QueryHandler public TransactionView find(TransactionByIdQuery query) { String transactionId = query.getTransactionId().getIdentifier(); return Optional.ofNullable(transactionViewRepository.getOne(transactionId)) .orElseGet(() -> { logger.warn( "Tried to retrieve a Transaction query model with a non existent transaction id [{}]", transactionId ); return null; }); } TransactionEventHandler(OrderBookViewRepository orderBookViewRepository,
                                   TransactionViewRepository transactionViewRepository); @EventHandler void on(BuyTransactionStartedEvent event); @EventHandler void on(SellTransactionStartedEvent event); @EventHandler void on(BuyTransactionCancelledEvent event); @EventHandler void on(SellTransactionCancelledEvent event); @EventHandler void on(BuyTransactionConfirmedEvent event); @EventHandler void on(SellTransactionConfirmedEvent event); @EventHandler void on(BuyTransactionExecutedEvent event); @EventHandler void on(SellTransactionExecutedEvent event); @EventHandler void on(BuyTransactionPartiallyExecutedEvent event); @EventHandler void on(SellTransactionPartiallyExecutedEvent event); @QueryHandler TransactionView find(TransactionByIdQuery query); @QueryHandler List<TransactionView> find(TransactionsByPortfolioIdQuery query);  }