public void testSetToNewFromMappedSide() {
testMethod = "testSetToNewFromMappedSide";
if (isTestToBePerformed) {
// Set relationship
IDepartment deptNew = new Department(99L, "The New Department");
pm.makePersistent(deptNew);
emp1.setDepartment(deptNew);
Object deptNewOid = pm.getObjectId((Object)deptNew);
pm.flush();
assertFalse(testMethod + ": Test aborted, precondition is false; " +
"expected deptNewOid to be non-null", deptNewOid == null);
// Postcondition
deferredAssertTrue(deptNew.getEmployees().contains(emp1),
ASSERTION_FAILED + testMethod,
"Postcondition is false; "
+ "other side of relationship not set on flush");
deferredAssertTrue(!dept1.getEmployees().contains(emp1),
ASSERTION_FAILED + testMethod,
"Postcondition is false; "
+ "previous relationship (dept1) not nulled on flush");
pm.currentTransaction().commit();
cleanupPM();
getPM();
pm.currentTransaction().begin();
emp1 = (Employee)pm.getObjectById(emp1Oid);
deptNew = (Department)pm.getObjectById(deptNewOid);
dept1 = (Department)pm.getObjectById(dept1Oid);
deferredAssertTrue(deptNew.getEmployees().contains(emp1),
ASSERTION_FAILED + testMethod,
"Postcondition is false; "
+ "other side of relationship not set in new pm");
deferredAssertTrue(!dept1.getEmployees().contains(emp1),
ASSERTION_FAILED + testMethod,