use of org.apache.cayenne.testdo.testmap.ROPainting in project cayenne by apache.
the class CayenneDataObjectSetToManyListIT method testReadRO1.
@Test
public void testReadRO1() throws Exception {
createArtistWithPaintingDataSet();
Artist a1 = Cayenne.objectForPK(context, Artist.class, 8);
assertEquals(a1 != null, true);
List<ROPainting> paints = ObjectSelect.query(ROPainting.class).where(ROPainting.TO_ARTIST.eq(a1)).select(context);
assertEquals(3, paints.size());
ROPainting rop1 = paints.get(0);
assertSame(a1, rop1.getToArtist());
}
use of org.apache.cayenne.testdo.testmap.ROPainting in project cayenne by apache.
the class CayenneDataObjectSetToManyListIT method testSetEmptyList1.
@Test
public void testSetEmptyList1() throws Exception {
createArtistWithPaintingDataSet();
Artist artist = Cayenne.objectForPK(context, Artist.class, 8);
artist.setToManyTarget(Artist.PAINTING_ARRAY.getName(), new ArrayList<ROPainting>(0), true);
List<Painting> paints = artist.getPaintingArray();
assertEquals(0, paints.size());
}
use of org.apache.cayenne.testdo.testmap.ROPainting in project cayenne by apache.
the class CayenneDataObjectSetToManyListIT method testWrongRelName.
@Test
public void testWrongRelName() throws Exception {
createArtistWithPaintingDataSet();
Artist artist = Cayenne.objectForPK(context, Artist.class, 8);
boolean thrown = false;
try {
artist.setToManyTarget("doesnotexist", new ArrayList<ROPainting>(0), true);
} catch (IllegalArgumentException e) {
thrown = true;
}
assertEquals("should throw a IllegalArgumentException, because the relName does not exist", thrown, true);
thrown = false;
try {
artist.setToManyTarget("", new ArrayList<ROPainting>(0), true);
} catch (IllegalArgumentException e) {
thrown = true;
}
assertEquals("should throw a IllegalArgumentException, because the relName is an empty string", thrown, true);
thrown = false;
try {
artist.setToManyTarget(null, new ArrayList<ROPainting>(0), true);
} catch (IllegalArgumentException e) {
thrown = true;
}
assertEquals("should throw a IllegalArgumentException, because the relName is NULL", thrown, true);
}
use of org.apache.cayenne.testdo.testmap.ROPainting in project cayenne by apache.
the class CDOMany2OneIT method testReadRO1.
@Test
public void testReadRO1() throws Exception {
createArtistWithPaintingDataSet();
Artist a1 = Cayenne.objectForPK(context, Artist.class, 8);
Expression e = ROPainting.TO_ARTIST.eq(a1);
SelectQuery q = new SelectQuery(ROPainting.class, e);
List<ROPainting> paints = context.performQuery(q);
assertEquals(1, paints.size());
ROPainting rop1 = paints.get(0);
assertSame(a1, rop1.getToArtist());
}
use of org.apache.cayenne.testdo.testmap.ROPainting in project cayenne by apache.
the class CDOMany2OneIT method testReadRO2.
@Test
public void testReadRO2() throws Exception {
createArtistWithPaintingDataSet();
Artist a1 = Cayenne.objectForPK(context, Artist.class, 8);
Expression e = ROPainting.TO_ARTIST.eq(a1);
SelectQuery q = new SelectQuery(ROPainting.class, e);
List<ROPainting> paints = context.performQuery(q);
assertEquals(1, paints.size());
ROPainting rop1 = paints.get(0);
assertNotNull(rop1.getToArtist());
// trigger fetch
rop1.getToArtist().getArtistName();
assertEquals(PersistenceState.COMMITTED, rop1.getToArtist().getPersistenceState());
}
Aggregations