use of org.apache.cayenne.ObjectContext in project cayenne by apache.
the class DataDomainFiltersIT method testOnQuery_Blocking.
@Test
public void testOnQuery_Blocking() {
DataDomain domain = runtime.getDataDomain();
final QueryResponse r1 = new ListResponse();
final QueryResponse r2 = new ListResponse();
DataChannelFilter f1 = new MockDataChannelFilter() {
@Override
public QueryResponse onQuery(ObjectContext originatingContext, Query query, DataChannelFilterChain filterChain) {
return r1;
}
};
DataChannelFilter f2 = new MockDataChannelFilter() {
@Override
public QueryResponse onQuery(ObjectContext originatingContext, Query query, DataChannelFilterChain filterChain) {
return r2;
}
};
domain.filters.add(f1);
domain.filters.add(f2);
SelectQuery query = new SelectQuery(Artist.class);
QueryResponse response = domain.onQuery(context, query);
assertSame(r2, response);
}
use of org.apache.cayenne.ObjectContext in project cayenne by apache.
the class DataDomainIT method testAddListener.
@Test
public void testAddListener() {
DataDomain domain = runtime.getDataDomain();
PostAddListener listener = new PostAddListener();
domain.addListener(listener);
ObjectContext context = runtime.newContext();
context.newObject(Gallery.class);
assertEquals("e:Gallery;", listener.getAndReset());
context.newObject(Artist.class);
assertEquals("a:Artist;", listener.getAndReset());
context.newObject(Exhibit.class);
assertEquals("", listener.getAndReset());
context.newObject(Painting.class);
assertEquals("e:Painting;", listener.getAndReset());
}
use of org.apache.cayenne.ObjectContext in project cayenne by apache.
the class ColumnSelectIT method testNestedContextObjectResult.
@Test
public void testNestedContextObjectResult() {
ObjectContext childContext = runtime.newContext(context);
Property<Artist> artistProperty = Property.createSelf(Artist.class);
List<Artist> artists = ObjectSelect.columnQuery(Artist.class, artistProperty).select(childContext);
assertEquals(20, artists.size());
for (Artist artist : artists) {
assertNotNull(artist);
}
}
use of org.apache.cayenne.ObjectContext in project cayenne by apache.
the class ColumnSelectIT method testNestedContextScalarArrayResult.
@Test
public void testNestedContextScalarArrayResult() {
ObjectContext childContext = runtime.newContext(context);
List<Object[]> data = ObjectSelect.columnQuery(Artist.class, Artist.ARTIST_NAME, Artist.DATE_OF_BIRTH).select(childContext);
assertEquals(20, data.size());
for (Object[] next : data) {
assertTrue(next[0] instanceof String);
assertTrue(next[1] instanceof Date);
}
}
use of org.apache.cayenne.ObjectContext in project cayenne by apache.
the class ColumnSelectIT method testNestedContextScalarResult.
/*
* Test selection from nested context
*/
@Test
public void testNestedContextScalarResult() {
ObjectContext childContext = runtime.newContext(context);
List<String> names = ObjectSelect.columnQuery(Artist.class, Artist.ARTIST_NAME).select(childContext);
assertEquals(20, names.size());
for (String name : names) {
assertNotNull(name);
}
}
Aggregations