use of org.apache.cayenne.query.MockQuery in project cayenne by apache.
the class QualifierTranslatorIT method testNonQualifiedQuery.
// TODO: not an integration test; extract into *Test
@Test
public void testNonQualifiedQuery() throws Exception {
TstQueryAssembler qa = new TstQueryAssembler(new MockQuery(), node.getAdapter(), node.getEntityResolver());
try {
new QualifierTranslator(qa).appendPart(new StringBuilder());
fail();
} catch (ClassCastException ccex) {
// exception expected
}
}
use of org.apache.cayenne.query.MockQuery in project cayenne by apache.
the class ClientServerChannelIT method testOnQuery.
@Test
public void testOnQuery() {
final boolean[] genericDone = new boolean[1];
MockDataChannel parent = new MockDataChannel(new EntityResolver()) {
@Override
public QueryResponse onQuery(ObjectContext context, Query query) {
genericDone[0] = true;
return super.onQuery(context, query);
}
};
DataContext context = (DataContext) runtime.newContext(parent);
QueryMessage message = new QueryMessage(new MockQuery());
new ClientServerChannel(context).onQuery(null, message.getQuery());
assertTrue(genericDone[0]);
}
use of org.apache.cayenne.query.MockQuery in project cayenne by apache.
the class DataContextDelegateIT method testWillPerformGenericQuery.
@Test
public void testWillPerformGenericQuery() throws Exception {
final List<Query> queriesPerformed = new ArrayList<Query>(1);
DataContextDelegate delegate = new MockDataContextDelegate() {
@Override
public Query willPerformGenericQuery(DataContext context, Query query) {
queriesPerformed.add(query);
return query;
}
};
context.setDelegate(delegate);
// test that delegate is consulted before select
MockQuery query = new MockQuery();
context.performGenericQuery(query);
assertTrue("Delegate is not notified of a query being run.", queriesPerformed.contains(query));
assertEquals(1, queriesPerformed.size());
assertTrue("Delegate unexpectedly blocked the query.", query.isRouteCalled());
}
use of org.apache.cayenne.query.MockQuery in project cayenne by apache.
the class DataContextDelegateIT method testWillPerformGenericQueryBlocked.
@Test
public void testWillPerformGenericQueryBlocked() throws Exception {
final List<Query> queriesPerformed = new ArrayList<Query>(1);
DataContextDelegate delegate = new MockDataContextDelegate() {
@Override
public Query willPerformGenericQuery(DataContext context, Query query) {
queriesPerformed.add(query);
return null;
}
};
context.setDelegate(delegate);
MockQuery query = new MockQuery();
context.performGenericQuery(query);
assertTrue("Delegate is not notified of a query being run.", queriesPerformed.contains(query));
assertEquals(1, queriesPerformed.size());
assertFalse("Delegate couldn't block the query.", query.isRouteCalled());
}
Aggregations