use of org.apache.cayenne.testdo.inheritance_people.Employee in project cayenne by apache.
the class SingleTableInheritanceIT method testCAY592.
@Test
public void testCAY592() throws Exception {
createManagerAddressDataSet();
List<?> addresses = context.performQuery(new SelectQuery(Address.class));
assertEquals(1, addresses.size());
Address address = (Address) addresses.get(0);
Employee e = address.getToEmployee();
// CAY-592 - make sure modification of the address in a parallel context
// doesn't mess up the Manager
e = (Employee) Cayenne.objectForPK(context2, e.getObjectId());
address = e.getAddresses().get(0);
assertSame(e, address.getToEmployee());
address.setCity("XYZ");
assertSame(e, address.getToEmployee());
}
use of org.apache.cayenne.testdo.inheritance_people.Employee in project cayenne by apache.
the class DeepMergeOperationInheritanceIT method assertMergeResult.
private void assertMergeResult(Department d1, DeepMergeOperation op) {
queryInterceptor.runWithQueriesBlocked(() -> {
Department d2 = op.merge(d1);
assertNotNull(d2);
assertEquals(PersistenceState.COMMITTED, d2.getPersistenceState());
for (Employee ex : d2.getEmployees()) {
if ("E2".equals(ex.getName())) {
assertThat(ex, is(instanceOf(Manager.class)));
} else {
assertThat(ex, is(not(instanceOf(Manager.class))));
}
}
});
}
use of org.apache.cayenne.testdo.inheritance_people.Employee in project cayenne by apache.
the class DeepMergeOperationInheritanceIT method testDeepMergeNonExistentSubclass.
@Test
public void testDeepMergeNonExistentSubclass() {
final Department d1 = context.newObject(Department.class);
d1.setName("D1");
// need to do double commit as Ashwood sorter blows on Employees/Departments ordering...
context.commitChanges();
Employee e1 = context.newObject(Employee.class);
e1.setName("E1");
e1.setPersonType("EE");
d1.addToEmployees(e1);
Manager e2 = context.newObject(Manager.class);
e2.setName("E2");
e2.setPersonType("EM");
d1.addToEmployees(e2);
context.commitChanges();
// need to make sure source relationship is resolved as a result of some Ashwood strangeness...
d1.getEmployees().size();
final DeepMergeOperation op = new DeepMergeOperation(context1);
assertMergeResult(d1, op);
}
Aggregations