use of org.apache.cayenne.testdo.testmap.CompoundPainting in project cayenne by apache.
the class DataContextFlattenedAttributesIT method testSelectCompound1.
@Test
public void testSelectCompound1() throws Exception {
createTestDataSet();
SelectQuery query = new SelectQuery(CompoundPainting.class);
List<?> objects = context.performQuery(query);
assertNotNull(objects);
assertEquals(8, objects.size());
assertTrue("CompoundPainting expected, got " + objects.get(0).getClass(), objects.get(0) instanceof CompoundPainting);
for (Iterator<?> i = objects.iterator(); i.hasNext(); ) {
CompoundPainting painting = (CompoundPainting) i.next();
Number id = (Number) painting.getObjectId().getIdSnapshot().get("PAINTING_ID");
assertEquals("CompoundPainting.getPaintingTitle(): " + painting.getPaintingTitle(), "painting" + id, painting.getPaintingTitle());
if (painting.getToPaintingInfo() == null) {
assertNull(painting.getTextReview());
} else {
assertEquals("CompoundPainting.getTextReview(): " + painting.getTextReview(), "painting review" + id, painting.getTextReview());
}
assertEquals("CompoundPainting.getArtistName(): " + painting.getArtistName(), painting.getToArtist().getArtistName(), painting.getArtistName());
if (painting.getToGallery() == null) {
assertNull(painting.getGalleryName());
} else {
assertEquals("CompoundPainting.getGalleryName(): " + painting.getGalleryName(), painting.getToGallery().getGalleryName(), painting.getGalleryName());
}
}
}
use of org.apache.cayenne.testdo.testmap.CompoundPainting in project cayenne by apache.
the class DataContextFlattenedAttributesIT method testSelectEJQBQL.
@Test
public void testSelectEJQBQL() throws Exception {
createTestDataSet();
EJBQLQuery query = new EJBQLQuery("SELECT a FROM CompoundPainting a WHERE a.artistName = 'artist2'");
List<?> objects = context.performQuery(query);
assertNotNull(objects);
assertEquals(2, objects.size());
assertTrue("CompoundPainting expected, got " + objects.get(0).getClass(), objects.get(0) instanceof CompoundPainting);
Iterator<?> i = objects.iterator();
while (i.hasNext()) {
CompoundPainting painting = (CompoundPainting) i.next();
assertEquals(PersistenceState.COMMITTED, painting.getPersistenceState());
}
}
use of org.apache.cayenne.testdo.testmap.CompoundPainting in project cayenne by apache.
the class DataContextFlattenedAttributesIT method testSelectEJQBQLBetween.
@Test
public void testSelectEJQBQLBetween() throws Exception {
createTestDataSet();
EJBQLQuery query = new EJBQLQuery("SELECT a FROM CompoundPainting a " + "WHERE a.artistName BETWEEN 'artist1' AND 'artist4' " + "ORDER BY a.paintingTitle");
List<?> objects = context.performQuery(query);
assertNotNull(objects);
assertEquals(8, objects.size());
Iterator<?> i = objects.iterator();
int index = 1;
while (i.hasNext()) {
CompoundPainting painting = (CompoundPainting) i.next();
assertEquals("painting" + index, painting.getPaintingTitle());
index++;
}
}
Aggregations