@Test public void create() throws Exception { when(eventOperationsService.createEvent("ANCESTRY_CREATED", SECURE_USER)).thenReturn(CREATE_EVENT); trackingOperationService.create(ANCESTRY, SECURE_USER); verify(eventOperationsService, times(1)).createEvent("ANCESTRY_CREATED", 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_CREATED"); Assertions.assertThat(ANCESTRY.getEvents()).extracting(event -> event.getEventDate()).isNotNull(); }
@Override public void create(Trackable trackable, SecureUser secureUser) { Event createEvent = eventOperationsService.createEvent("ANCESTRY_CREATED", secureUser); trackable.addEvent(createEvent); }
AncestryTrackingOperationServiceImpl implements TrackingOperationService { @Override public void create(Trackable trackable, SecureUser secureUser) { Event createEvent = eventOperationsService.createEvent("ANCESTRY_CREATED", secureUser); trackable.addEvent(createEvent); } }
AncestryTrackingOperationServiceImpl implements TrackingOperationService { @Override public void create(Trackable trackable, SecureUser secureUser) { Event createEvent = eventOperationsService.createEvent("ANCESTRY_CREATED", secureUser); trackable.addEvent(createEvent); } @Autowired  AncestryTrackingOperationServiceImpl(EventOperationsService eventOperationsService); }
AncestryTrackingOperationServiceImpl implements TrackingOperationService { @Override public void create(Trackable trackable, SecureUser secureUser) { Event createEvent = eventOperationsService.createEvent("ANCESTRY_CREATED", secureUser); trackable.addEvent(createEvent); } @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 create(Trackable trackable, SecureUser secureUser) { Event createEvent = eventOperationsService.createEvent("ANCESTRY_CREATED", secureUser); trackable.addEvent(createEvent); } @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);  }