public void testPersistBase() {
Object id = null;
try {
getPM().currentTransaction().begin();
Kitchen kitchen1 = new Kitchen(1);
Oven oven = new Oven("Westinghouse", "Economy");
kitchen1.setOven(oven);
getPM().makePersistent(kitchen1);
getPM().currentTransaction().commit();
id = getPM().getObjectId(kitchen1);
}
catch (Exception e) {
fail("Exception on persist : " + e.getMessage());
}
finally {
if (getPM().currentTransaction().isActive()) {
getPM().currentTransaction().rollback();
}
}
getPM().currentTransaction().begin();
Kitchen kitchen = (Kitchen)getPM().getObjectById(id);
assertEquals("Id of object is incorrect", 1, kitchen.getId());
Oven oven = kitchen.getOven();
assertNotNull("Oven of Kitchen is null!", oven);
assertEquals("Oven is of incorrect type", Oven.class.getName(), oven.getClass().getName());
assertEquals("Oven make is incorrect", "Westinghouse", oven.getMake());
assertEquals("Oven model is incorrect", "Economy", oven.getModel());
getPM().currentTransaction().commit();
}