@Test public void shouldGetRoleAssignmentsForAGivenUserOnAGivenProgramWithRights() throws Exception { Long userId = 1L; Long programId = 2L; List<RoleAssignment> expected = new ArrayList<>(); when(mapper.getHomeFacilityRolesForUserOnGivenProgramWithRights(userId, programId, "['CREATE_REQUISITION', 'AUTHORIZE_REQUISITION']")).thenReturn(expected); List<RoleAssignment> actual = repository.getHomeFacilityRolesForUserOnGivenProgramWithRights(userId, programId, CREATE_REQUISITION, AUTHORIZE_REQUISITION); assertThat(actual, is(expected)); }
public List<RoleAssignment> getHomeFacilityRolesForUserOnGivenProgramWithRights(Long userId, Long programId, String... rightNames) { return mapper.getHomeFacilityRolesForUserOnGivenProgramWithRights(userId, programId, commaSeparateRightNames(rightNames)); }
RoleAssignmentRepository { public List<RoleAssignment> getHomeFacilityRolesForUserOnGivenProgramWithRights(Long userId, Long programId, String... rightNames) { return mapper.getHomeFacilityRolesForUserOnGivenProgramWithRights(userId, programId, commaSeparateRightNames(rightNames)); } }
RoleAssignmentRepository { public List<RoleAssignment> getHomeFacilityRolesForUserOnGivenProgramWithRights(Long userId, Long programId, String... rightNames) { return mapper.getHomeFacilityRolesForUserOnGivenProgramWithRights(userId, programId, commaSeparateRightNames(rightNames)); } @Autowired  RoleAssignmentRepository(RoleAssignmentMapper roleAssignmentMapper); }
RoleAssignmentRepository { public List<RoleAssignment> getHomeFacilityRolesForUserOnGivenProgramWithRights(Long userId, Long programId, String... rightNames) { return mapper.getHomeFacilityRolesForUserOnGivenProgramWithRights(userId, programId, commaSeparateRightNames(rightNames)); } @Autowired  RoleAssignmentRepository(RoleAssignmentMapper roleAssignmentMapper); List<RoleAssignment> getRoleAssignmentsForUserWithRight(String rightName, Long userId); void deleteAllRoleAssignmentsForUser(Long id); List<RoleAssignment> getSupervisorRoles(Long userId); List<RoleAssignment> getHomeFacilityRoles(Long userId); List<RoleAssignment> getHomeFacilityRolesForUserOnGivenProgramWithRights(Long userId, Long programId, String... rightNames); RoleAssignment getAdminRole(Long userId); RoleAssignment getReportRole(Long userId); void insert(List<RoleAssignment> roleAssignments, final Long userId); List<RoleAssignment> getAllocationRoles(Long userId); RoleAssignment getReportingRole(Long userId); }
RoleAssignmentRepository { public List<RoleAssignment> getHomeFacilityRolesForUserOnGivenProgramWithRights(Long userId, Long programId, String... rightNames) { return mapper.getHomeFacilityRolesForUserOnGivenProgramWithRights(userId, programId, commaSeparateRightNames(rightNames)); } @Autowired  RoleAssignmentRepository(RoleAssignmentMapper roleAssignmentMapper); List<RoleAssignment> getRoleAssignmentsForUserWithRight(String rightName, Long userId); void deleteAllRoleAssignmentsForUser(Long id); List<RoleAssignment> getSupervisorRoles(Long userId); List<RoleAssignment> getHomeFacilityRoles(Long userId); List<RoleAssignment> getHomeFacilityRolesForUserOnGivenProgramWithRights(Long userId, Long programId, String... rightNames); RoleAssignment getAdminRole(Long userId); RoleAssignment getReportRole(Long userId); void insert(List<RoleAssignment> roleAssignments, final Long userId); List<RoleAssignment> getAllocationRoles(Long userId); RoleAssignment getReportingRole(Long userId);  }