public void testValidateSocialClub3Members() { EntityManager em = createEntityManager(); SocialClub socialClub3 = createEntityManager().find(SocialClub.class, socialClub3Id); assertNotNull("The social club 1 could not be read back.", socialClub3); assertFalse("The member list was empty", socialClub3.getMembers().isEmpty()); assertTrue("The member count was not the expected 2", socialClub3.getMembers().size() == 2); closeEntityManager(em); }
// Maybe test that setting this flag does not cause an error. Internally // it gets ignored. // ((ObjectLevelReadQuery)((EJBQueryImpl) // query).getDatabaseQuery()).setShouldOuterJoinSubclasses(true); public void testCreateNewSocialClubsWithMembers() { EntityManager em = createEntityManager(); try { beginTransaction(em); // Create some new clubs. SocialClub socialClub1 = new SocialClub(); socialClub1.setName("Jimmy's my name and killing is my game!"); em.persist(socialClub1); socialClub1Id = socialClub1.getId(); SocialClub socialClub2 = new SocialClub(); socialClub2.setName("Sharp shooting"); em.persist(socialClub2); socialClub2Id = socialClub2.getId(); SocialClub socialClub3 = new SocialClub(); socialClub3.setName("Precision explosions"); em.persist(socialClub3); socialClub3Id = socialClub3.getId(); // Create a couple new characters and add them to various clubs. ContractedPersonel contractedPersonel = new ContractedPersonel(); contractedPersonel.setName("Hired Goon"); em.persist(contractedPersonel); SpecialAssassin specialAssassin = new SpecialAssassin(); specialAssassin.setName("IED Expert"); em.persist(specialAssassin); specialAssassinId = specialAssassin.getId(); Assassin assassin = em.find(Assassin.class, assassinId); socialClub1.addMember(assassin); socialClub1.addMember(contractedPersonel); socialClub1.addMember(specialAssassin); socialClub2.addMember(assassin); socialClub2.addMember(contractedPersonel); socialClub3.addMember(contractedPersonel); socialClub3.addMember(specialAssassin); commitTransaction(em); } finally { closeEntityManager(em); } }