@Test
public void buildHierarchyNodeReturnsExpectedHierarchyNode() {

    // given
    var rootUserId = "root-user";
    var firstLevelUserId = "first-level-user";
    var secondLevelUserId = "second-level-user";
    var rootUser = new User(rootUserId);
    var firstLevelUser = new User(firstLevelUserId);
    var secondLevelUser = new User(secondLevelUserId);
    var rootNodeDn = "root-dn";
    var firstLevelDn = "first-level-dn";
    var secondLevelDn = "second-level-dn";
    var rootNode = new LdapUserNode()
            .setId(rootUserId)
            .setDn(rootNodeDn)
            .setManagerDn(rootNodeDn)
            .setDirectReportsDn(List.of(firstLevelDn));
    var firstLevelNode = new LdapUserNode()
            .setId(firstLevelUserId)
            .setDn(firstLevelDn)
            .setManagerDn(rootNodeDn)
            .setDirectReportsDn(List.of(secondLevelDn));
    var secondLevelNode = new LdapUserNode()
            .setId(secondLevelUserId)
            .setDn(secondLevelDn)
            .setManagerDn(firstLevelDn);
    var firstLevelHierarchy = new HierarchyTreeNode(firstLevelUser);
    var secondLevelHierarchy = new HierarchyTreeNode(secondLevelUser);
    var expectedHierarchyNode = new HierarchyTreeNode(rootUser);
    expectedHierarchyNode.addDirectStaffMember(firstLevelHierarchy);
    firstLevelHierarchy.addDirectStaffMember(secondLevelHierarchy);
    given(repoUserServiceMock.getOrCreateUserById(rootUserId)).willReturn(rootUser);
    given(repoUserServiceMock.getOrCreateUserById(firstLevelUserId)).willReturn(firstLevelUser);
    given(repoUserServiceMock.getOrCreateUserById(secondLevelUserId)).willReturn(secondLevelUser);
    // when
    var actualHierarchyNode = userUpdater.buildHierarchyNode(rootNode, List.of(firstLevelNode, secondLevelNode));
    // then
    assertThat(actualHierarchyNode).isEqualTo(expectedHierarchyNode);
}