@Test
public void addGroupUserTest() {

    // Setup:
    Map<String, User> users = new HashMap<>();
    IntStream.range(1, 6)
            .mapToObj(Integer::toString)
            .forEach(s -> users.put(s, userFactory.createNew(vf.createIRI("http://mobi.com/users/" + s))));
    Group newGroup = groupFactory.createNew(vf.createIRI("http://mobi.com/groups/testGroup"));
    newGroup.setMember(Collections.singleton(user));
    when(engineManager.retrieveUser(anyString())).thenAnswer(i -> Optional.of(users.get(i.getArgumentAt(0, String.class))));
    when(engineManager.retrieveGroup(eq(ENGINE_NAME), anyString())).thenReturn(Optional.of(newGroup));
    Response response = target().path("groups/testGroup/users").queryParam("users", users.keySet().toArray())
            .request().put(Entity.entity("", MediaType.MULTIPART_FORM_DATA));
    assertEquals(response.getStatus(), 200);
    verify(engineManager).retrieveGroup(ENGINE_NAME, "testGroup");
    users.keySet().forEach(s -> verify(engineManager).retrieveUser(s));
    ArgumentCaptor<Group> captor = ArgumentCaptor.forClass(Group.class);
    verify(engineManager).updateGroup(eq(ENGINE_NAME), captor.capture());
    Group updatedGroup = captor.getValue();
    assertEquals(newGroup.getResource(), updatedGroup.getResource());
    Set<Resource> updatedMembers = updatedGroup.getMember_resource();
    assertEquals(users.size() + 1, updatedMembers.size());
    assertTrue(updatedMembers.contains(user.getResource()));
    users.values().forEach(user -> assertTrue(updatedMembers.contains(user.getResource())));
}