EventRegistrationService { public Registration add(RegistrationAddPayload addPayload) throws AddEntityException, EntityNotFoundException { addPayload.setEvent(eventEntityService.getById(addPayload.getEventId())); return registrationEntityService.add(addPayload); } @Inject  EventRegistrationService(
            EventEntityService eventEntityService,
            RegistrationEntityService registrationEntityService
    ); Registration getByEventIdAndRegistrationId(String eventId, String registrationId); List<Registration> getAllWithEventId(String eventId); Registration add(RegistrationAddPayload addPayload);  }
@Test public void whenAddValid() throws Exception { RegistrationAddPayload registrationAddPayload = new RegistrationAddPayload(); registrationAddPayload.setEventId(TestConstants.EVENT_ID); Registration registration = mock(Registration.class); when(registrationEntityService.add(registrationAddPayload)).thenReturn(registration); Registration actual = eventRegistrationService.add(registrationAddPayload); verify(eventEntityService).getById(TestConstants.EVENT_ID); verify(registrationEntityService).add(registrationAddPayload); assertThat(actual).isSameAs(registration); }