### Question:
BranchGroupMap { public void setModeratingGroupForCurrentBranch(Group oldModeratorGroup, PoulpeBranch branch) { iterator = branchesCollection.iterator(); while (iterator.hasNext()) { ModeratingGroupComboboxRow controller = iterator.next(); if (controller.currentBrunchHasChanges(oldModeratorGroup, branch)) { controller.saveModeratorsGroup(); iterator.remove(); } } } BranchGroupMap(List<PoulpeBranch> branches, List<Group> groups, BranchService branchService); void setSelectedGroupForAllBranches(Group group); List<ModeratingGroupComboboxRow> getBranchesCollection(); void setModeratingGroupForAllBranches(Group oldModeratorGroup); void setModeratingGroupForCurrentBranch(Group oldModeratorGroup, PoulpeBranch branch); List<Group> getAllAvailableGroups(); void setAllAvailableGroups(List<Group> allAvailableGroups);  }### Answer:
@Test public void setModeratingGroupForCurrentBranchTest() throws NoSuchFieldException, IllegalAccessException { branchGroupMap.setSelectedGroupForAllBranches(groupToSet); PoulpeBranch firstBranch = branchesCollection.get(0).getCurrentBranch(); PoulpeBranch secondBranch = branchesCollection.get(1).getCurrentBranch(); int branchesWaitingForChangesCount = branchesCollection.size(); branchGroupMap.setModeratingGroupForCurrentBranch(wasModeratorGroup, firstBranch); assertNotNull(getIterator()); if (branchesWaitingForChangesCount == 0) { assertEquals(branchesWaitingForChangesCount, 0); } else { assertEquals(branchesCollection.size(), branchesWaitingForChangesCount - 1); } verify(firstBranch).setModeratorsGroup(groupToSet); verify(secondBranch, times(0)).setModeratorsGroup(any(Group.class)); }