HierarchyTreeNode implements Iterable<HierarchyTreeNode>, Streamable<HierarchyTreeNode>, Serializable { public boolean isLeaf() { return staff.isEmpty() && directStaff.isEmpty(); } 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 isLeafReturnsTrueWhenDirectStaffAndStaffAreEmpty() { var node = new HierarchyTreeNode(userMock); assertThat(node.isLeaf()).isTrue(); }
@Test public void isLeafReturnsFalseWhenDirectStaffIsNotEmpty() { var node = new HierarchyTreeNode(userMock); var directStaffNode = new HierarchyTreeNode(otherUserMock); node.directStaff = Collections.singletonList(directStaffNode); assertThat(node.isLeaf()).isFalse(); }
@Test public void isLeafReturnsFalseWhenStaffIsNotEmpty() { var node = new HierarchyTreeNode(userMock); var staffNode = new HierarchyTreeNode(otherUserMock); node.staff = Collections.singletonList(staffNode); assertThat(node.isLeaf()).isFalse(); }
@Test public void isLeafReturnsFalseWhenDirectStaffAndStaffNotEmpty() { var node = new HierarchyTreeNode(userMock); var directStaffNode = new HierarchyTreeNode(otherUserMock); var staffNode = new HierarchyTreeNode(otherUserMock); node.directStaff = Collections.singletonList(directStaffNode); node.staff = Collections.singletonList(staffNode); assertThat(node.isLeaf()).isFalse(); }