@Test public void managersEqualReturnsFalseWhenDifferentManagerId() { var managerNodeId = 1L; var otherManagerNodeId = 2L; var managerNode = new HierarchyTreeNode(otherUserMock); var otherManagerNode = new HierarchyTreeNode(); managerNode.id = managerNodeId; otherManagerNode.id = otherManagerNodeId; var node = new HierarchyTreeNode(userMock); node.manager = managerNode; var otherNode = new HierarchyTreeNode(userMock); otherManagerNode.manager = otherManagerNode; assertThat(node.managersEqual(otherNode)).isFalse(); }
boolean managersEqual(HierarchyTreeNode other) { var otherManager = Objects.requireNonNull(other).manager; if(manager == otherManager) { return true; } else if(Objects.isNull(manager) || Objects.isNull(otherManager)) { return false; } return Objects.equals(manager.id, otherManager.id); }
HierarchyTreeNode implements Iterable<HierarchyTreeNode>, Streamable<HierarchyTreeNode>, Serializable { boolean managersEqual(HierarchyTreeNode other) { var otherManager = Objects.requireNonNull(other).manager; if(manager == otherManager) { return true; } else if(Objects.isNull(manager) || Objects.isNull(otherManager)) { return false; } return Objects.equals(manager.id, otherManager.id); } }
HierarchyTreeNode implements Iterable<HierarchyTreeNode>, Streamable<HierarchyTreeNode>, Serializable { boolean managersEqual(HierarchyTreeNode other) { var otherManager = Objects.requireNonNull(other).manager; if(manager == otherManager) { return true; } else if(Objects.isNull(manager) || Objects.isNull(otherManager)) { return false; } return Objects.equals(manager.id, otherManager.id); } HierarchyTreeNode(User user); }
HierarchyTreeNode implements Iterable<HierarchyTreeNode>, Streamable<HierarchyTreeNode>, Serializable { boolean managersEqual(HierarchyTreeNode other) { var otherManager = Objects.requireNonNull(other).manager; if(manager == otherManager) { return true; } else if(Objects.isNull(manager) || Objects.isNull(otherManager)) { return false; } return Objects.equals(manager.id, otherManager.id); } HierarchyTreeNode(User user); boolean isLeaf(); boolean isRoot(); HierarchyTreeNode getRoot(); void addDirectStaffMember(HierarchyTreeNode staffNode); void removeDirectStaffMember(HierarchyTreeNode staffNode); @Override Iterator<HierarchyTreeNode> iterator(); @Override boolean equals(Object obj); @Override int hashCode(); }
HierarchyTreeNode implements Iterable<HierarchyTreeNode>, Streamable<HierarchyTreeNode>, Serializable { boolean managersEqual(HierarchyTreeNode other) { var otherManager = Objects.requireNonNull(other).manager; if(manager == otherManager) { return true; } else if(Objects.isNull(manager) || Objects.isNull(otherManager)) { return false; } return Objects.equals(manager.id, otherManager.id); } HierarchyTreeNode(User user); boolean isLeaf(); boolean isRoot(); HierarchyTreeNode getRoot(); void addDirectStaffMember(HierarchyTreeNode staffNode); void removeDirectStaffMember(HierarchyTreeNode staffNode); @Override Iterator<HierarchyTreeNode> iterator(); @Override boolean equals(Object obj); @Override int hashCode();  }