@Test public void shouldNotSaveDuplicateRole() throws Exception { doThrow(DuplicateKeyException.class).when(roleRightsMapper).insertRole(role); expectedEx.expect(dataExceptionMatcher("error.duplicate.role")); roleRightsRepository.createRole(role); }
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);  }