@Test(expected = UpdateServiceRequestNotAllowedException.class) public void test_should_throw_exception_when_employee_not_eligible_to_update_request() { final List<String> roleCodes = Collections.singletonList("RO"); final AuthenticatedUser user = AuthenticatedUser.builder() .id(1L) .type(UserType.EMPLOYEE) .roleCodes(roleCodes).build(); when(employeeRepository.getEmployeeById(1L, "tenantId")) .thenReturn(getEmployee()); when(submissionRepository.getPosition("crn", "tenantId")) .thenReturn(1L); service.validate("crn", "tenantId", user); }
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);  }