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