use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class ClientServerChannelIT method testPerformQueryObjectIDInjection.
@Test
public void testPerformQueryObjectIDInjection() throws Exception {
tMtTable1.insert(55, "g1", "s1");
Query query = new SelectQuery("MtTable1");
QueryResponse response = clientServerChannel.onQuery(null, query);
assertNotNull(response);
List<?> results = response.firstList();
assertNotNull(results);
assertEquals(1, results.size());
Object result = results.get(0);
assertTrue(result instanceof ClientMtTable1);
ClientMtTable1 clientObject = (ClientMtTable1) result;
assertNotNull(clientObject.getObjectId());
assertEquals(new ObjectId("MtTable1", MtTable1.TABLE1_ID_PK_COLUMN, 55), clientObject.getObjectId());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class ClientServerChannelIT method testOnQueryPrefetchingToManyEmpty.
@Test
public void testOnQueryPrefetchingToManyEmpty() throws Exception {
createTwoMtTable1sAnd2sDataSet();
SelectQuery q = new SelectQuery(ClientMtTable1.class);
q.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, SortOrder.ASCENDING);
q.addPrefetch(ClientMtTable1.TABLE2ARRAY_PROPERTY);
final List<?> results = clientServerChannel.onQuery(null, q).firstList();
queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
public void execute() {
ClientMtTable1 o2 = (ClientMtTable1) results.get(1);
assertNull(o2.getObjectContext());
List<?> children2 = o2.getTable2Array();
assertNotNull(children2);
assertFalse(((ValueHolder) children2).isFault());
assertEquals(0, children2.size());
}
});
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class ClientServerChannelQueryIT method testSelectQueryPrefetchToMany.
@Test
public void testSelectQueryPrefetchToMany() throws Exception {
createTwoMtTable1sAnd2sDataSet();
SelectQuery q = new SelectQuery(ClientMtTable1.class, ExpressionFactory.exp("globalAttribute1 = 'g1'"));
q.addPrefetch(ClientMtTable1.TABLE2ARRAY_PROPERTY);
List<?> results = context.performQuery(q);
assertEquals(1, results.size());
ClientMtTable1 result = (ClientMtTable1) results.get(0);
List<?> holder = result.getTable2ArrayDirect();
assertNotNull(holder);
assertTrue(holder instanceof PersistentObjectList);
PersistentObjectList objectHolder = (PersistentObjectList) holder;
assertFalse(objectHolder.isFault());
assertEquals(2, objectHolder.size());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class ClientServerChannelQueryIT method testSelectQueryToManyRelationshipQualifier.
@Test
public void testSelectQueryToManyRelationshipQualifier() throws Exception {
createTwoMtTable1sAnd2sDataSet();
SelectQuery q = new SelectQuery(ClientMtTable1.class, ExpressionFactory.exp("table2Array.globalAttribute = 'g1'"));
List<?> results = context.performQuery(q);
assertEquals(1, results.size());
assertTrue(results.get(0) instanceof ClientMtTable1);
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class ClientServerChannelQueryIT method testSelectQueryEntityNameRoot.
@Test
public void testSelectQueryEntityNameRoot() throws Exception {
createTwoMtTable1sAnd2sDataSet();
SelectQuery q = new SelectQuery("MtTable1");
List<?> results = context.performQuery(q);
assertEquals(2, results.size());
assertTrue(results.get(0) instanceof ClientMtTable1);
}
Aggregations