use of org.datanucleus.samples.fetchplan.FP2Base in project tests by datanucleus.
the class FetchPlanTest method testDetachmentRoots.
/**
* Test the detachment roots
*/
public void testDetachmentRoots() {
FetchPlan fp = getFetchPlan();
FP2Base baseObj = new FP2Base();
assertEquals(0, fp.getDetachmentRoots().size());
// verify immutable
try {
fp.getDetachmentRoots().add(baseObj);
fail("exception UnsupportedOperationException");
} catch (UnsupportedOperationException ex) {
// expected
}
List<Object> elms = new ArrayList<>();
elms.add(baseObj);
fp.setDetachmentRoots(elms);
assertEquals(1, fp.getDetachmentRoots().size());
// verify if immutable by changing original collection
FP2Base baseObj2 = new FP2Base();
elms.add(baseObj2);
assertEquals(1, fp.getDetachmentRoots().size());
// verify immutable after setting roots
try {
fp.getDetachmentRoots().add(baseObj);
fail("exception UnsupportedOperationException");
} catch (UnsupportedOperationException ex) {
// expected
}
}
Aggregations