use of org.apache.cayenne.testdo.inheritance_people.Manager 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.Manager in project cayenne by apache.
the class DataContextEJBQLConditionsPeopleIT method testCollectionNotMemberOfId.
@Test
public void testCollectionNotMemberOfId() throws Exception {
String ejbql = "SELECT DISTINCT m FROM Manager m JOIN m.managedDepartments d" + " WHERE m NOT MEMBER d.employees";
EJBQLQuery query = new EJBQLQuery(ejbql);
List<?> objects = context.performQuery(query);
assertEquals(1, objects.size());
Set<String> ids = new HashSet<String>();
Iterator<?> it = objects.iterator();
while (it.hasNext()) {
Manager m = (Manager) it.next();
ids.add(m.getName());
}
assertTrue(ids.contains("m2"));
}
use of org.apache.cayenne.testdo.inheritance_people.Manager in project cayenne by apache.
the class DataContextEJBQLConditionsPeopleIT method testCollectionMemberOfId.
@Test
public void testCollectionMemberOfId() throws Exception {
String ejbql = "SELECT DISTINCT m FROM Manager m JOIN m.managedDepartments d" + " WHERE m MEMBER d.employees";
EJBQLQuery query = new EJBQLQuery(ejbql);
List<?> objects = context.performQuery(query);
assertEquals(2, objects.size());
Set<String> ids = new HashSet<String>();
Iterator<?> it = objects.iterator();
while (it.hasNext()) {
Manager m = (Manager) it.next();
ids.add(m.getName());
}
assertTrue(ids.contains("m1"));
assertTrue(ids.contains("m3"));
}
use of org.apache.cayenne.testdo.inheritance_people.Manager in project cayenne by apache.
the class SingleTableInheritanceIT method testMatchingOnSuperAttributesWithPrefetch.
@Test
public void testMatchingOnSuperAttributesWithPrefetch() throws Exception {
create2PersonDataSet();
// fetch on leaf, but match on a super attribute
SelectQuery select = new SelectQuery(Employee.class);
select.addPrefetch(Employee.TO_DEPARTMENT.disjoint());
select.andQualifier(AbstractPerson.NAME.eq("E2"));
List<Manager> results = context.performQuery(select);
assertEquals(1, results.size());
assertEquals("E2", results.get(0).getName());
}
use of org.apache.cayenne.testdo.inheritance_people.Manager 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