### Question:
ReceivedFeeEntryListener { @EventHandler public void handleOffseted(ReceivedFeeOffsetedEvent event) { final ReceivedFeeEntry 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(ReceivedFeeCreatedEvent event); @EventHandler void handleConfirmed(ReceivedFeeConfirmedEvent event); @EventHandler void handleOffseted(ReceivedFeeOffsetedEvent event); @EventHandler void handleCancelled(ReceivedFeeCancelledEvent event); @Autowired @SuppressWarnings("SpringJavaAutowiringInspection") void setRepository(ReceivedFeeEntryQueryRepository repository);  }### Answer:
@Test public void testHandleOffseted() throws Exception { FeeId feeId = new FeeId("primaryKey"); OffsetId offsetId = new OffsetId(); Date offsetDate = new Date(); ReceivedFeeEntryListener listener = new ReceivedFeeEntryListener(); ReceivedFeeEntryQueryRepository repository = mock(ReceivedFeeEntryQueryRepository.class); when(repository.findOne(eq("primaryKey"))).thenReturn(new ReceivedFeeEntry()); listener.setRepository(repository); ReceivedFeeOffsetedEvent event = new ReceivedFeeOffsetedEvent(feeId, offsetId, offsetDate); listener.handleOffseted(event); ArgumentCaptor<ReceivedFeeEntry> captor = ArgumentCaptor.forClass(ReceivedFeeEntry.class); verify(repository).save(captor.capture()); ReceivedFeeEntry entity = captor.getValue(); assertThat(entity.getOffsetDate(), equalTo(offsetDate)); assertThat(entity.isOffseted(), is(true)); assertThat(entity.getOffsetId(), equalTo(offsetId.toString())); }