test_class.declarator: hierarchyTreeNodeRepoMock
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private HierarchyTreeNodeRepository hierarchyTreeNodeRepoMock;
test_class.type: HierarchyTreeNodeRepository
test_class.var_name: hierarchyTreeNodeRepoMock
test_class.declarator: ldapAdapterMock
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private LdapAdapter ldapAdapterMock;
test_class.type: LdapAdapter
test_class.var_name: ldapAdapterMock
test_class.declarator: repoUserServiceMock
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private RepositoryUserService repoUserServiceMock;
test_class.type: RepositoryUserService
test_class.var_name: repoUserServiceMock
test_class.declarator: userDataRepoMock
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private UserDataRepository userDataRepoMock;
test_class.type: UserDataRepository
test_class.var_name: userDataRepoMock
test_class.declarator: normalizerMock
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private Normalizer<UserData> normalizerMock;
test_class.type: Normalizer<UserData>
test_class.var_name: normalizerMock
test_class.declarator: userDataCaptor
test_class.modifier: @Captor
      private
test_class.original_string: @Captor
      private ArgumentCaptor<Collection<UserData>> userDataCaptor;
test_class.type: ArgumentCaptor<Collection<UserData>>
test_class.var_name: userDataCaptor
test_class.declarator: userUpdater
test_class.modifier: private
test_class.original_string: private UserUpdater userUpdater;
test_class.type: UserUpdater
test_class.var_name: userUpdater
test_class.file: backend/project-board/src/test/java/de/adesso/projectboard/ad/updater/UserUpdaterTest.java
test_class.identifier: UserUpdaterTest
test_case.body: @Test
      public void updateUserDataDeletesAllAndSavesNew() {
          // given
          var firstUserId = "first-user";
          var expectedFirstDepartment = "first-department";
          var expectedFirstDivision = "first-division";
          var expectedFirstGivenName = "first-given-name";
          var expectedFirstSurname = "first-surname";
          var expectedFirstName = "first-full-name";
          var expectedFirstMail = "first@mail.com";
  
          var secondUserId = "second-user";
          var expectedSecondDepartment = "second-department";
          var expectedSecondDivision = "second-division";
          var expectedSecondGivenName = "second-given-name";
          var expectedSecondSurname = "second-surname";
          var expectedSecondName = "second-full-name";
          var expectedSecondMail = "second@mail.com";
  
          var firstUser = new User(firstUserId);
          var secondUser = new User(secondUserId);
  
          var firstNode = new LdapUserNode()
                  .setId(firstUserId)
                  .setDepartment(expectedFirstDepartment)
                  .setDivision(expectedFirstDivision)
                  .setGivenName(expectedFirstGivenName)
                  .setSurname(expectedFirstSurname)
                  .setName(expectedFirstName)
                  .setMail(expectedFirstMail);
          var secondNode = new LdapUserNode()
                  .setId(secondUserId)
                  .setDepartment(expectedSecondDepartment)
                  .setDivision(expectedSecondDivision)
                  .setGivenName(expectedSecondGivenName)
                  .setSurname(expectedSecondSurname)
                  .setName(expectedSecondName)
                  .setMail(expectedSecondMail);
  
          var firstExpected = new UserData(firstUser, expectedFirstGivenName, expectedFirstSurname, expectedFirstMail, expectedFirstDivision);
          var secondExpected = new UserData(secondUser, expectedSecondGivenName, expectedSecondSurname, expectedSecondMail, expectedSecondDivision);
  
          given(repoUserServiceMock.getOrCreateUserById(firstUserId)).willReturn(firstUser);
          given(repoUserServiceMock.getOrCreateUserById(secondUserId)).willReturn(secondUser);
  
          given(normalizerMock.normalize(List.of(firstExpected, secondExpected))).willReturn(List.of(firstExpected, secondExpected));
  
          // when
          userUpdater.updateUserData(List.of(firstNode, secondNode));
  
          // then
          verify(userDataRepoMock).deleteAll();
          verify(userDataRepoMock).flush();
          verify(userDataRepoMock).saveAll(userDataCaptor.capture());
          verify(normalizerMock).normalize(List.of(firstExpected, secondExpected));
  
          assertThat(userDataCaptor.getValue()).containsExactlyInAnyOrder(firstExpected, secondExpected);
      }
test_case.class_method_signature: UserUpdaterTest.updateUserDataDeletesAllAndSavesNew()
test_case.full_signature: @Test public void updateUserDataDeletesAllAndSavesNew()
test_case.identifier: updateUserDataDeletesAllAndSavesNew
test_case.invocations: setMail setName setSurname setGivenName setDivision setDepartment setId setMail setName setSurname setGivenName setDivision setDepartment setId willReturn given getOrCreateUserById willReturn given getOrCreateUserById willReturn given normalize of of updateUserData of deleteAll verify flush verify saveAll verify capture normalize verify of containsExactlyInAnyOrder assertThat getValue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void updateUserDataDeletesAllAndSavesNew()
focal_class.declarator: hierarchyTreeNodeRepo
focal_class.modifier: private final
focal_class.original_string: private final HierarchyTreeNodeRepository hierarchyTreeNodeRepo;
focal_class.type: HierarchyTreeNodeRepository
focal_class.var_name: hierarchyTreeNodeRepo
focal_class.declarator: repoUserService
focal_class.modifier: private final
focal_class.original_string: private final RepositoryUserService repoUserService;
focal_class.type: RepositoryUserService
focal_class.var_name: repoUserService
focal_class.declarator: userDataRepo
focal_class.modifier: private final
focal_class.original_string: private final UserDataRepository userDataRepo;
focal_class.type: UserDataRepository
focal_class.var_name: userDataRepo
focal_class.declarator: ldapAdapter
focal_class.modifier: private final
focal_class.original_string: private final LdapAdapter ldapAdapter;
focal_class.type: LdapAdapter
focal_class.var_name: ldapAdapter
focal_class.declarator: normalizers
focal_class.modifier: private final
focal_class.original_string: private final List<Normalizer<UserData>> normalizers;
focal_class.type: List<Normalizer<UserData>>
focal_class.var_name: normalizers
focal_class.file: backend/project-board/src/main/java/de/adesso/projectboard/ad/updater/UserUpdater.java
focal_class.identifier: UserUpdater
focal_class.class_method_signature: UserUpdater.UserUpdater(HierarchyTreeNodeRepository hierarchyTreeNodeRepo,
                         RepositoryUserService repoUserService,
                         UserDataRepository userDataRepo,
                         LdapAdapter ldapAdapter,
                         List<Normalizer<UserData>> normalizers)
focal_class.full_signature: public  UserUpdater(HierarchyTreeNodeRepository hierarchyTreeNodeRepo,
                         RepositoryUserService repoUserService,
                         UserDataRepository userDataRepo,
                         LdapAdapter ldapAdapter,
                         List<Normalizer<UserData>> normalizers)
focal_class.identifier: UserUpdater
focal_class.modifiers: public
focal_class.parameters: (HierarchyTreeNodeRepository hierarchyTreeNodeRepo,
                         RepositoryUserService repoUserService,
                         UserDataRepository userDataRepo,
                         LdapAdapter ldapAdapter,
                         List<Normalizer<UserData>> normalizers)
focal_class.signature:  UserUpdater(HierarchyTreeNodeRepository hierarchyTreeNodeRepo,
                         RepositoryUserService repoUserService,
                         UserDataRepository userDataRepo,
                         LdapAdapter ldapAdapter,
                         List<Normalizer<UserData>> normalizers)
focal_class.class_method_signature: UserUpdater.updateHierarchyAndUserData()
focal_class.full_signature: public void updateHierarchyAndUserData()
focal_class.identifier: updateHierarchyAndUserData
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void updateHierarchyAndUserData()
focal_class.class_method_signature: UserUpdater.updateHierarchy(@NonNull Collection<LdapUserNode> nodes)
focal_class.full_signature:  void updateHierarchy(@NonNull Collection<LdapUserNode> nodes)
focal_class.identifier: updateHierarchy
focal_class.parameters: (@NonNull Collection<LdapUserNode> nodes)
focal_class.return: void
focal_class.signature: void updateHierarchy(@NonNull Collection<LdapUserNode> nodes)
focal_class.class_method_signature: UserUpdater.updateUserData(@NonNull Collection<LdapUserNode> nodes)
focal_class.full_signature:  void updateUserData(@NonNull Collection<LdapUserNode> nodes)
focal_class.identifier: updateUserData
focal_class.parameters: (@NonNull Collection<LdapUserNode> nodes)
focal_class.return: void
focal_class.signature: void updateUserData(@NonNull Collection<LdapUserNode> nodes)
focal_class.class_method_signature: UserUpdater.normalizeAndSaveUserData(List<UserData> userData)
focal_class.full_signature:  void normalizeAndSaveUserData(List<UserData> userData)
focal_class.identifier: normalizeAndSaveUserData
focal_class.parameters: (List<UserData> userData)
focal_class.return: void
focal_class.signature: void normalizeAndSaveUserData(List<UserData> userData)
focal_class.class_method_signature: UserUpdater.getRootNodes(@NonNull Collection<LdapUserNode> nodes)
focal_class.full_signature:  Set<LdapUserNode> getRootNodes(@NonNull Collection<LdapUserNode> nodes)
focal_class.identifier: getRootNodes
focal_class.parameters: (@NonNull Collection<LdapUserNode> nodes)
focal_class.return: Set<LdapUserNode>
focal_class.signature: Set<LdapUserNode> getRootNodes(@NonNull Collection<LdapUserNode> nodes)
focal_class.class_method_signature: UserUpdater.buildHierarchyTrees(@NonNull Collection<LdapUserNode> rootNodes, @NonNull Collection<LdapUserNode> allNodes)
focal_class.full_signature:  Collection<HierarchyTreeNode> buildHierarchyTrees(@NonNull Collection<LdapUserNode> rootNodes, @NonNull Collection<LdapUserNode> allNodes)
focal_class.identifier: buildHierarchyTrees
focal_class.parameters: (@NonNull Collection<LdapUserNode> rootNodes, @NonNull Collection<LdapUserNode> allNodes)
focal_class.return: Collection<HierarchyTreeNode>
focal_class.signature: Collection<HierarchyTreeNode> buildHierarchyTrees(@NonNull Collection<LdapUserNode> rootNodes, @NonNull Collection<LdapUserNode> allNodes)
focal_class.class_method_signature: UserUpdater.buildHierarchyNode(@NonNull LdapUserNode rootNode, @NonNull List<LdapUserNode> childNodes)
focal_class.full_signature:  HierarchyTreeNode buildHierarchyNode(@NonNull LdapUserNode rootNode, @NonNull List<LdapUserNode> childNodes)
focal_class.identifier: buildHierarchyNode
focal_class.parameters: (@NonNull LdapUserNode rootNode, @NonNull List<LdapUserNode> childNodes)
focal_class.return: HierarchyTreeNode
focal_class.signature: HierarchyTreeNode buildHierarchyNode(@NonNull LdapUserNode rootNode, @NonNull List<LdapUserNode> childNodes)
focal_class.class_method_signature: UserUpdater.getChildNodesInLevelOrder(@NonNull LdapUserNode node, @NonNull Map<String, LdapUserNode> dnNodeMap)
focal_class.full_signature:  List<LdapUserNode> getChildNodesInLevelOrder(@NonNull LdapUserNode node, @NonNull Map<String, LdapUserNode> dnNodeMap)
focal_class.identifier: getChildNodesInLevelOrder
focal_class.parameters: (@NonNull LdapUserNode node, @NonNull Map<String, LdapUserNode> dnNodeMap)
focal_class.return: List<LdapUserNode>
focal_class.signature: List<LdapUserNode> getChildNodesInLevelOrder(@NonNull LdapUserNode node, @NonNull Map<String, LdapUserNode> dnNodeMap)
focal_class.class_method_signature: UserUpdater.filterNodesWithMissingManager(@NonNull Collection<LdapUserNode> nodes)
focal_class.full_signature:  Set<LdapUserNode> filterNodesWithMissingManager(@NonNull Collection<LdapUserNode> nodes)
focal_class.identifier: filterNodesWithMissingManager
focal_class.parameters: (@NonNull Collection<LdapUserNode> nodes)
focal_class.return: Set<LdapUserNode>
focal_class.signature: Set<LdapUserNode> filterNodesWithMissingManager(@NonNull Collection<LdapUserNode> nodes)
focal_class.class_method_signature: UserUpdater.cleanDirectReports(@NonNull Collection<LdapUserNode> nodes)
focal_class.full_signature:  Set<LdapUserNode> cleanDirectReports(@NonNull Collection<LdapUserNode> nodes)
focal_class.identifier: cleanDirectReports
focal_class.parameters: (@NonNull Collection<LdapUserNode> nodes)
focal_class.return: Set<LdapUserNode>
focal_class.signature: Set<LdapUserNode> cleanDirectReports(@NonNull Collection<LdapUserNode> nodes)
focal_method.body: void updateUserData(@NonNull Collection<LdapUserNode> nodes) {
          var userData = nodes.stream()
                  .map(node -> {
                      var user = repoUserService.getOrCreateUserById(node.getId());
  
                      return new UserData(user, node.getGivenName(), node.getSurname(), node.getMail(), node.getDivision());
                  })
                  .distinct()
                  .collect(Collectors.toList());
  
          normalizeAndSaveUserData(userData);
      }
focal_method.class_method_signature: UserUpdater.updateUserData(@NonNull Collection<LdapUserNode> nodes)
focal_method.full_signature:  void updateUserData(@NonNull Collection<LdapUserNode> nodes)
focal_method.identifier: updateUserData
focal_method.invocations: collect distinct map stream getOrCreateUserById getId getGivenName getSurname getMail getDivision toList normalizeAndSaveUserData
focal_method.parameters: (@NonNull Collection<LdapUserNode> nodes)
focal_method.return: void
focal_method.signature: void updateUserData(@NonNull Collection<LdapUserNode> nodes)