@Test public void shouldSaveRoleWithMappings() throws Exception { role.setRights(asList(new Right(CONFIGURE_RNR, RightType.ADMIN), new Right(CREATE_REQUISITION, RightType.REQUISITION))); role.setId(1L); roleRightsRepository.createRole(role); verify(roleRightsMapper).insertRole(role); verify(roleRightsMapper).createRoleRight(role, CONFIGURE_RNR); verify(roleRightsMapper).createRoleRight(role, CREATE_REQUISITION); }
public void createRole(Role role) { try { roleRightsMapper.insertRole(role); } catch (DuplicateKeyException e) { throw new DataException("error.duplicate.role"); } createRoleRights(role); }
RoleRightsRepository { public void createRole(Role role) { try { roleRightsMapper.insertRole(role); } catch (DuplicateKeyException e) { throw new DataException("error.duplicate.role"); } createRoleRights(role); } }
RoleRightsRepository { public void createRole(Role role) { try { roleRightsMapper.insertRole(role); } catch (DuplicateKeyException e) { throw new DataException("error.duplicate.role"); } createRoleRights(role); } @Autowired  RoleRightsRepository(RoleRightsMapper roleRightsMapper, CommaSeparator commaSeparator); }
RoleRightsRepository { public void createRole(Role role) { try { roleRightsMapper.insertRole(role); } catch (DuplicateKeyException e) { throw new DataException("error.duplicate.role"); } createRoleRights(role); } @Autowired  RoleRightsRepository(RoleRightsMapper roleRightsMapper, CommaSeparator commaSeparator); void createRole(Role role); void updateRole(Role role); List<Role> getAllRoles(); Role getRole(Long roleId); List<Right> getAllRightsForUser(Long userId); List<Right> getRightsForUserOnSupervisoryNodeAndProgram(Long userId, List<SupervisoryNode> supervisoryNodes, Program program); List<Right> getRightsForUserOnHomeFacilityAndProgram(Long userId, Program program); RightType getRightTypeForRoleId(Long roleId); List<Right> getRightsForUserAndWarehouse(Long userId, Long warehouseId); }
RoleRightsRepository { public void createRole(Role role) { try { roleRightsMapper.insertRole(role); } catch (DuplicateKeyException e) { throw new DataException("error.duplicate.role"); } createRoleRights(role); } @Autowired  RoleRightsRepository(RoleRightsMapper roleRightsMapper, CommaSeparator commaSeparator); void createRole(Role role); void updateRole(Role role); List<Role> getAllRoles(); Role getRole(Long roleId); List<Right> getAllRightsForUser(Long userId); List<Right> getRightsForUserOnSupervisoryNodeAndProgram(Long userId, List<SupervisoryNode> supervisoryNodes, Program program); List<Right> getRightsForUserOnHomeFacilityAndProgram(Long userId, Program program); RightType getRightTypeForRoleId(Long roleId); List<Right> getRightsForUserAndWarehouse(Long userId, Long warehouseId);  }