insertData((MutableDataSource) aManager.getDelegate(), new File(DATA_FILE));
TestEntityListener.clearState();
Spacecraft aCraft = aManager.find(Spacecraft.class,
URI.create("http://nasa.dataincubator.org/spacecraft/1989-033B"));
assertTrue(aCraft.postLoadCalled);
assertTrue(TestEntityListener.postLoadCalled);
TestEntityListener.clearState();
aCraft.clearState();
aCraft.setDescription("some new description");
aCraft = aManager.merge(aCraft);
assertTrue(aCraft.preUpdateCalled);
assertTrue(aCraft.postUpdateCalled);
assertTrue(TestEntityListener.preUpdateCalled);
assertTrue(TestEntityListener.postUpdateCalled);
TestEntityListener.clearState();
aCraft.clearState();
aManager.remove(aCraft);
assertTrue(aCraft.preRemoveCalled);
assertTrue(aCraft.postRemoveCalled);
assertTrue(TestEntityListener.preRemoveCalled);
assertTrue(TestEntityListener.postRemoveCalled);
TestEntityListener.clearState();
aCraft.clearState();
Spacecraft aNewCraft = new Spacecraft();
aNewCraft.setAgency("U.S.A");
aNewCraft.setAlternateName(Collections.singletonList("67890"));
aNewCraft.setDescription("The newer rocket to return to the moon");
aNewCraft.setName("Ares 2");
aNewCraft.setMass("5000");
aManager.persist(aNewCraft);
assertTrue(aNewCraft.prePersistCalled);
assertTrue(aNewCraft.postPersistCalled);