@Test(expected = UpdateServiceRequestNotAllowedException.class) public void test_should_throw_exception_when_citizen_attempts_to_update_request_that_was_created_by_another_logged_in_citizen() { final AuthenticatedUser citizen = AuthenticatedUser.builder() .id(1L) .type(UserType.CITIZEN) .build(); when(submissionRepository.getLoggedInRequester("crn", "tenantId")) .thenReturn(2L); service.validate("crn", "tenantId", citizen); }
public void validate(String serviceRequestId, String tenantId, AuthenticatedUser user) { validateAnonymousUserNotAllowedToUpdate(user); validateCitizenUpdateEligibility(serviceRequestId, tenantId, user); validateEmployeeUpdateEligibility(serviceRequestId, tenantId, user); }
UpdateServiceRequestEligibilityService { public void validate(String serviceRequestId, String tenantId, AuthenticatedUser user) { validateAnonymousUserNotAllowedToUpdate(user); validateCitizenUpdateEligibility(serviceRequestId, tenantId, user); validateEmployeeUpdateEligibility(serviceRequestId, tenantId, user); } }
UpdateServiceRequestEligibilityService { public void validate(String serviceRequestId, String tenantId, AuthenticatedUser user) { validateAnonymousUserNotAllowedToUpdate(user); validateCitizenUpdateEligibility(serviceRequestId, tenantId, user); validateEmployeeUpdateEligibility(serviceRequestId, tenantId, user); } UpdateServiceRequestEligibilityService(SubmissionRepository submissionRepository,
                                                  EmployeeRepository employeeRepository); }
UpdateServiceRequestEligibilityService { public void validate(String serviceRequestId, String tenantId, AuthenticatedUser user) { validateAnonymousUserNotAllowedToUpdate(user); validateCitizenUpdateEligibility(serviceRequestId, tenantId, user); validateEmployeeUpdateEligibility(serviceRequestId, tenantId, user); } UpdateServiceRequestEligibilityService(SubmissionRepository submissionRepository,
                                                  EmployeeRepository employeeRepository); void validate(String serviceRequestId, String tenantId, AuthenticatedUser user); }
UpdateServiceRequestEligibilityService { public void validate(String serviceRequestId, String tenantId, AuthenticatedUser user) { validateAnonymousUserNotAllowedToUpdate(user); validateCitizenUpdateEligibility(serviceRequestId, tenantId, user); validateEmployeeUpdateEligibility(serviceRequestId, tenantId, user); } UpdateServiceRequestEligibilityService(SubmissionRepository submissionRepository,
                                                  EmployeeRepository employeeRepository); void validate(String serviceRequestId, String tenantId, AuthenticatedUser user);  }