@Test public void shouldNotHaveRightWhenNodeDoesNotMatch() throws Exception, RightTypeException { RightQuery rightQuery = new RightQuery(right, program, new SupervisoryNode()); boolean hasRight = supervisionRoleAssignment.hasRight(rightQuery); assertFalse(hasRight); }
@Override public boolean hasRight(RightQuery rightQuery) { boolean roleMatches = role.contains(rightQuery.getRight()); boolean programMatches = program.equals(rightQuery.getProgram()); boolean nodePresentAndMatches = supervisoryNode != null && supervisoryNode.equals(rightQuery.getSupervisoryNode()); boolean nodeAbsentAndMatches = supervisoryNode == null && rightQuery.getSupervisoryNode() == null; boolean nodeMatches = nodePresentAndMatches || nodeAbsentAndMatches; return roleMatches && programMatches && nodeMatches; }
SupervisionRoleAssignment extends RoleAssignment { @Override public boolean hasRight(RightQuery rightQuery) { boolean roleMatches = role.contains(rightQuery.getRight()); boolean programMatches = program.equals(rightQuery.getProgram()); boolean nodePresentAndMatches = supervisoryNode != null && supervisoryNode.equals(rightQuery.getSupervisoryNode()); boolean nodeAbsentAndMatches = supervisoryNode == null && rightQuery.getSupervisoryNode() == null; boolean nodeMatches = nodePresentAndMatches || nodeAbsentAndMatches; return roleMatches && programMatches && nodeMatches; } }
SupervisionRoleAssignment extends RoleAssignment { @Override public boolean hasRight(RightQuery rightQuery) { boolean roleMatches = role.contains(rightQuery.getRight()); boolean programMatches = program.equals(rightQuery.getProgram()); boolean nodePresentAndMatches = supervisoryNode != null && supervisoryNode.equals(rightQuery.getSupervisoryNode()); boolean nodeAbsentAndMatches = supervisoryNode == null && rightQuery.getSupervisoryNode() == null; boolean nodeMatches = nodePresentAndMatches || nodeAbsentAndMatches; return roleMatches && programMatches && nodeMatches; } private  SupervisionRoleAssignment(Role role);  SupervisionRoleAssignment(Role role, Program program);  SupervisionRoleAssignment(Role role, Program program, SupervisoryNode supervisoryNode); }
SupervisionRoleAssignment extends RoleAssignment { @Override public boolean hasRight(RightQuery rightQuery) { boolean roleMatches = role.contains(rightQuery.getRight()); boolean programMatches = program.equals(rightQuery.getProgram()); boolean nodePresentAndMatches = supervisoryNode != null && supervisoryNode.equals(rightQuery.getSupervisoryNode()); boolean nodeAbsentAndMatches = supervisoryNode == null && rightQuery.getSupervisoryNode() == null; boolean nodeMatches = nodePresentAndMatches || nodeAbsentAndMatches; return roleMatches && programMatches && nodeMatches; } private  SupervisionRoleAssignment(Role role);  SupervisionRoleAssignment(Role role, Program program);  SupervisionRoleAssignment(Role role, Program program, SupervisoryNode supervisoryNode); @Override boolean hasRight(RightQuery rightQuery); }
SupervisionRoleAssignment extends RoleAssignment { @Override public boolean hasRight(RightQuery rightQuery) { boolean roleMatches = role.contains(rightQuery.getRight()); boolean programMatches = program.equals(rightQuery.getProgram()); boolean nodePresentAndMatches = supervisoryNode != null && supervisoryNode.equals(rightQuery.getSupervisoryNode()); boolean nodeAbsentAndMatches = supervisoryNode == null && rightQuery.getSupervisoryNode() == null; boolean nodeMatches = nodePresentAndMatches || nodeAbsentAndMatches; return roleMatches && programMatches && nodeMatches; } private  SupervisionRoleAssignment(Role role);  SupervisionRoleAssignment(Role role, Program program);  SupervisionRoleAssignment(Role role, Program program, SupervisoryNode supervisoryNode); @Override boolean hasRight(RightQuery rightQuery);  }