@Test
void findGroupsForUser() {

    // Given
    final List<String> userNames = IntStream.range(0, 3)
            .mapToObj(i -> String.format("SomePerson_%s", UUID.randomUUID()))
            .collect(Collectors.toList());
    final List<String> groupNames = IntStream.range(0, 3)
            .mapToObj(i -> String.format("SomeGroup_%s", UUID.randomUUID()))
            .collect(Collectors.toList());
    final String userNameToTest = userNames.get(0);
    // When
    final List<User> users = userNames.stream()
            .map(name -> createUser(name, false))
            .collect(Collectors.toList());
    final User userToTest = users.stream()
            .filter(u -> userNameToTest.equals(u.getName()))
            .findFirst()
            .orElseThrow(() -> new AssertionError("Could not find user to test amongst created users"));
    final List<User> groups = groupNames.stream()
            .map(name -> createUser(name, true))
            .peek(g -> users.forEach(
                    u -> userDao.addUserToGroup(u.getUuid(), g.getUuid())))
            .collect(Collectors.toList());
    final List<User> groupsForUserToTest = userDao.findGroupsForUser(userToTest.getUuid(), null);
    // Then
    groupNames.forEach(groupName -> assertThat(groupsForUserToTest.stream()
            .anyMatch(g -> groupName.equals(g.getName())))
            .isTrue());
}