use of org.eclipse.persistence.testing.models.jpa.advanced.GolferPK in project eclipselink by eclipse-ee4j.
the class EntityManagerJUnitTestSuite method testWeaving.
/**
* Test that all of the classes in the advanced model were weaved as expected.
*/
public void testWeaving() {
// Only test if weaving was on, test runs without weaving must set this system property.
if (isWeavingEnabled()) {
internalTestWeaving(new Employee(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), true);
internalTestWeaving(new FormerEmployment(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
internalTestWeaving(new Address(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
internalTestWeaving(new PhoneNumber(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
internalTestWeaving(new EmploymentPeriod(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
// field-locking
internalTestWeaving(new Buyer(), false, isWeavingForFetchGroupsEnabled(), false);
// field-locking
internalTestWeaving(new GoldBuyer(), false, isWeavingForFetchGroupsEnabled(), false);
// field-locking
internalTestWeaving(new PlatinumBuyer(), false, isWeavingForFetchGroupsEnabled(), false);
// eager 1-m
internalTestWeaving(new Department(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
internalTestWeaving(new Golfer(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
internalTestWeaving(new GolferPK(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
internalTestWeaving(new SmallProject(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
internalTestWeaving(new LargeProject(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
internalTestWeaving(new Man(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
internalTestWeaving(new Woman(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
// serialized
internalTestWeaving(new Vegetable(), false, isWeavingForFetchGroupsEnabled(), false);
internalTestWeaving(new VegetablePK(), false, isWeavingForFetchGroupsEnabled(), false);
internalTestWeaving(new WorldRank(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
internalTestWeaving(new Equipment(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
internalTestWeaving(new EquipmentCode(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
internalTestWeaving(new PartnerLink(), isWeavingForChangeTrackingEnabled(), isWeavingForFetchGroupsEnabled(), false);
}
}
use of org.eclipse.persistence.testing.models.jpa.advanced.GolferPK in project eclipselink by eclipse-ee4j.
the class EntityManagerJUnitTestSuite method testReplaceElementCollection.
// Bug 384607
public void testReplaceElementCollection() {
EntityManager em = createEntityManager();
beginTransaction(em);
Golfer golfer = new Golfer();
GolferPK pk = new GolferPK(102);
WorldRank rank = new WorldRank();
rank.setId(102);
golfer.setWorldRank(rank);
golfer.getSponsorDollars().put("Oracle", 10000);
golfer.setGolferPK(pk);
em.persist(golfer);
em.persist(rank);
em.flush();
golfer = em.find(Golfer.class, golfer.getGolferPK());
golfer.getSponsorDollars().put("Callaway", 20000);
em.flush();
clearCache();
em.clear();
golfer = em.find(Golfer.class, golfer.getGolferPK());
assertTrue("Incorrect Number of sponsors", golfer.getSponsorDollars().size() == 2);
assertTrue("Missing Sponsor: Callaway", golfer.getSponsorDollars().get("Callaway").equals(20000));
assertTrue("Missing Sponsor: Oracle", golfer.getSponsorDollars().get("Oracle").equals(10000));
golfer = em.find(Golfer.class, golfer.getGolferPK());
golfer.setSponsorDollars(new HashMap<String, Integer>());
em.flush();
clearCache();
em.clear();
golfer = em.find(Golfer.class, golfer.getGolferPK());
assertTrue("Incorrect Number of sponsors", golfer.getSponsorDollars().size() == 0);
rollbackTransaction(em);
}
use of org.eclipse.persistence.testing.models.jpa.advanced.GolferPK in project eclipselink by eclipse-ee4j.
the class AdvancedJunitTest method testGF894.
public void testGF894() {
EntityManager em = createEntityManager();
beginTransaction(em);
try {
for (int i = 0; ; i++) {
GolferPK golferPK = new GolferPK(i);
Golfer golfer = em.find(Golfer.class, golferPK);
if (golfer == null) {
golfer = new Golfer();
golfer.setGolferPK(golferPK);
WorldRank worldRank = new WorldRank();
worldRank.setId(i);
golfer.setWorldRank(worldRank);
em.persist(worldRank);
em.persist(golfer);
commitTransaction(em);
break;
}
}
} catch (Exception e) {
fail("An exception was caught: [" + e.getMessage() + "]");
}
closeEntityManager(em);
}
Aggregations