@Test public void testOnPortfolioCreatedEventAPortfolioViewIsCreated() { long expectedAmountOfMoney = 0L; long expectedAmountOfReservedMoney = 0L; testSubject.on(new PortfolioCreatedEvent(portfolioId, userId)); verify(portfolioViewRepository).save(viewCaptor.capture()); PortfolioView result = viewCaptor.getValue(); assertEquals(portfolioId.getIdentifier(), result.getIdentifier()); assertEquals(userId.getIdentifier(), result.getUserId()); assertEquals(expectedAmountOfMoney, result.getAmountOfMoney()); assertEquals(expectedAmountOfReservedMoney, result.getReservedAmountOfMoney()); }
@EventHandler public void on(PortfolioCreatedEvent event) { PortfolioView portfolioView = new PortfolioView(); portfolioView.setIdentifier(event.getPortfolioId().getIdentifier()); portfolioView.setUserId(event.getUserId().getIdentifier()); portfolioView.setAmountOfMoney(0); portfolioView.setReservedAmountOfMoney(0); portfolioViewRepository.save(portfolioView); }
PortfolioEventHandler { @EventHandler public void on(PortfolioCreatedEvent event) { PortfolioView portfolioView = new PortfolioView(); portfolioView.setIdentifier(event.getPortfolioId().getIdentifier()); portfolioView.setUserId(event.getUserId().getIdentifier()); portfolioView.setAmountOfMoney(0); portfolioView.setReservedAmountOfMoney(0); portfolioViewRepository.save(portfolioView); } }
PortfolioEventHandler { @EventHandler public void on(PortfolioCreatedEvent event) { PortfolioView portfolioView = new PortfolioView(); portfolioView.setIdentifier(event.getPortfolioId().getIdentifier()); portfolioView.setUserId(event.getUserId().getIdentifier()); portfolioView.setAmountOfMoney(0); portfolioView.setReservedAmountOfMoney(0); portfolioViewRepository.save(portfolioView); } PortfolioEventHandler(PortfolioViewRepository portfolioViewRepository,
                                 OrderBookViewRepository orderBookViewRepository); }
PortfolioEventHandler { @EventHandler public void on(PortfolioCreatedEvent event) { PortfolioView portfolioView = new PortfolioView(); portfolioView.setIdentifier(event.getPortfolioId().getIdentifier()); portfolioView.setUserId(event.getUserId().getIdentifier()); portfolioView.setAmountOfMoney(0); portfolioView.setReservedAmountOfMoney(0); portfolioViewRepository.save(portfolioView); } 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 { @EventHandler public void on(PortfolioCreatedEvent event) { PortfolioView portfolioView = new PortfolioView(); portfolioView.setIdentifier(event.getPortfolioId().getIdentifier()); portfolioView.setUserId(event.getUserId().getIdentifier()); portfolioView.setAmountOfMoney(0); portfolioView.setReservedAmountOfMoney(0); portfolioViewRepository.save(portfolioView); } 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);  }