@Test public void testHandleCreated() throws Exception { FeeId feeId = new FeeId(); FeeStatus feeStatus = FeeStatus.PENDING; BigMoney amount = BigMoney.parse("BTC 30"); FeeType feeType = FeeType.PAY_COIN; Date dueDate = new Date(); Date businessCreationTime = new Date(); String portfolioId = "portfolioId"; String userId = "userId"; BusinessType businessType = BusinessType.CHARGE_COIN_COMMISSION; String businessReferenceId = "businessReferenceId"; AccountPayableFeeEntryQueryRepository repository = mock(AccountPayableFeeEntryQueryRepository.class); AccountPayableFeeCreatedEvent event = new AccountPayableFeeCreatedEvent(feeId, feeStatus, amount, feeType, dueDate, businessCreationTime, portfolioId, userId, businessType, businessReferenceId); AccountPayableEntryListener listener = new AccountPayableEntryListener(); listener.setRepository(repository); listener.handleCreated(event); ArgumentCaptor<AccountPayableFeeEntry> captor = ArgumentCaptor.forClass(AccountPayableFeeEntry.class); verify(repository).save(captor.capture()); AccountPayableFeeEntry entity = captor.getValue(); assertThat(entity.getPrimaryKey(), equalTo(feeId.toString())); assertThat(entity.getFeeStatus(), is(feeStatus)); assertThat(entity.getAmount(), equalTo(amount)); assertThat(entity.getFeeType(), equalTo(feeType)); assertThat(entity.getDueDate(), equalTo(dueDate)); assertThat(entity.getBusinessCreationTime(), equalTo(businessCreationTime)); assertThat(entity.getPortfolioId(), equalTo(portfolioId)); assertThat(entity.getUserId(), equalTo(userId)); assertThat(entity.getBusinessType(), equalTo(businessType)); assertThat(entity.getBusinessReferenceId(), equalTo(businessReferenceId)); }
@EventHandler public void handleCreated(AccountPayableFeeCreatedEvent event) { AccountPayableFeeEntry entry = new AccountPayableFeeEntry(); entry.copy(event); repository.save(entry); }
AccountPayableEntryListener { @EventHandler public void handleCreated(AccountPayableFeeCreatedEvent event) { AccountPayableFeeEntry entry = new AccountPayableFeeEntry(); entry.copy(event); repository.save(entry); } }
AccountPayableEntryListener { @EventHandler public void handleCreated(AccountPayableFeeCreatedEvent event) { AccountPayableFeeEntry entry = new AccountPayableFeeEntry(); entry.copy(event); repository.save(entry); }  }
AccountPayableEntryListener { @EventHandler public void handleCreated(AccountPayableFeeCreatedEvent event) { AccountPayableFeeEntry entry = new AccountPayableFeeEntry(); entry.copy(event); repository.save(entry); }  @EventHandler void handleCreated(AccountPayableFeeCreatedEvent event); @EventHandler void handleConfirmed(AccountPayableFeeConfirmedEvent event); @EventHandler void handleOffseted(AccountPayableFeeOffsetedEvent event); @EventHandler void handleCancelled(AccountPayableFeeCancelledEvent event); @Autowired @SuppressWarnings("SpringJavaAutowiringInspection") void setRepository(AccountPayableFeeEntryQueryRepository repository); }
AccountPayableEntryListener { @EventHandler public void handleCreated(AccountPayableFeeCreatedEvent event) { AccountPayableFeeEntry entry = new AccountPayableFeeEntry(); entry.copy(event); repository.save(entry); }  @EventHandler void handleCreated(AccountPayableFeeCreatedEvent event); @EventHandler void handleConfirmed(AccountPayableFeeConfirmedEvent event); @EventHandler void handleOffseted(AccountPayableFeeOffsetedEvent event); @EventHandler void handleCancelled(AccountPayableFeeCancelledEvent event); @Autowired @SuppressWarnings("SpringJavaAutowiringInspection") void setRepository(AccountPayableFeeEntryQueryRepository repository);  }