Search in sources :

Example 86 with PopulationManager

use of org.eclipse.persistence.tools.schemaframework.PopulationManager in project eclipselink by eclipse-ee4j.

the class QueryOptimizationTestSuite method addJoinTests.

public void addJoinTests() {
    PopulationManager manager = PopulationManager.getDefaultManager();
    Employee object = (Employee) manager.getObject(Employee.class, "0002");
    // Joining
    ReadObjectTest test = new ReadObjectTest(object);
    test.setName("JoiningReadObjectTestAddress");
    ReadObjectQuery query = new ReadObjectQuery();
    query.setSelectionObject(object);
    query.addJoinedAttribute("address");
    test.setQuery(query);
    addTest(test);
    ReadObjectTest test1a = new ReadObjectTest(object);
    test1a.setName("JoiningReadObjectTestAddressManager");
    ReadObjectQuery query1a = new ReadObjectQuery();
    query1a.setSelectionObject(object);
    query1a.addJoinedAttribute("address");
    query1a.addJoinedAttribute("manager");
    test1a.setQuery(query1a);
    addTest(test1a);
    ReadObjectTest test1m = new ReadObjectTest(object);
    test1m.setName("JoiningReadObjectTestPhones");
    ReadObjectQuery query1m = new ReadObjectQuery();
    query1m.setSelectionObject(object);
    query1m.addJoinedAttribute(query1m.getExpressionBuilder().anyOf("phoneNumbers"));
    test1m.setQuery(query1m);
    addTest(test1m);
    test1m = new ReadObjectTest(object);
    test1m.setName("JoiningReadObjectTestPhonesOuter");
    query1m = new ReadObjectQuery();
    query1m.setSelectionObject(object);
    query1m.addJoinedAttribute(query1m.getExpressionBuilder().anyOfAllowingNone("phoneNumbers"));
    test1m.setQuery(query1m);
    addTest(test1m);
    addTest(new ReadAnyObjectJoinPhoneTest());
    Object person = manager.getObject(Engineer.class, "example2");
    ReadObjectTest test1b = new ReadObjectTest(person);
    test1b.setName("JoiningInheritanceRelationshipTest");
    ReadObjectQuery query1b = new ReadObjectQuery();
    query1b.setSelectionObject(person);
    query1b.addJoinedAttribute("bestFriend");
    query1b.addJoinedAttribute("representitive");
    test1b.setQuery(query1b);
    addTest(test1b);
    ReadObjectTest test1bx = new ReadObjectTest(person);
    test1bx.setName("NestedJoiningInheritanceRelationshipTest");
    ReadObjectQuery query1bx = new ReadObjectQuery();
    query1bx.setSelectionObject(person);
    query1bx.addJoinedAttribute(query1bx.getExpressionBuilder().get("bestFriend"));
    query1bx.addJoinedAttribute(query1bx.getExpressionBuilder().get("bestFriend").getAllowingNull("bestFriend"));
    query1bx.addJoinedAttribute(query1bx.getExpressionBuilder().get("bestFriend").getAllowingNull("representitive"));
    query1bx.addJoinedAttribute(query1bx.getExpressionBuilder().get("representitive"));
    test1bx.setQuery(query1bx);
    addTest(test1bx);
    ReadObjectTest test1c = new ReadObjectTest(object);
    test1c.setName("JoiningReadObjectTestAddressManagerManager");
    ReadObjectQuery query1c = new ReadObjectQuery();
    query1c.setSelectionObject(object);
    query1c.addJoinedAttribute("address");
    query1c.addJoinedAttribute("manager");
    query1c.addJoinedAttribute(query1c.getExpressionBuilder().get("manager").get("manager"));
    test1c.setQuery(query1c);
    addTest(test1c);
    ReadAllTest test2 = new ReadAllTest(Employee.class, 12);
    test2.setName("JoiningReadAllTestAddress");
    ReadAllQuery query2 = new ReadAllQuery();
    query2.setReferenceClass(Employee.class);
    query2.addJoinedAttribute("address");
    query2.addJoinedAttribute(query2.getExpressionBuilder().getAllowingNull("manager"));
    test2.setQuery(query2);
    addTest(test2);
    ReadAllTest testReadAll1m = new ReadAllTest(Employee.class, 12);
    testReadAll1m.setName("JoiningReadAllTestPhones");
    ReadAllQuery queryReadAll1m = new ReadAllQuery();
    queryReadAll1m.setReferenceClass(Employee.class);
    queryReadAll1m.addJoinedAttribute(queryReadAll1m.getExpressionBuilder().anyOf("phoneNumbers"));
    testReadAll1m.setQuery(queryReadAll1m);
    addTest(testReadAll1m);
    ReadAllTest testReadAll21m = new ReadAllTest(Employee.class, 5);
    testReadAll21m.setName("JoiningReadAllTestPhonesManagedEmployeesPhones");
    ReadAllQuery queryReadAll21m = new ReadAllQuery();
    queryReadAll21m.setReferenceClass(Employee.class);
    Expression managedEmployee = queryReadAll21m.getExpressionBuilder().anyOf("managedEmployees");
    queryReadAll21m.addJoinedAttribute(queryReadAll21m.getExpressionBuilder().anyOf("phoneNumbers"));
    queryReadAll21m.addJoinedAttribute(managedEmployee);
    queryReadAll21m.addJoinedAttribute(managedEmployee.anyOf("phoneNumbers"));
    testReadAll21m.setQuery(queryReadAll21m);
    addTest(testReadAll21m);
    ReadAllTest test2a = new ReadAllTest(Employee.class, 2);
    test2a.setName("JoiningReadAllTestWhereLastNameWay");
    ReadAllQuery query2a = new ReadAllQuery();
    query2a.setReferenceClass(Employee.class);
    query2a.addJoinedAttribute("address");
    query2a.setSelectionCriteria(new ExpressionBuilder().get("lastName").equal("Way"));
    test2a.setQuery(query2a);
    addTest(test2a);
    ReadObjectTest test2az = new ReadObjectTest(object);
    test2az.setName("JoiningReadObjectTestCustomSQL");
    ReadObjectQuery query2az = new ReadObjectQuery();
    query2az.setReferenceClass(Employee.class);
    query2az.addJoinedAttribute("address");
    query2az.setSQLString("Select * from EMPLOYEE E, SALARY S, ADDRESS A WHERE E.EMP_ID = S.EMP_ID AND E.ADDR_ID = A.ADDRESS_ID AND E.EMP_ID = " + object.getId());
    test2az.setQuery(query2az);
    addTest(test2az);
    ReadAllTest test2ax = new ReadAllTest(Employee.class, 2);
    test2ax.setName("JoiningReadAllTestCustomSQL");
    ReadAllQuery query2ax = new ReadAllQuery();
    query2ax.setReferenceClass(Employee.class);
    query2ax.addJoinedAttribute("address");
    query2ax.setSQLString("Select * from EMPLOYEE E, SALARY S, ADDRESS A WHERE E.EMP_ID = S.EMP_ID AND E.ADDR_ID = A.ADDRESS_ID AND E.L_NAME = 'Way'");
    test2ax.setQuery(query2ax);
    addTest(test2ax);
    ReadAllTest test2aa = new ReadAllTest(Employee.class, 2);
    test2aa.setName("JoiningReadAllTestWhereLastNameWay-cursor");
    ReadAllQuery query2aa = new ReadAllQuery();
    query2aa.setReferenceClass(Employee.class);
    query2aa.useCursoredStream();
    query2aa.addJoinedAttribute("address");
    query2aa.setSelectionCriteria(new org.eclipse.persistence.expressions.ExpressionBuilder().get("lastName").equal("Way"));
    test2aa.setQuery(query2aa);
    addTest(test2aa);
    ReadAllJoinReadingTest test2b = new ReadAllJoinReadingTest(3, "teamLeader-address");
    ReadAllQuery query2b = new ReadAllQuery();
    query2b.setReferenceClass(LargeProject.class);
    query2b.addJoinedAttribute(query2b.getExpressionBuilder().get("teamLeader"));
    query2b.addJoinedAttribute(query2b.getExpressionBuilder().get("teamLeader").get("address"));
    test2b.setQuery(query2b);
    addTest(test2b);
    ReadAllTest ownerTest = new ReadAllTest(ObjectA.class, 3);
    ownerTest.setName("JoinOwnerA-oneToOne-oneToMany");
    ReadAllQuery ownerQuery = new ReadAllQuery();
    ownerQuery.setReferenceClass(ObjectA.class);
    ownerQuery.addJoinedAttribute(ownerQuery.getExpressionBuilder().get("oneToOne"));
    ownerQuery.addJoinedAttribute(ownerQuery.getExpressionBuilder().get("oneToOne").anyOf("oneToMany"));
    ownerTest.setQuery(ownerQuery);
    addTest(ownerTest);
    ReadAllTest ownerTest3 = new ReadAllTest(ObjectA.class, 3);
    ownerTest3.setName("JoinOwnerA-oneToOne-oneToMany-oneToOne");
    ReadAllQuery ownerQuery3 = new ReadAllQuery();
    ownerQuery3.setReferenceClass(ObjectA.class);
    ownerQuery3.addJoinedAttribute(ownerQuery.getExpressionBuilder().get("oneToOne"));
    Expression join = ownerQuery.getExpressionBuilder().get("oneToOne").anyOf("oneToMany");
    ownerQuery3.addJoinedAttribute(join);
    ownerQuery3.addJoinedAttribute(join.get("oneToOne"));
    ownerTest3.setQuery(ownerQuery3);
    addTest(ownerTest3);
    ReadAllTest ownerTest2 = new ReadAllTest(ObjectA.class, 3);
    ownerTest2.setName("JoinOwnerA-oneToOne(mapping)");
    ReadAllQuery ownerQuery2 = new ReadAllQuery();
    ownerQuery2.setReferenceClass(ObjectA.class);
    ownerTest2.setQuery(ownerQuery2);
    addTest(ownerTest2);
    ReadAllTest test3 = new ReadAllTest(LargeProject.class, 3);
    ReadAllQuery query3 = new ReadAllQuery();
    query3.setReferenceClass(LargeProject.class);
    query3.useCursoredStream();
    query3.addJoinedAttribute(query3.getExpressionBuilder().get("teamLeader"));
    query3.addJoinedAttribute(query3.getExpressionBuilder().get("teamLeader").get("address"));
    test3.setQuery(query3);
    addTest(test3);
    addTest(new ReadObjectMappingJoinReadingTest());
    addTest(new MultipleJoinedAttributeQueryTest());
    addTest(new ComplexJoinedAttributeQueryTest());
}
Also used : org.eclipse.persistence.expressions(org.eclipse.persistence.expressions) PopulationManager(org.eclipse.persistence.tools.schemaframework.PopulationManager)

Example 87 with PopulationManager

use of org.eclipse.persistence.tools.schemaframework.PopulationManager in project eclipselink by eclipse-ee4j.

the class EmployeeBasicTestModel method getReadObjectTestSuite.

public static TestSuite getReadObjectTestSuite() {
    TestSuite suite = new TestSuite();
    suite.setName("EmployeeReadObjectTestSuite");
    suite.setDescription("This suite test the reading of each object in the employee demo.");
    Class<Employee> employeeClass = Employee.class;
    Class<LargeProject> largeProjectClass = LargeProject.class;
    Class<SmallProject> smallProjectClass = SmallProject.class;
    PopulationManager manager = PopulationManager.getDefaultManager();
    suite.addTest(new ReadObjectTest(manager.getObject(employeeClass, "0001")));
    suite.addTest(new ReadObjectTest(manager.getObject(employeeClass, "0002")));
    suite.addTest(new ReadObjectTest(manager.getObject(employeeClass, "0003")));
    suite.addTest(new ReadObjectTest(manager.getObject(employeeClass, "0004")));
    suite.addTest(new ReadObjectTest(manager.getObject(employeeClass, "0005")));
    suite.addTest(new ReadObjectTest(manager.getObject(smallProjectClass, "0001")));
    suite.addTest(new ReadObjectTest(manager.getObject(smallProjectClass, "0002")));
    suite.addTest(new ReadObjectTest(manager.getObject(smallProjectClass, "0003")));
    suite.addTest(new ReadObjectTest(manager.getObject(largeProjectClass, "0001")));
    suite.addTest(new ReadObjectTest(manager.getObject(largeProjectClass, "0002")));
    suite.addTest(new ReadObjectTest(manager.getObject(largeProjectClass, "0003")));
    return suite;
}
Also used : PopulationManager(org.eclipse.persistence.tools.schemaframework.PopulationManager)

Example 88 with PopulationManager

use of org.eclipse.persistence.tools.schemaframework.PopulationManager in project eclipselink by eclipse-ee4j.

the class EmployeeBasicTestModel method getDeleteObjectTestSuite.

public static TestSuite getDeleteObjectTestSuite() {
    TestSuite suite = new TestSuite();
    suite.setName("EmployeeDeleteObjectTestSuite");
    suite.setDescription("This suite tests the deletion of each object in the employee demo.");
    Class<Employee> employeeClass = Employee.class;
    Class<LargeProject> largeProjectClass = LargeProject.class;
    Class<SmallProject> smallProjectClass = SmallProject.class;
    PopulationManager manager = PopulationManager.getDefaultManager();
    suite.addTest(new DeleteObjectTest(manager.getObject(employeeClass, "0001")));
    suite.addTest(new DeleteObjectTest(manager.getObject(employeeClass, "0002")));
    suite.addTest(new DeleteObjectTest(manager.getObject(employeeClass, "0003")));
    suite.addTest(new DeleteObjectTest(manager.getObject(employeeClass, "0004")));
    suite.addTest(new DeleteObjectTest(manager.getObject(employeeClass, "0005")));
    suite.addTest(new DeleteObjectTest(manager.getObject(smallProjectClass, "0001")));
    suite.addTest(new DeleteObjectTest(manager.getObject(smallProjectClass, "0002")));
    suite.addTest(new DeleteObjectTest(manager.getObject(smallProjectClass, "0003")));
    suite.addTest(new DeleteObjectTest(manager.getObject(largeProjectClass, "0001")));
    suite.addTest(new DeleteObjectTest(manager.getObject(largeProjectClass, "0002")));
    suite.addTest(new DeleteObjectTest(manager.getObject(largeProjectClass, "0003")));
    return suite;
}
Also used : PopulationManager(org.eclipse.persistence.tools.schemaframework.PopulationManager)

Example 89 with PopulationManager

use of org.eclipse.persistence.tools.schemaframework.PopulationManager in project eclipselink by eclipse-ee4j.

the class EmployeeWeavingTestModel method getReadObjectTestSuite.

public TestSuite getReadObjectTestSuite() {
    TestSuite suite = new TestSuite();
    suite.setName("EmployeeWeavedReadObjectTestSuite");
    suite.setDescription("This suite test the reading of each object in the employee weaved performance model.");
    Class<Employee> employeeClass = Employee.class;
    Class<LargeProject> largeProjectClass = LargeProject.class;
    Class<SmallProject> smallProjectClass = SmallProject.class;
    PopulationManager manager = PopulationManager.getDefaultManager();
    suite.addTest(new ReadObjectTest(manager.getObject(employeeClass, "0001")));
    suite.addTest(new ReadObjectTest(manager.getObject(employeeClass, "0002")));
    suite.addTest(new ReadObjectTest(manager.getObject(employeeClass, "0003")));
    suite.addTest(new ReadObjectTest(manager.getObject(employeeClass, "0004")));
    suite.addTest(new ReadObjectTest(manager.getObject(employeeClass, "0005")));
    suite.addTest(new ReadObjectTest(manager.getObject(smallProjectClass, "0001")));
    suite.addTest(new ReadObjectTest(manager.getObject(smallProjectClass, "0002")));
    suite.addTest(new ReadObjectTest(manager.getObject(smallProjectClass, "0003")));
    suite.addTest(new ReadObjectTest(manager.getObject(largeProjectClass, "0001")));
    suite.addTest(new ReadObjectTest(manager.getObject(largeProjectClass, "0002")));
    suite.addTest(new ReadObjectTest(manager.getObject(largeProjectClass, "0003")));
    return suite;
}
Also used : PopulationManager(org.eclipse.persistence.tools.schemaframework.PopulationManager)

Aggregations

PopulationManager (org.eclipse.persistence.tools.schemaframework.PopulationManager)89 TestSuite (org.eclipse.persistence.testing.framework.TestSuite)37 Employee (org.eclipse.persistence.testing.models.employee.domain.Employee)16 LargeProject (org.eclipse.persistence.testing.models.employee.domain.LargeProject)11 SmallProject (org.eclipse.persistence.testing.models.employee.domain.SmallProject)11 ReadObjectTest (org.eclipse.persistence.testing.framework.ReadObjectTest)10 WriteObjectTest (org.eclipse.persistence.testing.framework.WriteObjectTest)8 Client (org.eclipse.persistence.testing.models.aggregate.Client)6 Employee (org.eclipse.persistence.testing.models.aggregate.Employee)6 SQLCall (org.eclipse.persistence.queries.SQLCall)5 Agent (org.eclipse.persistence.testing.models.aggregate.Agent)5 Builder (org.eclipse.persistence.testing.models.aggregate.Builder)5 EvaluationClient (org.eclipse.persistence.testing.models.aggregate.EvaluationClient)5 ComplexUpdateTest (org.eclipse.persistence.testing.tests.writing.ComplexUpdateTest)5 UpdateChangeNothingTest (org.eclipse.persistence.testing.tests.writing.UpdateChangeNothingTest)5 UpdateChangeObjectTest (org.eclipse.persistence.testing.tests.writing.UpdateChangeObjectTest)5 UpdateChangeValueTest (org.eclipse.persistence.testing.tests.writing.UpdateChangeValueTest)5 UpdateToNullTest (org.eclipse.persistence.testing.tests.writing.UpdateToNullTest)5 org.eclipse.persistence.testing.models.employee.domain (org.eclipse.persistence.testing.models.employee.domain)4 EmployeeDeleteTest (org.eclipse.persistence.testing.tests.employee.EmployeeDeleteTest)4