public void testSnapshotRetainedOnRelAndPropertyModification() throws Exception {
createTestData("test");
DataContext context = createDataContext();
Artist a = DataObjectUtils.objectForPK(context, Artist.class, 2000);
ObjectStore objectStore = context.getObjectStore();
assertNull(objectStore.getChangesByObjectId().get(a.getObjectId()));
// we are trying to reproduce the bug CAY-213 - relationship modification puts
// object in a modified state, so later when object is really modified, its
// snapshot is not retained... in testing this I am leaving some flexibility for
// the framework to retain a snapshot when it deems appropriate...
a.addToPaintingArray(context.newObject(Painting.class));
a.setArtistName("some other name");
assertNotNull("Snapshot wasn't retained - CAY-213", objectStore
.getChangesByObjectId()
.get(a.getObjectId()));
}