@Test public void testFindByPortfolioIdReturnsAPortfolioView() { PortfolioView testView = buildTestPortfolio(); when(portfolioViewRepository.getOne(portfolioId.getIdentifier())).thenReturn(testView); PortfolioView result = testSubject.find(new PortfolioByIdQuery(portfolioId)); assertEquals(testView, result); }
@QueryHandler public PortfolioView find(PortfolioByIdQuery query) { String portfolioId = query.getPortfolioId().getIdentifier(); return Optional.ofNullable(portfolioViewRepository.getOne(portfolioId)) .orElseGet(() -> { logger.warn("Tried to retrieve a Portfolio query model with a non existent portfolio id [{}]", portfolioId); return null; }); }
PortfolioEventHandler { @QueryHandler public PortfolioView find(PortfolioByIdQuery query) { String portfolioId = query.getPortfolioId().getIdentifier(); return Optional.ofNullable(portfolioViewRepository.getOne(portfolioId)) .orElseGet(() -> { logger.warn("Tried to retrieve a Portfolio query model with a non existent portfolio id [{}]", portfolioId); return null; }); } }
PortfolioEventHandler { @QueryHandler public PortfolioView find(PortfolioByIdQuery query) { String portfolioId = query.getPortfolioId().getIdentifier(); return Optional.ofNullable(portfolioViewRepository.getOne(portfolioId)) .orElseGet(() -> { logger.warn("Tried to retrieve a Portfolio query model with a non existent portfolio id [{}]", portfolioId); return null; }); } PortfolioEventHandler(PortfolioViewRepository portfolioViewRepository,
                                 OrderBookViewRepository orderBookViewRepository); }
PortfolioEventHandler { @QueryHandler public PortfolioView find(PortfolioByIdQuery query) { String portfolioId = query.getPortfolioId().getIdentifier(); return Optional.ofNullable(portfolioViewRepository.getOne(portfolioId)) .orElseGet(() -> { logger.warn("Tried to retrieve a Portfolio query model with a non existent portfolio id [{}]", portfolioId); return null; }); } PortfolioEventHandler(PortfolioViewRepository portfolioViewRepository,
                                 OrderBookViewRepository orderBookViewRepository); @EventHandler void on(PortfolioCreatedEvent event); @EventHandler void on(ItemsAddedToPortfolioEvent event); @EventHandler void on(ItemsReservedEvent event); @EventHandler void on(ItemReservationConfirmedForPortfolioEvent event); @EventHandler void on(ItemReservationCancelledForPortfolioEvent event); @EventHandler void on(CashDepositedEvent event); @EventHandler void on(CashWithdrawnEvent event); @EventHandler void on(CashReservedEvent event); @EventHandler void on(CashReservationCancelledEvent event); @EventHandler void on(CashReservationConfirmedEvent event); @QueryHandler PortfolioView find(PortfolioByIdQuery query); @QueryHandler PortfolioView find(PortfolioByUserIdQuery query); }
PortfolioEventHandler { @QueryHandler public PortfolioView find(PortfolioByIdQuery query) { String portfolioId = query.getPortfolioId().getIdentifier(); return Optional.ofNullable(portfolioViewRepository.getOne(portfolioId)) .orElseGet(() -> { logger.warn("Tried to retrieve a Portfolio query model with a non existent portfolio id [{}]", portfolioId); return null; }); } PortfolioEventHandler(PortfolioViewRepository portfolioViewRepository,
                                 OrderBookViewRepository orderBookViewRepository); @EventHandler void on(PortfolioCreatedEvent event); @EventHandler void on(ItemsAddedToPortfolioEvent event); @EventHandler void on(ItemsReservedEvent event); @EventHandler void on(ItemReservationConfirmedForPortfolioEvent event); @EventHandler void on(ItemReservationCancelledForPortfolioEvent event); @EventHandler void on(CashDepositedEvent event); @EventHandler void on(CashWithdrawnEvent event); @EventHandler void on(CashReservedEvent event); @EventHandler void on(CashReservationCancelledEvent event); @EventHandler void on(CashReservationConfirmedEvent event); @QueryHandler PortfolioView find(PortfolioByIdQuery query); @QueryHandler PortfolioView find(PortfolioByUserIdQuery query);  }