@Test public void testHandleOffseted() throws Exception { FeeId feeId = new FeeId("primaryKey"); OffsetId offsetId = new OffsetId(); Date offsetDate = new Date(); PaidFeeEntryListener listener = new PaidFeeEntryListener(); PaidFeeEntryQueryRepository repository = mock(PaidFeeEntryQueryRepository.class); when(repository.findOne(eq("primaryKey"))).thenReturn(new PaidFeeEntry()); listener.setRepository(repository); PaidFeeOffsetedEvent event = new PaidFeeOffsetedEvent(feeId, offsetId, offsetDate); listener.handleOffseted(event); ArgumentCaptor<PaidFeeEntry> captor = ArgumentCaptor.forClass(PaidFeeEntry.class); verify(repository).save(captor.capture()); PaidFeeEntry entity = captor.getValue(); assertThat(entity.getOffsetDate(), equalTo(offsetDate)); assertThat(entity.isOffseted(), is(true)); assertThat(entity.getOffsetId(), equalTo(offsetId.toString())); }
@EventHandler public void handleOffseted(PaidFeeOffsetedEvent event) { final PaidFeeEntry 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); }
PaidFeeEntryListener { @EventHandler public void handleOffseted(PaidFeeOffsetedEvent event) { final PaidFeeEntry 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); } }
PaidFeeEntryListener { @EventHandler public void handleOffseted(PaidFeeOffsetedEvent event) { final PaidFeeEntry 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); }  }
PaidFeeEntryListener { @EventHandler public void handleOffseted(PaidFeeOffsetedEvent event) { final PaidFeeEntry 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(PaidFeeCreatedEvent event); @EventHandler void handleConfirmed(PaidFeeConfirmedEvent event); @EventHandler void handleOffseted(PaidFeeOffsetedEvent event); @EventHandler void handleCancelled(PaidFeeCancelledEvent event); @Autowired @SuppressWarnings("SpringJavaAutowiringInspection") void setRepository(PaidFeeEntryQueryRepository repository); }
PaidFeeEntryListener { @EventHandler public void handleOffseted(PaidFeeOffsetedEvent event) { final PaidFeeEntry 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(PaidFeeCreatedEvent event); @EventHandler void handleConfirmed(PaidFeeConfirmedEvent event); @EventHandler void handleOffseted(PaidFeeOffsetedEvent event); @EventHandler void handleCancelled(PaidFeeCancelledEvent event); @Autowired @SuppressWarnings("SpringJavaAutowiringInspection") void setRepository(PaidFeeEntryQueryRepository repository);  }