use of org.apache.cayenne.testdo.testmap.ROArtist in project cayenne by apache.
the class DataContextIT method testCommitChangesRO2.
@Test
public void testCommitChangesRO2() throws Exception {
createArtistsDataSet();
SelectQuery query = new SelectQuery(ROArtist.class, Artist.ARTIST_NAME.eq("artist1"));
ROArtist a1 = (ROArtist) context.performQuery(query).get(0);
a1.writeProperty(ROArtist.ARTIST_NAME.getName(), "abc");
try {
context.commitChanges();
fail("Updating a 'read-only' object must fail.");
} catch (Exception ex) {
// exception is expected,
// must blow on saving new "read-only" object.
}
}
use of org.apache.cayenne.testdo.testmap.ROArtist in project cayenne by apache.
the class DataContextIT method testCommitChangesRO1.
@Test
public void testCommitChangesRO1() throws Exception {
ROArtist a1 = (ROArtist) context.newObject("ROArtist");
a1.writePropertyDirectly("artistName", "abc");
a1.setPersistenceState(PersistenceState.MODIFIED);
try {
context.commitChanges();
fail("Inserting a 'read-only' object must fail.");
} catch (Exception ex) {
// exception is expected,
// must blow on saving new "read-only" object.
}
}
use of org.apache.cayenne.testdo.testmap.ROArtist in project cayenne by apache.
the class DataContextIT method testCommitChangesRO4.
@Test
public void testCommitChangesRO4() throws Exception {
createArtistsDataSet();
SelectQuery query = new SelectQuery(ROArtist.class, Artist.ARTIST_NAME.eq("artist1"));
ROArtist a1 = (ROArtist) context.performQuery(query).get(0);
Painting painting = context.newObject(Painting.class);
painting.setPaintingTitle("paint");
a1.addToPaintingArray(painting);
assertEquals(PersistenceState.MODIFIED, a1.getPersistenceState());
try {
context.commitChanges();
} catch (Exception ex) {
fail("Updating 'read-only' object's to-many must succeed, instead an exception was thrown: " + ex);
}
assertEquals(PersistenceState.COMMITTED, a1.getPersistenceState());
}
use of org.apache.cayenne.testdo.testmap.ROArtist in project cayenne by apache.
the class DataContextIT method testCommitChangesRO3.
@Test
public void testCommitChangesRO3() throws Exception {
createArtistsDataSet();
SelectQuery query = new SelectQuery(ROArtist.class, Artist.ARTIST_NAME.eq("artist1"));
ROArtist a1 = (ROArtist) context.performQuery(query).get(0);
context.deleteObjects(a1);
try {
context.commitChanges();
fail("Deleting a 'read-only' object must fail.");
} catch (Exception ex) {
// exception is expected,
// must blow on saving new "read-only" object.
}
}
Aggregations