@Test public void testOnCompanyCreatedEventACompanyViewIsSaved() { CompanyCreatedEvent testEvent = new CompanyCreatedEvent(testCompanyId, COMPANY_NAME, COMPANY_VALUE, AMOUNT_OF_SHARES); testSubject.on(testEvent); ArgumentCaptor<CompanyView> companyViewCaptor = ArgumentCaptor.forClass(CompanyView.class); verify(companyViewRepository).save(companyViewCaptor.capture()); CompanyView result = companyViewCaptor.getValue(); assertNotNull(result); assertEquals(testCompanyId.getIdentifier(), result.getIdentifier()); assertEquals(COMPANY_NAME, result.getName()); assertEquals(COMPANY_VALUE, result.getValue()); assertEquals(AMOUNT_OF_SHARES, result.getAmountOfShares()); }
@EventHandler public void on(CompanyCreatedEvent event) { CompanyView companyView = new CompanyView(); companyView.setIdentifier(event.getCompanyId().getIdentifier()); companyView.setValue(event.getCompanyValue()); companyView.setAmountOfShares(event.getAmountOfShares()); companyView.setTradeStarted(true); companyView.setName(event.getCompanyName()); companyRepository.save(companyView); }
CompanyEventHandler { @EventHandler public void on(CompanyCreatedEvent event) { CompanyView companyView = new CompanyView(); companyView.setIdentifier(event.getCompanyId().getIdentifier()); companyView.setValue(event.getCompanyValue()); companyView.setAmountOfShares(event.getAmountOfShares()); companyView.setTradeStarted(true); companyView.setName(event.getCompanyName()); companyRepository.save(companyView); } }
CompanyEventHandler { @EventHandler public void on(CompanyCreatedEvent event) { CompanyView companyView = new CompanyView(); companyView.setIdentifier(event.getCompanyId().getIdentifier()); companyView.setValue(event.getCompanyValue()); companyView.setAmountOfShares(event.getAmountOfShares()); companyView.setTradeStarted(true); companyView.setName(event.getCompanyName()); companyRepository.save(companyView); } CompanyEventHandler(CompanyViewRepository companyRepository); }
CompanyEventHandler { @EventHandler public void on(CompanyCreatedEvent event) { CompanyView companyView = new CompanyView(); companyView.setIdentifier(event.getCompanyId().getIdentifier()); companyView.setValue(event.getCompanyValue()); companyView.setAmountOfShares(event.getAmountOfShares()); companyView.setTradeStarted(true); companyView.setName(event.getCompanyName()); companyRepository.save(companyView); } CompanyEventHandler(CompanyViewRepository companyRepository); @EventHandler void on(CompanyCreatedEvent event); @QueryHandler CompanyView find(CompanyByIdQuery query); @QueryHandler List<CompanyView> find(FindAllCompaniesQuery query); }
CompanyEventHandler { @EventHandler public void on(CompanyCreatedEvent event) { CompanyView companyView = new CompanyView(); companyView.setIdentifier(event.getCompanyId().getIdentifier()); companyView.setValue(event.getCompanyValue()); companyView.setAmountOfShares(event.getAmountOfShares()); companyView.setTradeStarted(true); companyView.setName(event.getCompanyName()); companyRepository.save(companyView); } CompanyEventHandler(CompanyViewRepository companyRepository); @EventHandler void on(CompanyCreatedEvent event); @QueryHandler CompanyView find(CompanyByIdQuery query); @QueryHandler List<CompanyView> find(FindAllCompaniesQuery query);  }