@Test
public void buildHierarchyNodeThrowsExceptionWhenChildNodesNotInLevelOrder() {

    // given
    var rootUserId = "root-user";
    var firstLevelUserId = "first-level-user";
    var secondLevelUserId = "second-level-user";
    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);
    given(repoUserServiceMock.getOrCreateUserById(rootUserId)).willReturn(new User(rootUserId));
    given(repoUserServiceMock.getOrCreateUserById(secondLevelUserId)).willReturn(new User(secondLevelUserId));
    // when / then
    assertThatThrownBy(() -> userUpdater.buildHierarchyNode(rootNode, List.of(secondLevelNode, firstLevelNode)))
            .isInstanceOf(IllegalArgumentException.class)
            .hasMessage("Child nodes not in level order!");
}