@Test public void update() throws Exception { when(eventOperationsService.createEvent("ANCESTRY_UPDATED", SECURE_USER)).thenReturn(UPDATE_EVENT); trackingOperationService.update(ANCESTRY, SECURE_USER, "ANCESTRY_UPDATED"); verify(eventOperationsService, times(1)).createEvent("ANCESTRY_UPDATED", SECURE_USER); Assertions.assertThat(ANCESTRY.getEvents()).hasSize(1); Assertions.assertThat(ANCESTRY.getEvents()) .extracting(event -> event.getUser().getEmail()) .contains("test@test.com"); Assertions.assertThat(ANCESTRY.getEvents()) .extracting(event -> event.getEventType()) .contains("ANCESTRY_UPDATED"); Assertions.assertThat(ANCESTRY.getEvents()).extracting(event -> event.getEventDate()).isNotNull(); }
@Override public void update(Trackable trackable, SecureUser secureUser, String eventType) { Event updateEvent = eventOperationsService.createEvent(eventType, secureUser); trackable.addEvent(updateEvent); }
AncestryTrackingOperationServiceImpl implements TrackingOperationService { @Override public void update(Trackable trackable, SecureUser secureUser, String eventType) { Event updateEvent = eventOperationsService.createEvent(eventType, secureUser); trackable.addEvent(updateEvent); } }
AncestryTrackingOperationServiceImpl implements TrackingOperationService { @Override public void update(Trackable trackable, SecureUser secureUser, String eventType) { Event updateEvent = eventOperationsService.createEvent(eventType, secureUser); trackable.addEvent(updateEvent); } @Autowired  AncestryTrackingOperationServiceImpl(EventOperationsService eventOperationsService); }
AncestryTrackingOperationServiceImpl implements TrackingOperationService { @Override public void update(Trackable trackable, SecureUser secureUser, String eventType) { Event updateEvent = eventOperationsService.createEvent(eventType, secureUser); trackable.addEvent(updateEvent); } @Autowired  AncestryTrackingOperationServiceImpl(EventOperationsService eventOperationsService); @Override void create(Trackable trackable, SecureUser secureUser); @Override void delete(Trackable trackable, SecureUser secureUser); @Override void update(Trackable trackable, SecureUser secureUser, String eventType); @Override void update(Trackable trackable, SecureUser secureUser, String eventType, String description); }
AncestryTrackingOperationServiceImpl implements TrackingOperationService { @Override public void update(Trackable trackable, SecureUser secureUser, String eventType) { Event updateEvent = eventOperationsService.createEvent(eventType, secureUser); trackable.addEvent(updateEvent); } @Autowired  AncestryTrackingOperationServiceImpl(EventOperationsService eventOperationsService); @Override void create(Trackable trackable, SecureUser secureUser); @Override void delete(Trackable trackable, SecureUser secureUser); @Override void update(Trackable trackable, SecureUser secureUser, String eventType); @Override void update(Trackable trackable, SecureUser secureUser, String eventType, String description);  }