class UserSyncService {

    @VisibleForTesting
    void applyStateDifferenceToIpa(String environmentCrn, FreeIpaClient freeIpaClient, UsersStateDifference stateDifference,
                    BiConsumer<String, String> warnings) throws FreeIpaClientException {
        LOGGER.info("Applying state difference to environment {}.", environmentCrn);

        LOGGER.debug("Starting {} ...", LogEvent.ADD_GROUPS);
        addGroups(freeIpaClient, stateDifference.getGroupsToAdd(), warnings);
        LOGGER.debug("Finished {}.", LogEvent.ADD_GROUPS);

        LOGGER.debug("Starting {} ...", LogEvent.ADD_USERS);
        addUsers(freeIpaClient, stateDifference.getUsersToAdd(), warnings);
        LOGGER.debug("Finished {}.", LogEvent.ADD_USERS);

        LOGGER.debug("Starting {} ...", LogEvent.ADD_USERS_TO_GROUPS);
        addUsersToGroups(freeIpaClient, stateDifference.getGroupMembershipToAdd(), warnings);
        LOGGER.debug("Finished {}.", LogEvent.ADD_USERS_TO_GROUPS);

        LOGGER.debug("Starting {} ...", LogEvent.REMOVE_USERS_FROM_GROUPS);
        removeUsersFromGroups(freeIpaClient, stateDifference.getGroupMembershipToRemove(), warnings);
        LOGGER.debug("Finished {}.", LogEvent.REMOVE_USERS_FROM_GROUPS);

        LOGGER.debug("Starting {} ...", LogEvent.REMOVE_USERS);
        removeUsers(freeIpaClient, stateDifference.getUsersToRemove(), warnings);
        LOGGER.debug("Finished {}.", LogEvent.REMOVE_USERS);

        LOGGER.debug("Starting {} ...", LogEvent.REMOVE_GROUPS);
        removeGroups(freeIpaClient, stateDifference.getGroupsToRemove(), warnings);
        LOGGER.debug("Finished {}.", LogEvent.REMOVE_GROUPS);
    }

}