@Test public void testHandleCancelled() throws Exception { FeeId feeId = new FeeId("primaryKey"); CancelledReason cancelledReason = CancelledReason.INVALID_ADDRESS; Date cancelledDate = new Date(); AccountReceivableEntryListener listener = new AccountReceivableEntryListener(); AccountReceivableFeeEntryQueryRepository repository = mock(AccountReceivableFeeEntryQueryRepository.class); when(repository.findOne(eq("primaryKey"))).thenReturn(new AccountReceivableFeeEntry()); listener.setRepository(repository); AccountReceivableFeeCancelledEvent event = new AccountReceivableFeeCancelledEvent(feeId, cancelledReason, cancelledDate); listener.handleCancelled(event); ArgumentCaptor<AccountReceivableFeeEntry> captor = ArgumentCaptor.forClass(AccountReceivableFeeEntry.class); verify(repository).save(captor.capture()); AccountReceivableFeeEntry entity = captor.getValue(); assertThat(entity.getCancelledDate(), equalTo(cancelledDate)); assertThat(entity.getCancelledReason(), is(cancelledReason)); assertThat(entity.getFeeStatus(), is(FeeStatus.CANCELLED)); }
@EventHandler public void handleCancelled(AccountReceivableFeeCancelledEvent event) { final AccountReceivableFeeEntry entry = repository.findOne(event.getFeeId().toString()); if (entry == null) { logger.error("Entry not found with id {}", event.getFeeId()); } entry.setCancelledDate(event.getCancelledDate()); entry.setCancelledReason(event.getCancelledReason()); entry.setFeeStatus(FeeStatus.CANCELLED); repository.save(entry); }
AccountReceivableEntryListener { @EventHandler public void handleCancelled(AccountReceivableFeeCancelledEvent event) { final AccountReceivableFeeEntry entry = repository.findOne(event.getFeeId().toString()); if (entry == null) { logger.error("Entry not found with id {}", event.getFeeId()); } entry.setCancelledDate(event.getCancelledDate()); entry.setCancelledReason(event.getCancelledReason()); entry.setFeeStatus(FeeStatus.CANCELLED); repository.save(entry); } }
AccountReceivableEntryListener { @EventHandler public void handleCancelled(AccountReceivableFeeCancelledEvent event) { final AccountReceivableFeeEntry entry = repository.findOne(event.getFeeId().toString()); if (entry == null) { logger.error("Entry not found with id {}", event.getFeeId()); } entry.setCancelledDate(event.getCancelledDate()); entry.setCancelledReason(event.getCancelledReason()); entry.setFeeStatus(FeeStatus.CANCELLED); repository.save(entry); }  }
AccountReceivableEntryListener { @EventHandler public void handleCancelled(AccountReceivableFeeCancelledEvent event) { final AccountReceivableFeeEntry entry = repository.findOne(event.getFeeId().toString()); if (entry == null) { logger.error("Entry not found with id {}", event.getFeeId()); } entry.setCancelledDate(event.getCancelledDate()); entry.setCancelledReason(event.getCancelledReason()); entry.setFeeStatus(FeeStatus.CANCELLED); repository.save(entry); }  @EventHandler void handleCreated(AccountReceivableFeeCreatedEvent event); @EventHandler void handleConfirmed(AccountReceivableFeeConfirmedEvent event); @EventHandler void handleOffseted(AccountReceivableFeeOffsetedEvent event); @EventHandler void handleCancelled(AccountReceivableFeeCancelledEvent event); @Autowired @SuppressWarnings("SpringJavaAutowiringInspection") void setRepository(AccountReceivableFeeEntryQueryRepository repository); }
AccountReceivableEntryListener { @EventHandler public void handleCancelled(AccountReceivableFeeCancelledEvent event) { final AccountReceivableFeeEntry entry = repository.findOne(event.getFeeId().toString()); if (entry == null) { logger.error("Entry not found with id {}", event.getFeeId()); } entry.setCancelledDate(event.getCancelledDate()); entry.setCancelledReason(event.getCancelledReason()); entry.setFeeStatus(FeeStatus.CANCELLED); repository.save(entry); }  @EventHandler void handleCreated(AccountReceivableFeeCreatedEvent event); @EventHandler void handleConfirmed(AccountReceivableFeeConfirmedEvent event); @EventHandler void handleOffseted(AccountReceivableFeeOffsetedEvent event); @EventHandler void handleCancelled(AccountReceivableFeeCancelledEvent event); @Autowired @SuppressWarnings("SpringJavaAutowiringInspection") void setRepository(AccountReceivableFeeEntryQueryRepository repository);  }