assertEquals(src.getObjectId(), src2.getObjectId());
assertEquals(target.getObjectId(), target2.getObjectId());
}
public void testNewAdd() throws Exception {
ToOneFK2 src = context.newObject(ToOneFK2.class);
ToOneFK1 target = context.newObject(ToOneFK1.class);
// *** TESTING THIS ***
src.setToOneToFK(target);
// test before save
assertSame(target, src.getToOneToFK());
// do save
context.commitChanges();
context = createDataContext();
// test database data
ObjectIdQuery refetch = new ObjectIdQuery(
src.getObjectId(),
false,
ObjectIdQuery.CACHE_REFRESH);
ToOneFK2 src2 = (ToOneFK2) Cayenne.objectForQuery(context, refetch);
ToOneFK1 target2 = src2.getToOneToFK();
assertNotNull(target2);
assertEquals(src.getObjectId(), src2.getObjectId());
assertEquals(target.getObjectId(), target2.getObjectId());
}