@Test public void test_should_not_throw_exception_when_employee_eligible_to_update_request() { when(employeeRepository.getEmployeeById(1L, "tenantId")).thenReturn(getEmployeeEligible()); when(submissionRepository.getPosition("crn", "tenantId")).thenReturn(1L); final AuthenticatedUser user = AuthenticatedUser.builder() .type(UserType.EMPLOYEE) .id(1L) .build(); 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);  }