use of org.eclipse.persistence.testing.models.aggregate.ProjectDescription in project eclipselink by eclipse-ee4j.
the class UnitOfWorkCommitResumeTest method changeUnitOfWorkWorkingCopy.
/**
* Change the working copy of the object. Add a suffix to the changes.
* Make sure the suffix is so long that it will be longer that the size of
* the field in the database.
*/
protected void changeUnitOfWorkWorkingCopy() {
Employee employee = (Employee) this.unitOfWorkWorkingCopy;
AddressDescription addressDescription = employee.getAddressDescription();
ProjectDescription projectDescription = employee.getProjectDescription();
Responsibility responsibility = Responsibility.example6(employee);
Vector responsibilities;
Vector languages;
Language language;
String suffix = (Integer.valueOf(changeVersion)).toString();
// Root object changed
employee.setFirstName("First " + suffix);
employee.setLastName("Last " + suffix);
// First level aggregate object changed
projectDescription.setDescription("ProjectDescription's Description changed" + suffix);
// Third level aggregate object changed
addressDescription.getPeriodDescription().getPeriod().setEndDate(Helper.dateFromYearMonthDate(1900 + ((changeVersion + 1975) % 2500), (changeVersion % 12) + 1, (changeVersion % 28) + 1));
addressDescription.getAddress().getValue().setAddress(suffix + " Any Street");
// 1 to 1 mapped object changed
projectDescription.getComputer().getValue().setDescription("Vic 20");
// 1 level aggregate's 1:M mapping, removing an element
responsibility.setResponsibility("Changed Reponsibility" + suffix);
responsibilities = (Vector) projectDescription.getResponsibilities().getValue();
responsibilities.removeElement(responsibilities.firstElement());
// 1 level aggregate's 1:M mapping, adding a new element
responsibilities.addElement(responsibility);
// 1 level aggregate's M:M mapping, removing an element
languages = (Vector) projectDescription.getLanguages().getValue();
languages.removeElement(languages.firstElement());
// 1 level aggregate's M:M mapping, modifying an element
language = (Language) languages.firstElement();
language.setLanguage("ModifiedLanguage" + suffix);
// 1 level aggregate's M:M mapping, adding a new element
languages.addElement(Language.example7());
// Update the change version.
changeVersion++;
}
use of org.eclipse.persistence.testing.models.aggregate.ProjectDescription in project eclipselink by eclipse-ee4j.
the class MergingUnitOfWorkTest method shallowMergeWorkingCopies.
protected void shallowMergeWorkingCopies() {
// Only Employee.firstName should have changed
this.unitOfWork2 = getSession().acquireUnitOfWork();
this.workingCopy2 = (Employee) this.unitOfWork2.registerObject(this.originalObject);
this.mergedCopy = (Employee) this.unitOfWork2.shallowMergeClone(workingCopy1);
ProjectDescription projectDescription = this.mergedCopy.getProjectDescription();
Vector responsibilities = (Vector) projectDescription.getResponsibilities().getValue();
Vector languages = (Vector) projectDescription.getLanguages().getValue();
Computer computer = projectDescription.getComputer().getValue();
if (this.mergedCopy.getFirstName() != "Kevin") {
throw new TestErrorException("Shallow Merge did not merge changes in Employee.");
}
if (projectDescription.getDescription() != "Quality Assurance project") {
throw new TestErrorException("Shallow Merge merged changes in ProjectDescription (Aggregate mapping) but shouldn't have.");
}
if (responsibilities.size() == this.workingCopy1.getProjectDescription().getResponsibilities().getValue().size()) {
throw new TestErrorException("Shallow Merge merged changes in Responsibility (private 1:M) but shouldn't have.");
}
if (languages.size() == this.workingCopy1.getProjectDescription().getLanguages().getValue().size()) {
throw new TestErrorException("Shallow Merge merged changes in Language (public M:M) but shouldn't have.");
}
if (computer.getDescription() == "Commodore 64") {
throw new TestErrorException("Shallow Merge merged changes in Computer (private 1:1) but shouldn't have.");
}
}
use of org.eclipse.persistence.testing.models.aggregate.ProjectDescription in project eclipselink by eclipse-ee4j.
the class DescriptorRefreshCacheTest method changeObject.
protected void changeObject(Employee employee) {
employee.setFirstName("Zack");
ProjectDescription projectDescription = employee.getProjectDescription();
projectDescription.setDescription("FBI Project");
((Vector) projectDescription.getResponsibilities().getValue()).removeElement(((Vector) projectDescription.getResponsibilities().getValue()).firstElement());
((Vector) projectDescription.getResponsibilities().getValue()).addElement(Responsibility.example1(employee));
((Vector) projectDescription.getResponsibilities().getValue()).addElement(Responsibility.example2(employee));
((Vector) projectDescription.getLanguages().getValue()).removeElement(((Vector) projectDescription.getLanguages().getValue()).firstElement());
((Vector) projectDescription.getLanguages().getValue()).addElement(Language.example1());
((Vector) projectDescription.getLanguages().getValue()).addElement(Language.example2());
projectDescription.getComputer().getValue().setDescription("Newton");
}
Aggregations