use of org.apache.cayenne.testdo.mt.MtTable1 in project cayenne by apache.
the class SelectQueryAbstractEntityIT method test1AbstractEntitySelect.
@Test
public void test1AbstractEntitySelect() throws Exception {
createDataSet();
ObjectSelect<MtTable1> query = ObjectSelect.query(MtTable1.class);
final List<MtTable1> list = context.select(query);
assertNotNull(list);
for (MtTable1 sub : list) {
if (sub instanceof MtTable1Subclass1) {
assertNotNull(((MtTable1Subclass1) sub).getSubclass1Attribute1());
}
}
}
use of org.apache.cayenne.testdo.mt.MtTable1 in project cayenne by apache.
the class ClientServerChannelIT method testSynchronizeCommit.
@Test
public void testSynchronizeCommit() {
ObjectSelect<MtTable1> query = ObjectSelect.query(MtTable1.class);
// no changes...
clientServerChannel.onSync(serverContext, mock(GraphDiff.class), DataChannel.FLUSH_CASCADE_SYNC);
assertEquals(0, serverContext.performQuery(query).size());
// introduce changes
clientServerChannel.onSync(serverContext, new NodeCreateOperation(ObjectId.of("MtTable1")), DataChannel.FLUSH_CASCADE_SYNC);
assertEquals(1, serverContext.performQuery(query).size());
}
use of org.apache.cayenne.testdo.mt.MtTable1 in project cayenne by apache.
the class ObjectDetachOperationIT method testDetachHollow.
@Test
public void testDetachHollow() throws Exception {
tMtTable1.insert(4, "g1", "s1");
EntityResolver serverResover = serverContext.getEntityResolver();
EntityResolver clientResolver = serverResover.getClientEntityResolver();
ObjectDetachOperation op = new ObjectDetachOperation(clientResolver);
ObjectId oid = ObjectId.of("MtTable1", MtTable1.TABLE1_ID_PK_COLUMN, 4);
MtTable1 so = new MtTable1();
so.setObjectId(oid);
so.setPersistenceState(PersistenceState.HOLLOW);
so.setObjectContext(serverContext);
serverContext.getGraphManager().registerNode(oid, so);
Object detached = op.detach(so, serverResover.getClassDescriptor("MtTable1"), null);
assertNotNull(detached);
assertNotSame(so, detached);
assertTrue(detached instanceof ClientMtTable1);
ClientMtTable1 co = (ClientMtTable1) detached;
assertEquals(oid, co.getObjectId());
assertEquals("g1", co.getGlobalAttribute1());
assertEquals(PersistenceState.TRANSIENT, co.getPersistenceState());
assertNull(co.getObjectContext());
}
Aggregations