public void testLocalObjectSynchronize() throws Exception {
deleteTestData();
ObjectContext child = context.createChildContext();
ClientMtTable1 committed = context.newObject(ClientMtTable1.class);
ClientMtTable1 deleted = context.newObject(ClientMtTable1.class);
ClientMtTable1 modified = context.newObject(ClientMtTable1.class);
context.commitChanges();
context.deleteObject(deleted);
modified.setGlobalAttribute1("a");
ClientMtTable1 _new = context.newObject(ClientMtTable1.class);
ClientMtTable1 hollow = (ClientMtTable1) context.localObject(new ObjectId(
"MtTable1"), null);
assertEquals(PersistenceState.HOLLOW, hollow.getPersistenceState());
assertEquals(PersistenceState.COMMITTED, committed.getPersistenceState());
assertEquals(PersistenceState.MODIFIED, modified.getPersistenceState());
assertEquals(PersistenceState.DELETED, deleted.getPersistenceState());
assertEquals(PersistenceState.NEW, _new.getPersistenceState());
blockQueries();
try {
Persistent newPeer = child.localObject(_new.getObjectId(), _new);
assertEquals(_new.getObjectId(), newPeer.getObjectId());
assertEquals(PersistenceState.COMMITTED, newPeer.getPersistenceState());
assertSame(child, newPeer.getObjectContext());
assertSame(context, _new.getObjectContext());
Persistent hollowPeer = child.localObject(hollow.getObjectId(), hollow);
assertEquals(PersistenceState.HOLLOW, hollowPeer.getPersistenceState());
assertEquals(hollow.getObjectId(), hollowPeer.getObjectId());
assertSame(child, hollowPeer.getObjectContext());
assertSame(context, hollow.getObjectContext());
Persistent committedPeer = child.localObject(
committed.getObjectId(),
committed);
assertEquals(PersistenceState.COMMITTED, committedPeer.getPersistenceState());
assertEquals(committed.getObjectId(), committedPeer.getObjectId());
assertSame(child, committedPeer.getObjectContext());
assertSame(context, committed.getObjectContext());
ClientMtTable1 modifiedPeer = (ClientMtTable1) child.localObject(modified
.getObjectId(), modified);
assertEquals(PersistenceState.COMMITTED, modifiedPeer.getPersistenceState());
assertEquals(modified.getObjectId(), modifiedPeer.getObjectId());
assertEquals("a", modifiedPeer.getGlobalAttribute1());
assertSame(child, modifiedPeer.getObjectContext());
assertSame(context, modified.getObjectContext());
Persistent deletedPeer = child.localObject(deleted.getObjectId(), deleted);
assertEquals(PersistenceState.COMMITTED, deletedPeer.getPersistenceState());
assertEquals(deleted.getObjectId(), deletedPeer.getObjectId());