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