### Question:
UserSyncService { @VisibleForTesting void addUsersToGroups(FreeIpaClient freeIpaClient, Multimap<String, String> groupMapping, BiConsumer<String, String> warnings) throws FreeIpaClientException { LOGGER.debug("adding users to groups: [{}]", groupMapping); for (String group : groupMapping.keySet()) { for (List<String> users : Iterables.partition(groupMapping.get(group), maxSubjectsPerRequest)) { LOGGER.debug("adding users [{}] to group [{}]", users, group); try { RPCResponse<Group> groupAddMemberResponse = freeIpaClient.groupAddMembers(group, users); List<String> members = Optional.ofNullable(groupAddMemberResponse.getResult().getMemberUser()).orElse(List.of()); if (members.containsAll(users)) { LOGGER.debug("Successfully added users {} to {}", users, groupAddMemberResponse.getResult()); } else { LOGGER.error("Failed to add {} to group '{}': {}", users, group, groupAddMemberResponse.getFailed()); warnings.accept(group, String.format("Failed to add users to group: %s", groupAddMemberResponse.getFailed())); } } catch (FreeIpaClientException e) { LOGGER.error("Failed to add {} to group '{}'", users, group, e); warnings.accept(group, String.format("Failed to add users %s to group: %s", users, e.getMessage())); checkIfClientStillUsable(e); } } } }  Operation synchronizeUsers(String accountId, String actorCrn, Set<String> environmentCrnFilter,
            Set<String> userCrnFilter, Set<String> machineUserCrnFilter); Operation synchronizeUsersWithCustomPermissionCheck(String accountId, String actorCrn, Set<String> environmentCrnFilter,
            UserSyncRequestFilter userSyncFilter, AuthorizationResourceAction action);  }### Answer:
@Test void testAddUsersToGroupsPartitionsRequests() throws Exception { Multimap<String, String> groupMapping = setupGroupMapping(5, underTest.maxSubjectsPerRequest * 2); FreeIpaClient freeIpaClient = mock(FreeIpaClient.class); Group addResponseGroup = mock(Group.class, RETURNS_DEEP_STUBS); RPCResponse<Group> mockAddResponse = mock(RPCResponse.class); when(mockAddResponse.getResult()).thenReturn(addResponseGroup); when(addResponseGroup.getMemberUser().containsAll(anyCollection())).thenReturn(true); when(freeIpaClient.groupAddMembers(anyString(), anyCollection())).thenReturn(mockAddResponse); Multimap<String, String> warnings = ArrayListMultimap.create(); underTest.addUsersToGroups(freeIpaClient, groupMapping, warnings::put); groupMapping.keySet().stream().forEach(group -> { try { verify(freeIpaClient, times(2)).groupAddMembers(eq(group), any()); } catch (FreeIpaClientException e) { throw new RuntimeException(e); } }); }