use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class QueryOptionTestSuite method buildReadOnlyTest.
/**
* Test the read-only query option.
*/
public TestCase buildReadOnlyTest() {
TestCase test = new TestCase() {
@Override
public void test() {
UnitOfWork uow = getSession().acquireUnitOfWork();
Employee employee = (Employee) uow.executeQuery("readOnlyQuery", Employee.class);
if (employee != getSession().readObject(employee)) {
throwError("Read-only option not used, employee registered in the unit of work.");
}
}
};
test.setName("ReadOnlyTest");
test.setDescription("Test the read-only query option in named queries.");
return test;
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class MemoryQueryReturnNotConfirmedTest method setup.
@Override
public void setup() {
getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
queryAll = (ReadAllQuery) getSession().getDescriptor(org.eclipse.persistence.testing.models.employee.domain.Employee.class).getQueryManager().getQuery("memoryQueryReturnNotConfirmedQuery");
allEmployees = (Vector) getSession().executeQuery(queryAll);
queryObject = new ReadObjectQuery(Employee.class);
queryObject.setSelectionCriteria(new ExpressionBuilder().get("address").get("city").notEqual("Montreal"));
employee = (Employee) getSession().executeQuery(queryObject);
if (employee != null) {
employee.getAddress();
}
// queryObject = new ReadObjectQuery(Employee.class);
queryObject.setSelectionCriteria(new ExpressionBuilder().get("address").get("city").equal("Montreal"));
employee = (Employee) getSession().executeQuery(queryObject);
if (employee != null) {
employee.getAddress();
}
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class ReportQueryAndExistsSubQueryWithWhereClause method setup.
@Override
protected void setup() throws Exception {
if (getSession().isRemoteSession()) {
throwWarning("Report queries with objects are not supported on remote session.");
}
super.setup();
reportQuery = new ReportQuery(Employee.class, new ExpressionBuilder());
ExpressionBuilder builder = reportQuery.getExpressionBuilder();
reportQuery.addAttribute("employee", builder);
ReportQuery innerQuery = new ReportQuery(Employee.class, new ExpressionBuilder());
innerQuery.addAttribute("areaCode", builder.anyOf("phoneNumbers").get("areaCode"));
Expression innerExp = builder.anyOf("phoneNumbers").get("areaCode").like("613");
innerQuery.setSelectionCriteria(innerExp);
Expression exists = builder.exists(innerQuery);
reportQuery.setSelectionCriteria(exists);
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class AllChangeSetsTest method test.
@Override
public void test() {
UnitOfWork uow = getSession().acquireUnitOfWork();
Vector employees = uow.readAllObjects(Employee.class);
// let's require at least 5 object
if (employees.size() <= 4) {
throw new TestProblemException("only " + employees.size() + " employees were read, need at least 5");
}
// Existing object has changed - should be counted
Employee emp = (Employee) employees.firstElement();
emp.setFirstName("Changed");
changedObjectsCount++;
Address add = emp.getAddress();
if (emp.getAddress() != null) {
// Existing object has changed - should be counted
add.setCity("Changed");
changedObjectsCount++;
}
// New object - should be counted
Employee newEmp = new Employee();
Employee newEmpClone = (Employee) uow.registerObject(newEmp);
newEmpClone.setFirstName("New");
changedObjectsCount++;
Iterator it = emp.getPhoneNumbers().iterator();
while (it.hasNext()) {
PhoneNumber phone = (PhoneNumber) it.next();
// to force reading the phone in and therefore registering in uow
// Registered but not changed - should NOT be counted
String code = phone.getAreaCode();
}
// forcedUpdate with false - should NOT be counted (doesn't affect cache)
Employee emp1 = (Employee) employees.elementAt(1);
uow.forceUpdateToVersionField(emp1, false);
// forcedUpdate with true - should be counted
Employee emp2 = (Employee) employees.elementAt(2);
uow.forceUpdateToVersionField(emp2, true);
changedObjectsCount++;
uow.commit();
}
use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.
the class BuildCloneFromRowOneToOneTest method createNewManagerObject.
public Employee createNewManagerObject() {
Employee employee = new org.eclipse.persistence.testing.models.employee.domain.Employee();
employee.setFirstName("Markus" + System.currentTimeMillis());
employee.setLastName("Markson");
employee.setMale();
employee.setSalary(35000);
employee.setPeriod(employmentPeriodExample());
return employee;
}
Aggregations