@Test public void shouldSaveUserFulfilmentRoleAssignments() throws Exception { User user = new User(); user.setFulfillmentRoles(asList(new FulfillmentRoleAssignment(2l, 3l, asList(2l, 4l)))); service.saveRolesForUser(user); verify(fulfillmentRoleService).saveFulfillmentRoles(user); }
public void saveRolesForUser(User user) { roleAssignmentRepository.deleteAllRoleAssignmentsForUser(user.getId()); roleAssignmentRepository.insert(user.getHomeFacilityRoles(), user.getId()); roleAssignmentRepository.insert(user.getSupervisorRoles(), user.getId()); roleAssignmentRepository.insert(user.getAllocationRoles(), user.getId()); roleAssignmentRepository.insert(asList(user.getReportRoles()), user.getId()); roleAssignmentRepository.insert(asList(user.getAdminRole()), user.getId()); roleAssignmentRepository.insert(asList(user.getReportingRole()), user.getId()); fulfillmentRoleService.saveFulfillmentRoles(user); }
RoleAssignmentService { public void saveRolesForUser(User user) { roleAssignmentRepository.deleteAllRoleAssignmentsForUser(user.getId()); roleAssignmentRepository.insert(user.getHomeFacilityRoles(), user.getId()); roleAssignmentRepository.insert(user.getSupervisorRoles(), user.getId()); roleAssignmentRepository.insert(user.getAllocationRoles(), user.getId()); roleAssignmentRepository.insert(asList(user.getReportRoles()), user.getId()); roleAssignmentRepository.insert(asList(user.getAdminRole()), user.getId()); roleAssignmentRepository.insert(asList(user.getReportingRole()), user.getId()); fulfillmentRoleService.saveFulfillmentRoles(user); } }
RoleAssignmentService { public void saveRolesForUser(User user) { roleAssignmentRepository.deleteAllRoleAssignmentsForUser(user.getId()); roleAssignmentRepository.insert(user.getHomeFacilityRoles(), user.getId()); roleAssignmentRepository.insert(user.getSupervisorRoles(), user.getId()); roleAssignmentRepository.insert(user.getAllocationRoles(), user.getId()); roleAssignmentRepository.insert(asList(user.getReportRoles()), user.getId()); roleAssignmentRepository.insert(asList(user.getAdminRole()), user.getId()); roleAssignmentRepository.insert(asList(user.getReportingRole()), user.getId()); fulfillmentRoleService.saveFulfillmentRoles(user); }  }
RoleAssignmentService { public void saveRolesForUser(User user) { roleAssignmentRepository.deleteAllRoleAssignmentsForUser(user.getId()); roleAssignmentRepository.insert(user.getHomeFacilityRoles(), user.getId()); roleAssignmentRepository.insert(user.getSupervisorRoles(), user.getId()); roleAssignmentRepository.insert(user.getAllocationRoles(), user.getId()); roleAssignmentRepository.insert(asList(user.getReportRoles()), user.getId()); roleAssignmentRepository.insert(asList(user.getAdminRole()), user.getId()); roleAssignmentRepository.insert(asList(user.getReportingRole()), user.getId()); fulfillmentRoleService.saveFulfillmentRoles(user); }  List<RoleAssignment> getHomeFacilityRoles(Long userId); RoleAssignment getAdminRole(Long userId); RoleAssignment getReportRole(Long userId); List<RoleAssignment> getSupervisorRoles(Long userId); List<RoleAssignment> getAllocationRoles(Long userId); List<RoleAssignment> getHomeFacilityRolesForUserOnGivenProgramWithRights(Long userId, Long programId, String... rightNames); List<RoleAssignment> getRoleAssignments(String rightName, Long userId); void saveRolesForUser(User user); List<FulfillmentRoleAssignment> getFulfilmentRoles(Long userId); List<FulfillmentRoleAssignment> getFulfilmentRolesWithRight(Long userId, String rightName); RoleAssignment getReportingRole(Long userId); }
RoleAssignmentService { public void saveRolesForUser(User user) { roleAssignmentRepository.deleteAllRoleAssignmentsForUser(user.getId()); roleAssignmentRepository.insert(user.getHomeFacilityRoles(), user.getId()); roleAssignmentRepository.insert(user.getSupervisorRoles(), user.getId()); roleAssignmentRepository.insert(user.getAllocationRoles(), user.getId()); roleAssignmentRepository.insert(asList(user.getReportRoles()), user.getId()); roleAssignmentRepository.insert(asList(user.getAdminRole()), user.getId()); roleAssignmentRepository.insert(asList(user.getReportingRole()), user.getId()); fulfillmentRoleService.saveFulfillmentRoles(user); }  List<RoleAssignment> getHomeFacilityRoles(Long userId); RoleAssignment getAdminRole(Long userId); RoleAssignment getReportRole(Long userId); List<RoleAssignment> getSupervisorRoles(Long userId); List<RoleAssignment> getAllocationRoles(Long userId); List<RoleAssignment> getHomeFacilityRolesForUserOnGivenProgramWithRights(Long userId, Long programId, String... rightNames); List<RoleAssignment> getRoleAssignments(String rightName, Long userId); void saveRolesForUser(User user); List<FulfillmentRoleAssignment> getFulfilmentRoles(Long userId); List<FulfillmentRoleAssignment> getFulfilmentRolesWithRight(Long userId, String rightName); RoleAssignment getReportingRole(Long userId);  }