use of org.apache.cayenne.testdo.testmap.Artist in project cayenne by apache.
the class SelectByIdTest method testSerializabilityWithHessian.
@Test
public void testSerializabilityWithHessian() throws Exception {
SelectById<Artist> o = SelectById.query(Artist.class, 5);
Object clone = HessianUtil.cloneViaClientServerSerialization(o, new EntityResolver());
assertTrue(clone instanceof SelectById);
SelectById<?> c1 = (SelectById<?>) clone;
assertNotSame(o, c1);
assertEquals(o.entityType, c1.entityType);
assertEquals(o.singleId, c1.singleId);
}
use of org.apache.cayenne.testdo.testmap.Artist in project cayenne by apache.
the class FlattenedPrefetchIT method testJointManyToMany.
@Test
public void testJointManyToMany() throws Exception {
createPrefetchDataSet1();
SelectQuery q = new SelectQuery(Artist.class);
q.addPrefetch(Artist.GROUP_ARRAY.joint());
final List<Artist> objects = context.performQuery(q);
queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
public void execute() {
assertEquals(3, objects.size());
for (Artist a : objects) {
List<ArtGroup> list = a.getGroupArray();
assertNotNull(list);
assertFalse("artist's groups not resolved: " + a, ((ValueHolder) list).isFault());
assertTrue(list.size() > 0);
for (ArtGroup g : list) {
assertEquals(PersistenceState.COMMITTED, g.getPersistenceState());
}
// assert no duplicates
Set<ArtGroup> s = new HashSet<ArtGroup>(list);
assertEquals(s.size(), list.size());
}
}
});
}
use of org.apache.cayenne.testdo.testmap.Artist in project cayenne by apache.
the class FlattenedPrefetchIT method testJointMultiPrefetch.
@Test
public void testJointMultiPrefetch() throws Exception {
createPrefetchDataSet2();
SelectQuery q = new SelectQuery(Painting.class);
q.addPrefetch(Painting.TO_ARTIST.joint());
q.addPrefetch(Painting.TO_ARTIST.dot(Artist.GROUP_ARRAY).joint());
final List<Painting> objects = context.performQuery(q);
queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
public void execute() {
assertEquals(3, objects.size());
for (Painting p : objects) {
Artist a = p.getToArtist();
assertEquals(PersistenceState.COMMITTED, a.getPersistenceState());
List<ArtGroup> list = a.getGroupArray();
assertNotNull(list);
assertFalse("artist's groups not resolved: " + a, ((ValueHolder) list).isFault());
assertTrue(list.size() > 0);
for (ArtGroup g : list) {
assertEquals(PersistenceState.COMMITTED, g.getPersistenceState());
}
// assert no duplicates
Set<ArtGroup> s = new HashSet<ArtGroup>(list);
assertEquals(s.size(), list.size());
}
}
});
}
use of org.apache.cayenne.testdo.testmap.Artist in project cayenne by apache.
the class DataContextSelectQuerySplitAliasesIT method testAliasPathSplits_SplitJoin.
@Test
public void testAliasPathSplits_SplitJoin() throws Exception {
createTwoArtistsThreePaintingsDataSet();
SelectQuery query = new SelectQuery(Artist.class);
query.andQualifier(ExpressionFactory.matchExp("p1.paintingTitle", "X"));
query.andQualifier(ExpressionFactory.matchExp("p2.paintingTitle", "Y"));
query.aliasPathSplits("paintingArray", "p1", "p2");
List<Artist> artists = context.performQuery(query);
assertEquals(1, artists.size());
assertEquals("BB", artists.get(0).getArtistName());
}
use of org.apache.cayenne.testdo.testmap.Artist in project cayenne by apache.
the class DataContextSelectQuerySplitAliasesIT method testAliasPathSplits_SinglePath.
@Test
public void testAliasPathSplits_SinglePath() throws Exception {
createTwoArtistsTwoPaintingsDataSet();
SelectQuery query = new SelectQuery(Artist.class);
query.andQualifier(ExpressionFactory.matchExp("p.paintingTitle", "X"));
query.aliasPathSplits("paintingArray", "p");
List<Artist> artists = context.performQuery(query);
assertEquals(1, artists.size());
assertEquals("AA", artists.get(0).getArtistName());
}
Aggregations