@Test
public void buildHierarchyNodesReturnsExpectedNodes() {

    // given
    var firstRootUserId = "first-root-user";
    var secondRootUserId = "second-root-user";
    var firstRootChildUserId = "first-root-child-user";
    var secondRootChildUserId = "second-root-child-user";
    var firstRootUser = new User(firstRootUserId);
    var secondRootUser = new User(secondRootUserId);
    var firstRootChildUser = new User(firstRootChildUserId);
    var secondRootChildUser = new User(secondRootChildUserId);
    var firstRootDn = "first-root-dn";
    var secondRootDn = "second-root-dn";
    var firstRootChildDn = "first-root-child-dn";
    var secondRootChildDn = "second-root-child-dn";
    var firstRootNode = new LdapUserNode()
            .setId(firstRootUserId)
            .setDn(firstRootDn)
            .setManagerDn(firstRootDn)
            .setDirectReportsDn(List.of(firstRootChildDn));
    var firstRootChildNode = new LdapUserNode()
            .setId(firstRootChildUserId)
            .setDn(firstRootChildDn)
            .setManagerDn(firstRootDn);
    var secondRootNode = new LdapUserNode()
            .setId(secondRootUserId)
            .setDn(secondRootDn)
            .setManagerDn(secondRootDn)
            .setDirectReportsDn(List.of(secondRootChildDn));
    var secondRootChildNode = new LdapUserNode()
            .setId(secondRootChildUserId)
            .setDn(secondRootChildDn)
            .setManagerDn(secondRootDn);
    var firstRootChildHierarchyNode = new HierarchyTreeNode(firstRootChildUser);
    var expectedFirstRootHierarchyNode = new HierarchyTreeNode(firstRootUser);
    expectedFirstRootHierarchyNode.addDirectStaffMember(firstRootChildHierarchyNode);
    var secondRootChildHierarchyNode = new HierarchyTreeNode(secondRootChildUser);
    var expectedSecondRootHierarchyNode = new HierarchyTreeNode(secondRootUser);
    expectedSecondRootHierarchyNode.addDirectStaffMember(secondRootChildHierarchyNode);
    given(repoUserServiceMock.getOrCreateUserById(firstRootUserId)).willReturn(firstRootUser);
    given(repoUserServiceMock.getOrCreateUserById(firstRootChildUserId)).willReturn(firstRootChildUser);
    given(repoUserServiceMock.getOrCreateUserById(secondRootUserId)).willReturn(secondRootUser);
    given(repoUserServiceMock.getOrCreateUserById(secondRootChildUserId)).willReturn(secondRootChildUser);
    // when
    var actualRootHierarchyNodes = userUpdater.buildHierarchyTrees(List.of(firstRootNode, secondRootNode),
            List.of(firstRootNode, secondRootNode, firstRootChildNode, secondRootChildNode));
    // then
    assertThat(actualRootHierarchyNodes).containsExactly(expectedFirstRootHierarchyNode, expectedSecondRootHierarchyNode);
}