use of org.apache.cayenne.testdo.relationships_delete_rules.DeleteRuleFlatB in project cayenne by apache.
the class DeleteRulesIT method testNoActionFlattened.
@Test
public void testNoActionFlattened() {
// temporarily set delete rule to NOACTION...
int oldRule = changeDeleteRule(DeleteRule.NO_ACTION);
try {
DeleteRuleFlatA a = context.newObject(DeleteRuleFlatA.class);
DeleteRuleFlatB b = context.newObject(DeleteRuleFlatB.class);
a.addToFlatB(b);
context.commitChanges();
// must go on without exceptions...
context.deleteObjects(a);
// assert that join is deleted
assertJoinDeleted(a, b);
assertEquals(PersistenceState.DELETED, a.getPersistenceState());
assertEquals(PersistenceState.COMMITTED, b.getPersistenceState());
assertTrue(b.getUntitledRel().contains(a));
context.commitChanges();
} finally {
changeDeleteRule(oldRule);
}
}
use of org.apache.cayenne.testdo.relationships_delete_rules.DeleteRuleFlatB in project cayenne by apache.
the class DeleteRulesIT method testCascadeFlattenedNoReverse.
@Test
public void testCascadeFlattenedNoReverse() {
// temporarily set delete rule to CASCADE...
int oldRule = changeDeleteRule(DeleteRule.CASCADE);
ObjRelationship reverse = unsetReverse();
try {
DeleteRuleFlatA a = context.newObject(DeleteRuleFlatA.class);
DeleteRuleFlatB b = context.newObject(DeleteRuleFlatB.class);
a.addToFlatB(b);
context.commitChanges();
// must go on without exceptions...
context.deleteObjects(a);
// assert that join is deleted
assertJoinDeleted(a, b);
context.commitChanges();
assertEquals(PersistenceState.TRANSIENT, a.getPersistenceState());
assertEquals(PersistenceState.TRANSIENT, b.getPersistenceState());
} finally {
changeDeleteRule(oldRule);
restoreReverse(reverse);
}
}
use of org.apache.cayenne.testdo.relationships_delete_rules.DeleteRuleFlatB in project cayenne by apache.
the class DeleteRulesIT method testDenyFlattened.
@Test
public void testDenyFlattened() {
// temporarily set delete rule to DENY...
int oldRule = changeDeleteRule(DeleteRule.DENY);
try {
DeleteRuleFlatA a = context.newObject(DeleteRuleFlatA.class);
DeleteRuleFlatB b = context.newObject(DeleteRuleFlatB.class);
a.addToFlatB(b);
context.commitChanges();
try {
context.deleteObjects(a);
fail("Must have thrown a deny exception..");
} catch (DeleteDenyException ex) {
// expected... but check further
assertJoinNotDeleted(a, b);
}
} finally {
changeDeleteRule(oldRule);
}
}
Aggregations