use of org.apache.cayenne.testdo.inheritance_people.Address in project cayenne by apache.
the class SingleTableInheritanceIT method testEmployeeAddress.
/**
* Tests that to-one relationship produces correct subclass.
*/
@Test
public void testEmployeeAddress() throws Exception {
createEmployeeAddressDataSet();
List<?> addresses = context.performQuery(new SelectQuery(Address.class));
assertEquals(1, addresses.size());
Address address = (Address) addresses.get(0);
assertSame(Employee.class, address.getToEmployee().getClass());
}
use of org.apache.cayenne.testdo.inheritance_people.Address in project cayenne by apache.
the class SingleTableInheritanceIT method testManagerAddress.
/**
* Tests that to-one relationship produces correct subclass.
*/
@Test
public void testManagerAddress() 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();
assertSame(Manager.class, e.getClass());
}
use of org.apache.cayenne.testdo.inheritance_people.Address in project cayenne by apache.
the class DataContextEJBQLConditionsPeopleIT method setUp.
@Before
public void setUp() {
// TODO: use TableHelper to create test data
Department d1 = context.newObject(Department.class);
d1.setName("d1");
Department d2 = context.newObject(Department.class);
d2.setName("d2");
Department d3 = context.newObject(Department.class);
d3.setName("d3");
context.commitChanges();
Manager m1 = context.newObject(Manager.class);
m1.setName("m1");
m1.setPersonType("EM");
Manager m2 = context.newObject(Manager.class);
m2.setName("m2");
m2.setPersonType("EM");
Manager m3 = context.newObject(Manager.class);
m3.setName("m3");
m3.setPersonType("EM");
Address a1 = context.newObject(Address.class);
m1.addToAddresses(a1);
Address a2 = context.newObject(Address.class);
m2.addToAddresses(a2);
Address a3 = context.newObject(Address.class);
m3.addToAddresses(a3);
d1.addToEmployees(m1);
d1.addToEmployees(m2);
d3.addToEmployees(m3);
context.commitChanges();
d1.setToManager(m1);
d2.setToManager(m2);
d3.setToManager(m3);
context.commitChanges();
}
use of org.apache.cayenne.testdo.inheritance_people.Address 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());
}
Aggregations