// make sure we have a fully resolved copy of an artist and painting
// objects
// in the second context
final Artist altArtist = (Artist) altContext.getGraphManager().getNode(
artist.getObjectId());
final Painting altPainting1 = (Painting) altContext.getGraphManager().getNode(
painting1.getObjectId());
final Painting altPainting2 = (Painting) altContext.getGraphManager().getNode(
painting2.getObjectId());
assertEquals(artist.getArtistName(), altArtist.getArtistName());
assertEquals(painting1.getPaintingTitle(), altPainting1.getPaintingTitle());
assertEquals(painting2.getPaintingTitle(), altPainting2.getPaintingTitle());
assertEquals(2, altArtist.getPaintingArray().size());
assertEquals(PersistenceState.COMMITTED, altArtist.getPersistenceState());
assertEquals(PersistenceState.COMMITTED, altPainting1.getPersistenceState());
assertEquals(PersistenceState.COMMITTED, altPainting2.getPersistenceState());
// make sure toOne relationships from Paintings
// are resolved...
altPainting1.getToArtist();
altPainting2.getToArtist();
assertSame(altArtist, altPainting1.readPropertyDirectly("toArtist"));
assertSame(altArtist, altPainting2.readPropertyDirectly("toArtist"));
// delete painting
context.deleteObject(painting1);
context.commitChanges();
// check underlying cache
assertNull(context.getObjectStore().getDataRowCache().getCachedSnapshot(
painting1.getObjectId()));
// check peer artist
ThreadedTestHelper helper = new ThreadedTestHelper() {
@Override
protected void assertResult() throws Exception {
assertEquals(PersistenceState.TRANSIENT, altPainting1
.getPersistenceState());
assertEquals(PersistenceState.COMMITTED, altArtist.getPersistenceState());
Collection list = altArtist.getPaintingArray();
assertEquals(1, list.size());
assertFalse(list.contains(altPainting1));
}
};
helper.assertWithTimeout(3000);