@Test public void testHandleConfirmed() throws Exception { FeeId feeId = new FeeId("primaryKey"); Date confirmedDate = new Date(); PaidFeeEntryQueryRepository repository = mock(PaidFeeEntryQueryRepository.class); when(repository.findOne(eq("primaryKey"))).thenReturn(new PaidFeeEntry()); PaidFeeEntryListener listener = new PaidFeeEntryListener(); listener.setRepository(repository); PaidFeeConfirmedEvent event = new PaidFeeConfirmedEvent(feeId, "sequenceNumber", confirmedDate); listener.handleConfirmed(event); ArgumentCaptor<PaidFeeEntry> captor = ArgumentCaptor.forClass(PaidFeeEntry.class); verify(repository).save(captor.capture()); PaidFeeEntry entity = captor.getValue(); assertThat(entity.getConfirmedDate(), equalTo(confirmedDate)); assertThat(entity.getFeeStatus(), is(FeeStatus.CONFIRMED)); assertThat(entity.getSequenceNumber(), equalTo("sequenceNumber")); }
@EventHandler public void handleConfirmed(PaidFeeConfirmedEvent event) { final PaidFeeEntry entry = repository.findOne(event.getFeeId().toString()); if (entry == null) { logger.error("Entry not found with id {}", event.getFeeId()); } entry.setConfirmedDate(event.getConfirmedDate()); entry.setFeeStatus(FeeStatus.CONFIRMED); entry.setSequenceNumber(event.getSequenceNumber()); repository.save(entry); }
PaidFeeEntryListener { @EventHandler public void handleConfirmed(PaidFeeConfirmedEvent event) { final PaidFeeEntry entry = repository.findOne(event.getFeeId().toString()); if (entry == null) { logger.error("Entry not found with id {}", event.getFeeId()); } entry.setConfirmedDate(event.getConfirmedDate()); entry.setFeeStatus(FeeStatus.CONFIRMED); entry.setSequenceNumber(event.getSequenceNumber()); repository.save(entry); } }
PaidFeeEntryListener { @EventHandler public void handleConfirmed(PaidFeeConfirmedEvent event) { final PaidFeeEntry entry = repository.findOne(event.getFeeId().toString()); if (entry == null) { logger.error("Entry not found with id {}", event.getFeeId()); } entry.setConfirmedDate(event.getConfirmedDate()); entry.setFeeStatus(FeeStatus.CONFIRMED); entry.setSequenceNumber(event.getSequenceNumber()); repository.save(entry); }  }
PaidFeeEntryListener { @EventHandler public void handleConfirmed(PaidFeeConfirmedEvent event) { final PaidFeeEntry entry = repository.findOne(event.getFeeId().toString()); if (entry == null) { logger.error("Entry not found with id {}", event.getFeeId()); } entry.setConfirmedDate(event.getConfirmedDate()); entry.setFeeStatus(FeeStatus.CONFIRMED); entry.setSequenceNumber(event.getSequenceNumber()); 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 handleConfirmed(PaidFeeConfirmedEvent event) { final PaidFeeEntry entry = repository.findOne(event.getFeeId().toString()); if (entry == null) { logger.error("Entry not found with id {}", event.getFeeId()); } entry.setConfirmedDate(event.getConfirmedDate()); entry.setFeeStatus(FeeStatus.CONFIRMED); entry.setSequenceNumber(event.getSequenceNumber()); 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);  }