@Test void testCalculateUsersToRemove() { FmsUser userUms = new FmsUser().withName("userUms"); FmsUser userBoth = new FmsUser().withName("userBoth"); FmsUser userIPA = new FmsUser().withName("userIPA"); FmsUser userIPA2 = new FmsUser().withName("userIPA2"); FmsUser userProtected = new FmsUser().withName(FreeIpaChecks.IPA_PROTECTED_USERS.get(0)); UmsUsersState umsUsersState = new UmsUsersState.Builder() .setUsersState(new UsersState.Builder() .addUser(userUms) .addMemberToGroup(UserSyncConstants.CDP_USERSYNC_INTERNAL_GROUP, userUms.getName()) .addUser(userBoth) .addMemberToGroup(UserSyncConstants.CDP_USERSYNC_INTERNAL_GROUP, userBoth.getName()) .build()) .build(); UsersState ipaUsersState = new UsersState.Builder() .addUser(userBoth) .addMemberToGroup(UserSyncConstants.CDP_USERSYNC_INTERNAL_GROUP, userBoth.getName()) .addUser(userIPA) .addMemberToGroup(UserSyncConstants.CDP_USERSYNC_INTERNAL_GROUP, userIPA.getName()) .addUser(userIPA2) .addUser(userProtected) .addMemberToGroup(UserSyncConstants.CDP_USERSYNC_INTERNAL_GROUP, userProtected.getName()) .build(); ImmutableSet<String> usersToRemove = UsersStateDifference.calculateUsersToRemove(umsUsersState, ipaUsersState); assertTrue(usersToRemove.contains(userIPA.getName())); assertFalse(usersToRemove.contains(userProtected.getName())); assertFalse(usersToRemove.contains(userUms.getName())); assertFalse(usersToRemove.contains(userBoth.getName())); assertFalse(usersToRemove.contains(userIPA2.getName())); }
public static ImmutableSet<String> calculateUsersToRemove(UmsUsersState umsState, UsersState ipaState) { Collection<String> umsStateUsers = umsState.getUsersState().getGroupMembership().get(UserSyncConstants.CDP_USERSYNC_INTERNAL_GROUP); Collection<String> ipaStateUsers = ipaState.getGroupMembership().get(UserSyncConstants.CDP_USERSYNC_INTERNAL_GROUP); ImmutableSet<String> usersToRemove = ImmutableSet.copyOf(ipaStateUsers.stream() .filter(ipaUser -> !umsStateUsers.contains(ipaUser)) .filter(ipaUser -> !FreeIpaChecks.IPA_PROTECTED_USERS.contains(ipaUser)) .collect(Collectors.toSet())); LOGGER.info("usersToRemove size = {}", usersToRemove.size()); LOGGER.debug("usersToRemove = {}", usersToRemove); return usersToRemove; }
UsersStateDifference { public static ImmutableSet<String> calculateUsersToRemove(UmsUsersState umsState, UsersState ipaState) { Collection<String> umsStateUsers = umsState.getUsersState().getGroupMembership().get(UserSyncConstants.CDP_USERSYNC_INTERNAL_GROUP); Collection<String> ipaStateUsers = ipaState.getGroupMembership().get(UserSyncConstants.CDP_USERSYNC_INTERNAL_GROUP); ImmutableSet<String> usersToRemove = ImmutableSet.copyOf(ipaStateUsers.stream() .filter(ipaUser -> !umsStateUsers.contains(ipaUser)) .filter(ipaUser -> !FreeIpaChecks.IPA_PROTECTED_USERS.contains(ipaUser)) .collect(Collectors.toSet())); LOGGER.info("usersToRemove size = {}", usersToRemove.size()); LOGGER.debug("usersToRemove = {}", usersToRemove); return usersToRemove; } }
UsersStateDifference { public static ImmutableSet<String> calculateUsersToRemove(UmsUsersState umsState, UsersState ipaState) { Collection<String> umsStateUsers = umsState.getUsersState().getGroupMembership().get(UserSyncConstants.CDP_USERSYNC_INTERNAL_GROUP); Collection<String> ipaStateUsers = ipaState.getGroupMembership().get(UserSyncConstants.CDP_USERSYNC_INTERNAL_GROUP); ImmutableSet<String> usersToRemove = ImmutableSet.copyOf(ipaStateUsers.stream() .filter(ipaUser -> !umsStateUsers.contains(ipaUser)) .filter(ipaUser -> !FreeIpaChecks.IPA_PROTECTED_USERS.contains(ipaUser)) .collect(Collectors.toSet())); LOGGER.info("usersToRemove size = {}", usersToRemove.size()); LOGGER.debug("usersToRemove = {}", usersToRemove); return usersToRemove; } UsersStateDifference(ImmutableSet<FmsGroup> groupsToAdd, ImmutableSet<FmsGroup> groupsToRemove,
            ImmutableSet<FmsUser> usersToAdd, ImmutableSet<String> usersToRemove,
            ImmutableMultimap<String, String> groupMembershipToAdd, ImmutableMultimap<String, String> groupMembershipToRemove); }
UsersStateDifference { public static ImmutableSet<String> calculateUsersToRemove(UmsUsersState umsState, UsersState ipaState) { Collection<String> umsStateUsers = umsState.getUsersState().getGroupMembership().get(UserSyncConstants.CDP_USERSYNC_INTERNAL_GROUP); Collection<String> ipaStateUsers = ipaState.getGroupMembership().get(UserSyncConstants.CDP_USERSYNC_INTERNAL_GROUP); ImmutableSet<String> usersToRemove = ImmutableSet.copyOf(ipaStateUsers.stream() .filter(ipaUser -> !umsStateUsers.contains(ipaUser)) .filter(ipaUser -> !FreeIpaChecks.IPA_PROTECTED_USERS.contains(ipaUser)) .collect(Collectors.toSet())); LOGGER.info("usersToRemove size = {}", usersToRemove.size()); LOGGER.debug("usersToRemove = {}", usersToRemove); return usersToRemove; } UsersStateDifference(ImmutableSet<FmsGroup> groupsToAdd, ImmutableSet<FmsGroup> groupsToRemove,
            ImmutableSet<FmsUser> usersToAdd, ImmutableSet<String> usersToRemove,
            ImmutableMultimap<String, String> groupMembershipToAdd, ImmutableMultimap<String, String> groupMembershipToRemove); ImmutableSet<FmsGroup> getGroupsToAdd(); ImmutableSet<FmsGroup> getGroupsToRemove(); ImmutableSet<FmsUser> getUsersToAdd(); ImmutableSet<String> getUsersToRemove(); ImmutableMultimap<String, String> getGroupMembershipToAdd(); ImmutableMultimap<String, String> getGroupMembershipToRemove(); @Override String toString(); static UsersStateDifference fromUmsAndIpaUsersStates(UmsUsersState umsState, UsersState ipaState); static UsersStateDifference forDeletedUser(String deletedUser, Collection<String> groupsToRemove); static ImmutableSet<FmsUser> calculateUsersToAdd(UmsUsersState umsState, UsersState ipaState); static ImmutableSet<String> calculateUsersToRemove(UmsUsersState umsState, UsersState ipaState); static ImmutableSet<FmsGroup> calculateGroupsToAdd(UmsUsersState umsState, UsersState ipaState); static ImmutableSet<FmsGroup> calculateGroupsToRemove(UmsUsersState umsState, UsersState ipaState); static ImmutableMultimap<String, String> calculateGroupMembershipToAdd(UmsUsersState umsState, UsersState ipaState); static ImmutableMultimap<String, String> calculateGroupMembershipToRemove(UmsUsersState umsState, UsersState ipaState); }
UsersStateDifference { public static ImmutableSet<String> calculateUsersToRemove(UmsUsersState umsState, UsersState ipaState) { Collection<String> umsStateUsers = umsState.getUsersState().getGroupMembership().get(UserSyncConstants.CDP_USERSYNC_INTERNAL_GROUP); Collection<String> ipaStateUsers = ipaState.getGroupMembership().get(UserSyncConstants.CDP_USERSYNC_INTERNAL_GROUP); ImmutableSet<String> usersToRemove = ImmutableSet.copyOf(ipaStateUsers.stream() .filter(ipaUser -> !umsStateUsers.contains(ipaUser)) .filter(ipaUser -> !FreeIpaChecks.IPA_PROTECTED_USERS.contains(ipaUser)) .collect(Collectors.toSet())); LOGGER.info("usersToRemove size = {}", usersToRemove.size()); LOGGER.debug("usersToRemove = {}", usersToRemove); return usersToRemove; } UsersStateDifference(ImmutableSet<FmsGroup> groupsToAdd, ImmutableSet<FmsGroup> groupsToRemove,
            ImmutableSet<FmsUser> usersToAdd, ImmutableSet<String> usersToRemove,
            ImmutableMultimap<String, String> groupMembershipToAdd, ImmutableMultimap<String, String> groupMembershipToRemove); ImmutableSet<FmsGroup> getGroupsToAdd(); ImmutableSet<FmsGroup> getGroupsToRemove(); ImmutableSet<FmsUser> getUsersToAdd(); ImmutableSet<String> getUsersToRemove(); ImmutableMultimap<String, String> getGroupMembershipToAdd(); ImmutableMultimap<String, String> getGroupMembershipToRemove(); @Override String toString(); static UsersStateDifference fromUmsAndIpaUsersStates(UmsUsersState umsState, UsersState ipaState); static UsersStateDifference forDeletedUser(String deletedUser, Collection<String> groupsToRemove); static ImmutableSet<FmsUser> calculateUsersToAdd(UmsUsersState umsState, UsersState ipaState); static ImmutableSet<String> calculateUsersToRemove(UmsUsersState umsState, UsersState ipaState); static ImmutableSet<FmsGroup> calculateGroupsToAdd(UmsUsersState umsState, UsersState ipaState); static ImmutableSet<FmsGroup> calculateGroupsToRemove(UmsUsersState umsState, UsersState ipaState); static ImmutableMultimap<String, String> calculateGroupMembershipToAdd(UmsUsersState umsState, UsersState ipaState); static ImmutableMultimap<String, String> calculateGroupMembershipToRemove(UmsUsersState umsState, UsersState ipaState);  }