### Question:
AccountPayableEntryListener { @EventHandler public void handleOffseted(AccountPayableFeeOffsetedEvent event) { final AccountPayableFeeEntry entry = repository.findOne(event.getFeeId().toString()); if (entry == null) { logger.error("Entry not found with id {}", event.getFeeId()); } entry.setOffsetDate(event.getOffsetedDate()); entry.setOffseted(true); entry.setOffsetId(event.getOffsetId().toString()); 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);  }### Answer:
@Test public void testHandleOffseted() throws Exception { FeeId feeId = new FeeId("primaryKey"); OffsetId offsetId = new OffsetId(); Date offsetDate = new Date(); AccountPayableEntryListener listener = new AccountPayableEntryListener(); AccountPayableFeeEntryQueryRepository repository = mock(AccountPayableFeeEntryQueryRepository.class); when(repository.findOne(eq("primaryKey"))).thenReturn(new AccountPayableFeeEntry()); listener.setRepository(repository); AccountPayableFeeOffsetedEvent event = new AccountPayableFeeOffsetedEvent(feeId, offsetId, offsetDate); listener.handleOffseted(event); ArgumentCaptor<AccountPayableFeeEntry> captor = ArgumentCaptor.forClass(AccountPayableFeeEntry.class); verify(repository).save(captor.capture()); AccountPayableFeeEntry entity = captor.getValue(); assertThat(entity.getOffsetDate(), equalTo(offsetDate)); assertThat(entity.isOffseted(), is(true)); assertThat(entity.getOffsetId(), equalTo(offsetId.toString())); }