@Test
public void testModifyUserRemoveGroup() throws Exception
{
//Setup
Group group = new Group(TEST_GROUP_ID);
User user = new User(TEST_USER_ID , TEST_PASSWORD);
user.addToGroups(group);
em.persist(group);
em.persist(user);
em.flush();
em.clear();
//Execute
user.removeFromGroups(group);
user = repository.modify(user);
em.flush();
em.clear();
//Verify
User actualUser = em.find(User.class, TEST_USER_ID);
Group actualGroup = em.find(Group.class, TEST_GROUP_ID);
assertEquals(user, actualUser);
assertFalse(actualUser.getGroups().contains(group));
assertEquals(group, actualGroup);
}