@Test void testCalculateUsersToAdd() { FmsUser userUms = new FmsUser().withName("userUms"); FmsUser userProtected = new FmsUser().withName(FreeIpaChecks.IPA_PROTECTED_USERS.get(0)); FmsUser userBoth = new FmsUser().withName("userBoth"); FmsUser userIPA = new FmsUser().withName("userIPA"); UmsUsersState umsUsersState = new UmsUsersState.Builder() .setUsersState(new UsersState.Builder() .addUser(userUms) .addUser(userProtected) .addUser(userBoth) .build()) .build(); UsersState ipaUsersState = new UsersState.Builder() .addUser(userBoth) .addUser(userIPA) .build(); ImmutableSet<FmsUser> usersToAdd = UsersStateDifference.calculateUsersToAdd(umsUsersState, ipaUsersState); assertTrue(usersToAdd.contains(userUms)); assertFalse(usersToAdd.contains(userProtected)); assertFalse(usersToAdd.contains(userBoth)); assertFalse(usersToAdd.contains(userIPA)); }
public static ImmutableSet<FmsUser> calculateUsersToAdd(UmsUsersState umsState, UsersState ipaState) { ImmutableSet<FmsUser> usersToAdd = ImmutableSet.copyOf(Sets.difference(umsState.getUsersState().getUsers(), ipaState.getUsers()) .stream() .filter(fmsUser -> !FreeIpaChecks.IPA_PROTECTED_USERS.contains(fmsUser.getName())) .collect(Collectors.toSet())); LOGGER.info("usersToAdd size = {}", usersToAdd.size()); LOGGER.debug("userToAdd = {}", usersToAdd.stream().map(FmsUser::getName).collect(Collectors.toSet())); return usersToAdd; }
UsersStateDifference { public static ImmutableSet<FmsUser> calculateUsersToAdd(UmsUsersState umsState, UsersState ipaState) { ImmutableSet<FmsUser> usersToAdd = ImmutableSet.copyOf(Sets.difference(umsState.getUsersState().getUsers(), ipaState.getUsers()) .stream() .filter(fmsUser -> !FreeIpaChecks.IPA_PROTECTED_USERS.contains(fmsUser.getName())) .collect(Collectors.toSet())); LOGGER.info("usersToAdd size = {}", usersToAdd.size()); LOGGER.debug("userToAdd = {}", usersToAdd.stream().map(FmsUser::getName).collect(Collectors.toSet())); return usersToAdd; } }
UsersStateDifference { public static ImmutableSet<FmsUser> calculateUsersToAdd(UmsUsersState umsState, UsersState ipaState) { ImmutableSet<FmsUser> usersToAdd = ImmutableSet.copyOf(Sets.difference(umsState.getUsersState().getUsers(), ipaState.getUsers()) .stream() .filter(fmsUser -> !FreeIpaChecks.IPA_PROTECTED_USERS.contains(fmsUser.getName())) .collect(Collectors.toSet())); LOGGER.info("usersToAdd size = {}", usersToAdd.size()); LOGGER.debug("userToAdd = {}", usersToAdd.stream().map(FmsUser::getName).collect(Collectors.toSet())); return usersToAdd; } 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<FmsUser> calculateUsersToAdd(UmsUsersState umsState, UsersState ipaState) { ImmutableSet<FmsUser> usersToAdd = ImmutableSet.copyOf(Sets.difference(umsState.getUsersState().getUsers(), ipaState.getUsers()) .stream() .filter(fmsUser -> !FreeIpaChecks.IPA_PROTECTED_USERS.contains(fmsUser.getName())) .collect(Collectors.toSet())); LOGGER.info("usersToAdd size = {}", usersToAdd.size()); LOGGER.debug("userToAdd = {}", usersToAdd.stream().map(FmsUser::getName).collect(Collectors.toSet())); return usersToAdd; } 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<FmsUser> calculateUsersToAdd(UmsUsersState umsState, UsersState ipaState) { ImmutableSet<FmsUser> usersToAdd = ImmutableSet.copyOf(Sets.difference(umsState.getUsersState().getUsers(), ipaState.getUsers()) .stream() .filter(fmsUser -> !FreeIpaChecks.IPA_PROTECTED_USERS.contains(fmsUser.getName())) .collect(Collectors.toSet())); LOGGER.info("usersToAdd size = {}", usersToAdd.size()); LOGGER.debug("userToAdd = {}", usersToAdd.stream().map(FmsUser::getName).collect(Collectors.toSet())); return usersToAdd; } 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);  }