Search in sources :

Example 1 with MtTable1Subclass1

use of org.apache.cayenne.testdo.mt.MtTable1Subclass1 in project cayenne by apache.

the class ValueInjectorIT method testServer.

@Test
public void testServer() {
    ObjEntity entity = serverContext.getEntityResolver().getObjEntity(MtTable1Subclass1.class);
    Expression qualifier = entity.getDeclaredQualifier();
    try {
        MtTable1Subclass1 ee = serverContext.newObject(MtTable1Subclass1.class);
        assertEquals(ee.getGlobalAttribute1(), "sub1");
        // check AND
        entity.setDeclaredQualifier(qualifier.andExp(ExpressionFactory.exp("serverAttribute1 = 'sa'")));
        ee = serverContext.newObject(MtTable1Subclass1.class);
        assertEquals(ee.getGlobalAttribute1(), "sub1");
        assertEquals(ee.getServerAttribute1(), "sa");
    } finally {
        entity.setDeclaredQualifier(qualifier);
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) Expression(org.apache.cayenne.exp.Expression) ClientMtTable1Subclass1(org.apache.cayenne.testdo.mt.ClientMtTable1Subclass1) MtTable1Subclass1(org.apache.cayenne.testdo.mt.MtTable1Subclass1) Test(org.junit.Test)

Example 2 with MtTable1Subclass1

use of org.apache.cayenne.testdo.mt.MtTable1Subclass1 in project cayenne by apache.

the class SelectQueryAbstractEntityIT method test1AbstractEntitySelect.

@Test
public void test1AbstractEntitySelect() throws Exception {
    createDataSet();
    SelectQuery<MtTable1> query = new SelectQuery<MtTable1>(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)

Aggregations

MtTable1Subclass1 (org.apache.cayenne.testdo.mt.MtTable1Subclass1)2 Test (org.junit.Test)2 Expression (org.apache.cayenne.exp.Expression)1 ObjEntity (org.apache.cayenne.map.ObjEntity)1 ClientMtTable1Subclass1 (org.apache.cayenne.testdo.mt.ClientMtTable1Subclass1)1 MtTable1 (org.apache.cayenne.testdo.mt.MtTable1)1