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();
}
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;
}
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");
}
}
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.");
}
}
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;
}
Aggregations