use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class CommitAfterExecuteModifyQueryDuringTransTest method test.
@Override
public void test() {
uow = getSession().acquireUnitOfWork();
uow.getEventManager().addListener(new SessionEventAdapter() {
@Override
public void prepareUnitOfWork(SessionEvent event) {
Vector myV = new Vector();
myV.addElement(employeesNewFirstName);
myV.addElement(initialVersionField);
myV.addElement(originalEmployee.lastName);
uow.executeQuery(dataModifyQuery, myV);
}
});
Employee temp = (Employee) uow.registerObject(cachedEmployee);
temp.firstName = "tempFirstName";
// no exceptions are expected, though transaction should not be commited if test fails:
uow.commit();
cachedEmployee = (Employee) getSession().refreshObject(cachedEmployee);
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class CommitUnitOfWorkAgainTest method test.
@Override
public void test() {
// Test CR#2189
UnitOfWork uow = getSession().acquireUnitOfWork();
Employee anEmployee = (Employee) uow.readObject(Employee.class);
anEmployee.setLastName("TOPLink");
uow.commit();
// If you try to commit again, it must throw a exception.[TOPLink-7068]
try {
anEmployee.setLastName("EclipseLink");
uow.commit();
throw new TestErrorException("UOW is not throwing an exception when it is committed for a second time.");
} catch (ValidationException exception) {
if (!(exception.getErrorCode() == ValidationException.CANNOT_COMMIT_UOW_AGAIN)) {
throw new TestErrorException("UOW is throwing exception " + exception.getErrorCode() + " instead of CANNOT_COMMIT_UOW_AGAIN when it is committed for a second time.");
}
}
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class ComplexMultipleUnitOfWorkTest method verify.
@Override
public void verify() {
getSession().getIdentityMapAccessor().initializeIdentityMaps();
Session sessionToVerifyDelete;
if (getSession() instanceof RemoteSession) {
sessionToVerifyDelete = RemoteModel.getServerSession();
} else {
sessionToVerifyDelete = getSession();
}
// Verify if object deleted in the uow was deleted
if (!(((AbstractSession) sessionToVerifyDelete).verifyDelete(this.readInSession))) {
throw new TestErrorException("The object '" + this.readInSession + "'deleted in the uow was not completely deleted from the database.");
}
// Verify if object deleted in the uow was deleted
if (!(((AbstractSession) sessionToVerifyDelete).verifyDelete(this.readInUow))) {
throw new TestErrorException("The object '" + this.readInUow + "'deleted in the nested uow was not completely deleted from the database.");
}
ReadObjectQuery query = new ReadObjectQuery();
query.setSelectionObject(this.newEmployeeInUow);
Employee objectFromDatabase = (Employee) getSession().executeQuery(query);
if (!(((AbstractSession) getSession()).compareObjects(this.newEmployeeInUow, objectFromDatabase))) {
throw new TestErrorException("The object read from the database, '" + this.newEmployeeInUow + "' does not match the originial, '" + objectFromDatabase + ".");
}
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class ComplexMultipleUnitOfWorkTest method createNewEmployeeObject.
public Employee createNewEmployeeObject() {
Employee employee = new org.eclipse.persistence.testing.models.employee.domain.Employee();
employee.setFirstName("Judy");
employee.setLastName("Barney");
employee.setMale();
employee.setSalary(35000);
employee.setPeriod(employmentPeriodExample());
employee.setAddress(addressExample1());
employee.addResponsibility("Make the coffee.");
employee.addResponsibility("Clean the kitchen.");
employee.addPhoneNumber(new org.eclipse.persistence.testing.models.employee.domain.PhoneNumber("Work", "613", "2258812"));
employee.addProject(smallProjectExample());
return employee;
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class ComplexMultipleUnitOfWorkTest method processThirdUnitOfWork.
public void processThirdUnitOfWork() {
this.thirdUnitOfWork = getSession().acquireUnitOfWork();
Employee workingCopy = (Employee) thirdUnitOfWork.registerObject(this.newEmployeeInUow);
changeObject(workingCopy, this.thirdUnitOfWork);
if (!((AbstractSession) getSession()).compareObjectsDontMatch(this.newEmployeeInUow, workingCopy)) {
throw new TestErrorException("The original object was changed through changing the clone.");
}
this.thirdUnitOfWork.commit();
}
Aggregations