HierarchyTreeNode implements Iterable<HierarchyTreeNode>, Streamable<HierarchyTreeNode>, Serializable { public HierarchyTreeNode getRoot() { if(isRoot()) { return this; } return manager.getRoot(); } 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();  }
@Test public void getRootReturnsNodeWhenManagerIsNull() { var node = new HierarchyTreeNode(userMock); assertThat(node.getRoot()).isSameAs(node); }
@Test public void getRootReturnsManagerWhenNodeIsNoRoot() { var managerNode = new HierarchyTreeNode(otherUserMock); var node = new HierarchyTreeNode(userMock); node.manager = managerNode; assertThat(node.getRoot()).isSameAs(managerNode); }