use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class CayenneDataObjectRelationshipsIT method testComplexInsertUpdateOrdering.
@Test
public void testComplexInsertUpdateOrdering() {
Artist artist = context.newObject(Artist.class);
artist.setArtistName("a name");
context.commitChanges();
// Cause an update and an insert that need correct ordering
Painting painting = context.newObject(Painting.class);
painting.setPaintingTitle("a painting");
artist.addToPaintingArray(painting);
context.commitChanges();
context.deleteObjects(artist);
context.commitChanges();
}
use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class CayenneDataObjectRelationshipsIT method testReadToManyRel1.
@Test
public void testReadToManyRel1() throws Exception {
createArtistWithPaintingDataSet();
Artist a1 = Cayenne.objectForPK(context, Artist.class, 8);
List<Painting> plist = a1.getPaintingArray();
assertNotNull(plist);
assertEquals(1, plist.size());
assertEquals(PersistenceState.COMMITTED, plist.get(0).getPersistenceState());
assertEquals("pW", plist.get(0).getPaintingTitle());
}
use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class CayenneDataObjectRelationshipsIT method testReadToOneRel2.
@Test
public void testReadToOneRel2() throws Exception {
// test chained calls to read relationships
createArtistWithPaintingAndInfoDataSet();
PaintingInfo pi1 = Cayenne.objectForPK(context, PaintingInfo.class, 6);
Painting p1 = pi1.getPainting();
p1.getPaintingTitle();
Artist a1 = p1.getToArtist();
assertNotNull(a1);
assertEquals(PersistenceState.HOLLOW, a1.getPersistenceState());
assertEquals("aX", a1.getArtistName());
assertEquals(PersistenceState.COMMITTED, a1.getPersistenceState());
}
use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class CayenneDataObjectSetToManyListIT method testRemoveOneOldAndAddOneNewPaintings.
@Test
public void testRemoveOneOldAndAddOneNewPaintings() throws Exception {
createArtistWithPaintingDataSet();
Artist artist = Cayenne.objectForPK(context, Artist.class, 8);
List<Painting> newPaints = new ArrayList<Painting>();
Painting paint6 = artist.getPaintingArray().get(0);
Painting paint7 = artist.getPaintingArray().get(1);
Painting paint8 = artist.getPaintingArray().get(2);
Painting paintX = new Painting();
paintX.setPaintingTitle("pantingX");
Painting paintY = new Painting();
paintY.setPaintingTitle("paintingY");
newPaints.add(paint6);
newPaints.add(paint7);
newPaints.add(paintX);
newPaints.add(paintY);
List<? extends DataObject> returnList = artist.setToManyTarget(Artist.PAINTING_ARRAY.getName(), newPaints, true);
assertEquals(returnList.size(), 1);
assertEquals(returnList.get(0) == paint8, true);
List<Painting> newPaints2 = artist.getPaintingArray();
assertEquals(newPaints2.size(), 4);
assertEquals(newPaints2.contains(paintX), true);
assertEquals(newPaints2.contains(paintY), true);
assertEquals(newPaints2.contains(paint6), true);
assertEquals(newPaints2.contains(paint7), true);
}
use of org.apache.cayenne.testdo.testmap.Painting in project cayenne by apache.
the class DataContextMaxIdQualifierIT method testIncrementalFaultList_Lower.
@Test
public void testIncrementalFaultList_Lower() throws Exception {
insertData_OneBag_100Boxes();
runtime.getDataDomain().setMaxIdQualifierSize(5);
final SelectQuery query = new SelectQuery(Painting.class);
query.setPageSize(10);
int queriesCount = queryInterceptor.runWithQueryCounter(new UnitTestClosure() {
public void execute() {
final List<Painting> boxes = context.performQuery(query);
for (Painting box : boxes) {
box.getToArtist();
}
}
});
assertEquals(21, queriesCount);
queriesCount = queryInterceptor.runWithQueryCounter(new UnitTestClosure() {
public void execute() {
final List<Painting> boxes = context.performQuery(query);
List<Painting> tempList = new ArrayList<Painting>();
tempList.addAll(boxes);
}
});
assertEquals(21, queriesCount);
}
Aggregations