Search in sources :

Example 6 with MtTable1

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());
        }
    }
}
Also used : MtTable1(org.apache.cayenne.testdo.mt.MtTable1) MtTable1Subclass1(org.apache.cayenne.testdo.mt.MtTable1Subclass1) Test(org.junit.Test)

Example 7 with MtTable1

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());
}
Also used : NodeCreateOperation(org.apache.cayenne.graph.NodeCreateOperation) MtTable1(org.apache.cayenne.testdo.mt.MtTable1) ClientMtTable1(org.apache.cayenne.testdo.mt.ClientMtTable1) GraphDiff(org.apache.cayenne.graph.GraphDiff) Test(org.junit.Test)

Example 8 with MtTable1

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());
}
Also used : ClientMtTable1(org.apache.cayenne.testdo.mt.ClientMtTable1) MtTable1(org.apache.cayenne.testdo.mt.MtTable1) ClientMtTable1(org.apache.cayenne.testdo.mt.ClientMtTable1) ObjectId(org.apache.cayenne.ObjectId) EntityResolver(org.apache.cayenne.map.EntityResolver) Test(org.junit.Test)

Aggregations

MtTable1 (org.apache.cayenne.testdo.mt.MtTable1)8 Test (org.junit.Test)8 ClientMtTable1 (org.apache.cayenne.testdo.mt.ClientMtTable1)6 ObjectId (org.apache.cayenne.ObjectId)2 EntityResolver (org.apache.cayenne.map.EntityResolver)2 DataContext (org.apache.cayenne.access.DataContext)1 GraphDiff (org.apache.cayenne.graph.GraphDiff)1 NodeCreateOperation (org.apache.cayenne.graph.NodeCreateOperation)1 ObjectSelect (org.apache.cayenne.query.ObjectSelect)1 LifecycleCallbackRegistry (org.apache.cayenne.reflect.LifecycleCallbackRegistry)1 ParallelTestContainer (org.apache.cayenne.test.parallel.ParallelTestContainer)1 ClientMtTable2 (org.apache.cayenne.testdo.mt.ClientMtTable2)1 MtTable1Subclass1 (org.apache.cayenne.testdo.mt.MtTable1Subclass1)1 MtTable1Subclass2 (org.apache.cayenne.testdo.mt.MtTable1Subclass2)1 MtTable2 (org.apache.cayenne.testdo.mt.MtTable2)1