### Question:
DatabaseUserGroupProvider implements ConfigurableUserGroupProvider { @Override public Set<User> getUsers() throws AuthorizationAccessException { final String sql = "SELECT * FROM UGP_USER"; final List<DatabaseUser> databaseUsers = jdbcTemplate.query(sql, new DatabaseUserRowMapper()); final Set<User> users = new HashSet<>(); databaseUsers.forEach(u -> { users.add(mapToUser(u)); }); return users; }  @AuthorizerContext void setDataSource(final DataSource dataSource); @AuthorizerContext void setIdentityMapper(final IdentityMapper identityMapper); @Override void initialize(final UserGroupProviderInitializationContext initializationContext); @Override void onConfigured(final AuthorizerConfigurationContext configurationContext); @Override void preDestruction(); @Override String getFingerprint(); @Override void inheritFingerprint(final String fingerprint); @Override void checkInheritability(final String proposedFingerprint); @Override User addUser(final User user); @Override User updateUser(final User user); @Override Set<User> getUsers(); @Override User getUser(final String identifier); @Override User getUserByIdentity(final String identity); @Override UserAndGroups getUserAndGroups(final String userIdentity); @Override User deleteUser(final User user); @Override Group addGroup(final Group group); @Override Group updateGroup(final Group group); @Override Set<Group> getGroups(); @Override Group getGroup(final String groupIdentifier); @Override Group deleteGroup(final Group group);  }### Answer:
@Test public void testOnConfiguredCreatesInitialUsersWhenNoUsersAndGroups() { final String userIdentity1 = "user1"; final String userIdentity2 = "user2"; configureWithInitialUsers(userIdentity1, userIdentity2); final Set<User> users = userGroupProvider.getUsers(); assertEquals(2, users.size()); assertNotNull(users.stream().filter(u -> u.getIdentity().equals(userIdentity1)).findFirst().orElse(null)); assertNotNull(users.stream().filter(u -> u.getIdentity().equals(userIdentity2)).findFirst().orElse(null)); }
@Test public void testOnConfiguredStillCreatesInitialUsersWhenExistingUsersAndGroups() { final String existingUserIdentity= "existingUser"; final String existingUserIdentifier = UUID.randomUUID().toString(); createUser(existingUserIdentifier, existingUserIdentity); final String userIdentity1 = "user1"; final String userIdentity2 = "user2"; configureWithInitialUsers(userIdentity1, userIdentity2); final Set<User> users = userGroupProvider.getUsers(); assertEquals(3, users.size()); assertNotNull(users.stream().filter(u -> u.getIdentity().equals(existingUserIdentity)).findFirst().orElse(null)); assertNotNull(users.stream().filter(u -> u.getIdentity().equals(userIdentity1)).findFirst().orElse(null)); assertNotNull(users.stream().filter(u -> u.getIdentity().equals(userIdentity2)).findFirst().orElse(null)); }
@Test public void testOnConfiguredWithSameUsers() { final String existingUserIdentity= "existingUser"; final String existingUserIdentifier = UUID.randomUUID().toString(); createUser(existingUserIdentifier, existingUserIdentity); configureWithInitialUsers(existingUserIdentity); final Set<User> users = userGroupProvider.getUsers(); assertEquals(1, users.size()); assertNotNull(users.stream().filter(u -> u.getIdentity().equals(existingUserIdentity)).findFirst().orElse(null)); }