Search in sources :

Example 1 with Project

use of org.eclipse.persistence.testing.models.employee.domain.Project in project eclipselink by eclipse-ee4j.

the class RollbackObjectsTest method test.

@Override
public void test() {
    org.eclipse.persistence.sessions.Session hs = getSession().acquireHistoricalSession(pastTime);
    pastObjects = hs.readAllObjects(domainClass);
    // getSession().getProject().checkDatabaseForDoesExist();
    Vector currentProjects = getSession().readAllObjects(Project.class);
    for (Enumeration enumtr = currentProjects.elements(); enumtr.hasMoreElements(); ) {
        ((Project) enumtr.nextElement()).getTeamLeader();
    }
    UnitOfWork uow = getSession().acquireUnitOfWork();
    for (Enumeration enumtr = pastObjects.elements(); enumtr.hasMoreElements(); ) {
        Employee emp = (Employee) enumtr.nextElement();
        emp.getProjects();
        for (Enumeration proj = emp.getProjects().elements(); proj.hasMoreElements(); ) {
            ((Project) proj.nextElement()).getTeamLeader();
        }
        emp.getAddress();
    }
    for (Enumeration enumtr = pastObjects.elements(); enumtr.hasMoreElements(); ) {
        Employee emp = (Employee) enumtr.nextElement();
        uow.registerObject(emp);
    }
    Vector pastProjects = hs.readAllObjects(Project.class);
    for (Enumeration enumtr = pastProjects.elements(); enumtr.hasMoreElements(); ) {
        Project project = (Project) enumtr.nextElement();
        uow.registerObject(project);
        uow.deepMergeClone(project);
    }
    // uow.registerAllObjects(pastProjects);
    // clone = uow.deepClone(obj);
    // } else {
    // clone = uow.deepMergeClone(obj);
    // }
    uow.commit();
}
Also used : Project(org.eclipse.persistence.testing.models.employee.domain.Project) UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) Employee(org.eclipse.persistence.testing.models.employee.domain.Employee)

Example 2 with Project

use of org.eclipse.persistence.testing.models.employee.domain.Project in project eclipselink by eclipse-ee4j.

the class EmployeeChangeFlagBasicTestModel 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 = org.eclipse.persistence.testing.models.employee.domain.Employee.class;
    Class<LargeProject> largeProjectClass = org.eclipse.persistence.testing.models.employee.domain.LargeProject.class;
    Class<SmallProject> smallProjectClass = org.eclipse.persistence.testing.models.employee.domain.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")));
    Employee employee = (Employee) manager.getObject(employeeClass, "0001");
    suite.addTest(new ReadObjectCallTest(employeeClass, new SQLCall("SELECT t0.VERSION, t1.EMP_ID, t0.L_NAME, t0.F_NAME, t1.SALARY, t0.EMP_ID, t0.GENDER, t0.END_DATE, t0.START_DATE, t0.MANAGER_ID, t0.END_TIME, t0.START_TIME, t0.ADDR_ID FROM EMPLOYEE t0, SALARY t1 WHERE t1.EMP_ID = t0.EMP_ID AND t0.F_NAME = '" + employee.getFirstName() + "' AND t0.L_NAME = '" + employee.getLastName() + "'")));
    employee = (Employee) manager.getObject(employeeClass, "0002");
    suite.addTest(new ReadObjectCallTest(employeeClass, new SQLCall("SELECT  t0.VERSION, t1.EMP_ID, t0.L_NAME, t0.F_NAME, t1.SALARY, t0.EMP_ID, t0.GENDER, t0.END_DATE, t0.START_DATE, t0.MANAGER_ID, t0.END_TIME, t0.START_TIME, t0.ADDR_ID FROM EMPLOYEE t0, SALARY t1 WHERE t1.EMP_ID = t0.EMP_ID AND t0.F_NAME = '" + employee.getFirstName() + "' AND t0.L_NAME = '" + employee.getLastName() + "'")));
    employee = (Employee) manager.getObject(employeeClass, "0003");
    suite.addTest(new ReadObjectCallTest(employeeClass, new SQLCall("SELECT  t0.VERSION, t1.EMP_ID, t0.L_NAME, t0.F_NAME, t1.SALARY, t0.EMP_ID, t0.GENDER, t0.END_DATE, t0.START_DATE, t0.MANAGER_ID, t0.END_TIME, t0.START_TIME, t0.ADDR_ID FROM EMPLOYEE t0, SALARY t1 WHERE t1.EMP_ID = t0.EMP_ID AND t0.F_NAME = '" + employee.getFirstName() + "' AND t0.L_NAME = '" + employee.getLastName() + "'")));
    org.eclipse.persistence.testing.models.employee.domain.Project project = (org.eclipse.persistence.testing.models.employee.domain.Project) manager.getObject(largeProjectClass, "0001");
    ReadObjectTest test = new ReadObjectTest(project);
    test.setQuery(new org.eclipse.persistence.queries.ReadObjectQuery(org.eclipse.persistence.testing.models.employee.domain.Project.class, new org.eclipse.persistence.expressions.ExpressionBuilder().get("id").equal(project.getId())));
    suite.addTest(test);
    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 : SQLCall(org.eclipse.persistence.queries.SQLCall) SmallProject(org.eclipse.persistence.testing.models.employee.domain.SmallProject) ReadObjectTest(org.eclipse.persistence.testing.framework.ReadObjectTest) ReadObjectCallTest(org.eclipse.persistence.testing.framework.ReadObjectCallTest) Project(org.eclipse.persistence.testing.models.employee.domain.Project) SmallProject(org.eclipse.persistence.testing.models.employee.domain.SmallProject) LargeProject(org.eclipse.persistence.testing.models.employee.domain.LargeProject) Employee(org.eclipse.persistence.testing.models.employee.domain.Employee) TestSuite(org.eclipse.persistence.testing.framework.TestSuite) Project(org.eclipse.persistence.testing.models.employee.domain.Project) PopulationManager(org.eclipse.persistence.tools.schemaframework.PopulationManager) LargeProject(org.eclipse.persistence.testing.models.employee.domain.LargeProject)

Example 3 with Project

use of org.eclipse.persistence.testing.models.employee.domain.Project in project eclipselink by eclipse-ee4j.

the class TransactionIsolationM2MBatchReadTest method verifyCloneHasSameProjectsAsOriginal.

private void verifyCloneHasSameProjectsAsOriginal(Vector clones, Vector originals) {
    strongAssert(clones.size() == originals.size(), "The clones collections was of a different size than the original. " + clones.size() + " instead of: " + originals.size());
    for (int i = 0; i < clones.size(); i++) {
        Project clone = (Project) clones.elementAt(i);
        boolean match = false;
        for (int j = 0; j < originals.size(); j++) {
            Project original = (Project) originals.elementAt(j);
            if (clone.getId().equals(original.getId())) {
                match = true;
                break;
            }
        }
        strongAssert(match, "The project's contents are different");
    }
}
Also used : Project(org.eclipse.persistence.testing.models.employee.domain.Project)

Example 4 with Project

use of org.eclipse.persistence.testing.models.employee.domain.Project in project eclipselink by eclipse-ee4j.

the class RelatedNewObjectNotSentTest method verify.

@Override
public void verify() {
    Employee distributedEmployee = (Employee) getObjectFromDistributedCache(employee);
    Address distributedAddress = (Address) getObjectFromDistributedCache(address);
    SmallProject distributedProject = (SmallProject) getObjectFromDistributedCache(project);
    if (!((AbstractSession) getSession()).compareObjects(distributedEmployee.getAddress(), employee.getAddress())) {
        throw new TestErrorException("The employee's address was not properly merged.  The new address " + "was not read into the distributed cache.");
    }
    distributedProject = null;
    boolean foundProject = false;
    Enumeration enumtr = distributedEmployee.getProjects().elements();
    while (enumtr.hasMoreElements() && !foundProject) {
        Project proj = (Project) enumtr.nextElement();
        if (((AbstractSession) getSession()).compareObjects(proj, project)) {
            foundProject = true;
        }
    }
    if (!foundProject) {
        throw new TestErrorException("The employee's small project was not properly merged.  The new small project " + "was not read into the distributed cache.");
    }
}
Also used : SmallProject(org.eclipse.persistence.testing.models.employee.domain.SmallProject) Project(org.eclipse.persistence.testing.models.employee.domain.Project) SmallProject(org.eclipse.persistence.testing.models.employee.domain.SmallProject) Employee(org.eclipse.persistence.testing.models.employee.domain.Employee) Enumeration(java.util.Enumeration) Address(org.eclipse.persistence.testing.models.employee.domain.Address) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) AbstractSession(org.eclipse.persistence.internal.sessions.AbstractSession)

Example 5 with Project

use of org.eclipse.persistence.testing.models.employee.domain.Project in project eclipselink by eclipse-ee4j.

the class SessionsXMLBasicTestModel method getSRGReadObjectTestSuite.

// SRG test set is maintained by QA only, do NOT add any new tests into it.
public static TestSuite getSRGReadObjectTestSuite() {
    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")));
    Project project = (Project) manager.getObject(largeProjectClass, "0001");
    ReadObjectTest test = new ReadObjectTest(project);
    test.setQuery(new org.eclipse.persistence.queries.ReadObjectQuery(Project.class, new org.eclipse.persistence.expressions.ExpressionBuilder().get("id").equal(project.getId())));
    suite.addTest(test);
    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 : SmallProject(org.eclipse.persistence.testing.models.employee.domain.SmallProject) ReadObjectTest(org.eclipse.persistence.testing.framework.ReadObjectTest) LargeProject(org.eclipse.persistence.testing.models.employee.domain.LargeProject) Project(org.eclipse.persistence.testing.models.employee.domain.Project) SmallProject(org.eclipse.persistence.testing.models.employee.domain.SmallProject) Employee(org.eclipse.persistence.testing.models.employee.domain.Employee) TestSuite(org.eclipse.persistence.testing.framework.TestSuite) PopulationManager(org.eclipse.persistence.tools.schemaframework.PopulationManager) LargeProject(org.eclipse.persistence.testing.models.employee.domain.LargeProject)

Aggregations

Project (org.eclipse.persistence.testing.models.employee.domain.Project)10 Employee (org.eclipse.persistence.testing.models.employee.domain.Employee)8 SmallProject (org.eclipse.persistence.testing.models.employee.domain.SmallProject)5 ReadObjectTest (org.eclipse.persistence.testing.framework.ReadObjectTest)3 TestSuite (org.eclipse.persistence.testing.framework.TestSuite)3 LargeProject (org.eclipse.persistence.testing.models.employee.domain.LargeProject)3 PopulationManager (org.eclipse.persistence.tools.schemaframework.PopulationManager)3 Expression (org.eclipse.persistence.expressions.Expression)2 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)2 Address (org.eclipse.persistence.testing.models.employee.domain.Address)2 Enumeration (java.util.Enumeration)1 HashMap (java.util.HashMap)1 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)1 VersionLockingPolicy (org.eclipse.persistence.descriptors.VersionLockingPolicy)1 AbstractSession (org.eclipse.persistence.internal.sessions.AbstractSession)1 ForeignReferenceMapping (org.eclipse.persistence.mappings.ForeignReferenceMapping)1 ReportQuery (org.eclipse.persistence.queries.ReportQuery)1 SQLCall (org.eclipse.persistence.queries.SQLCall)1 org.eclipse.persistence.sessions (org.eclipse.persistence.sessions)1 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)1