GroupManager groupMan = new GroupManager();
groupMan.setEntityManager(em);
FireUser user1 = TestUtil.createRandomUser();
StudentGroup sg = new StudentGroup();
sg.addGroupMember(user1);
em.getTransaction().begin();
userMan.create(user1);
groupMan.create(sg);
em.getTransaction().commit();
FireUser user2 = userMan.read(user1.getId());
assertNotNull(user2);
StudentGroup group = groupMan.read(sg.getId());
assertNotNull(group);
assertEquals(user2, user1);
// Test getGroupForUser
List<FireUser> users = groupMan.getGroupMembers(group);
assertTrue(users.size() > 0);
TestData data = new TestData();
StudentGroup group2 = new StudentGroup();
group2.addAllGroupMembers(data.users);
em.getTransaction().begin();
for (FireUser user : data.users) userMan.create(user);
groupMan.create(group2);
em.getTransaction().commit();
StudentGroup group3 = groupMan.getGroupForUser(data.user2);
assertEquals(group2, group3);
}