use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class NestedUnitOfWorkNewObjectWithIndirectionTest method setup.
@Override
public void setup() {
getAbstractSession().beginTransaction();
Employee emp = (Employee) new EmployeePopulator().basicEmployeeExample1();
original = (Employee) new EmployeePopulator().basicEmployeeExample2();
original.getManagedEmployees().add(emp);
emp.setManager(original);
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class NestedUnitOfWorkReadOnlyClassTest method test.
@Override
public void test() {
getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
// start root transaction
UnitOfWork rootUOW = getSession().acquireUnitOfWork();
Address addressRO = (Address) getSession().readObject(Address.class, new ExpressionBuilder().get("postalCode").equal(postalCode));
if (addressRO == null) {
throw new TestErrorException("Unable to find address.");
}
// start nested transaction
UnitOfWork nestedUOW = rootUOW.acquireUnitOfWork();
nestedUOW.addReadOnlyClass(Address.class);
Employee emp = (Employee) nestedUOW.registerObject(new Employee());
nestedUOW.assignSequenceNumber(emp);
emp.setFirstName("John");
emp.setAddress(addressRO);
nestedUOW.commit();
rootUOW.commit();
originalEmployee = emp;
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class NestedUnitOfWorkTest method changeUnitOfWorkWorkingCopy.
protected void changeUnitOfWorkWorkingCopy() {
Employee employee = (Employee) this.unitOfWorkWorkingCopy;
// Transformation
employee.setNormalHours(new java.sql.Time[2]);
employee.setStartTime(Helper.timeFromHourMinuteSecond(1, 1, 1));
employee.setEndTime(Helper.timeFromHourMinuteSecond(1, 1, 1));
// Aggregate
employee.setPeriod(new EmploymentPeriod(Helper.dateFromYearMonthDate(1901, 1, 1), Helper.dateFromYearMonthDate(1902, 2, 2)));
// One to many private
employee.setPhoneNumbers(new Vector());
employee.addPhoneNumber(new PhoneNumber("home", "613", "2263374"));
employee.addPhoneNumber(new PhoneNumber("office", "416", "8224599"));
// Many to many
employee.setProjects(new Vector());
employee.addProject((Project) this.unitOfWork.readObject(SmallProject.class));
employee.addProject((Project) this.unitOfWork.readObject(LargeProject.class));
// Direct collection
employee.setResponsibilitiesList(new Vector());
employee.addResponsibility("make coffee");
employee.addResponsibility("buy donuts");
// One to one private/public
employee.setAddress(new Address());
// make sure that the employee is not his own manager
employee.setManager((Employee) this.unitOfWork.readObject(Employee.class, (new ExpressionBuilder()).get("id").notEqual(employee.getId())));
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class MergeUnitOfWorkTest method verify.
/**
* Verify if the objects match completely through allowing the session to use the descriptors.
* This will compare the objects and all of their privately owned parts.
*/
@Override
protected void verify() {
boolean found = false;
Employee employeeToBeWritten = new org.eclipse.persistence.testing.models.employee.domain.Employee();
Enumeration enumeration = ((Employee) this.objectToBeWritten).getManagedEmployees().elements();
while ((!found) && (enumeration.hasMoreElements())) {
Employee employee = (Employee) enumeration.nextElement();
if (employee.getFirstName() == "New Man") {
employeeToBeWritten = employee;
found = true;
}
}
this.compareForProperMerge((Employee) this.objectBeforeMerge, employeeToBeWritten);
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class MergeUnitOfWorkTest method changeUnitOfWorkWorkingCopy.
protected void changeUnitOfWorkWorkingCopy() {
Employee employee = (Employee) this.unitOfWorkWorkingCopy;
Employee managedEmployee = (Employee) employee.getManagedEmployees().firstElement();
Employee newEmployee;
newEmployee = (Employee) unitOfWork.registerObject(new Employee());
newEmployee.setNormalHours(employee.getNormalHours());
newEmployee.setPeriod((EmploymentPeriod) employee.getPeriod().clone());
newEmployee.setAddress(managedEmployee.getAddress());
newEmployee.setFirstName("New Man");
newEmployee.setLastName("Smith");
employee.addManagedEmployee(newEmployee);
this.setObjectBeforeMerge(newEmployee);
}
Aggregations