use of org.eclipse.persistence.testing.models.aggregate.Responsibility in project eclipselink by eclipse-ee4j.
the class DescriptorRefreshCacheTest method test.
@Override
public void test() {
Employee originalState = (Employee) this.objectFromDatabase;
String originalFirstName = originalState.getFirstName();
String originalProjectDescription = originalState.getProjectDescription().getDescription();
Vector originalResponsibilities = (Vector) ((Vector) originalState.getProjectDescription().getResponsibilities().getValue()).clone();
Vector originalLanguages = (Vector) ((Vector) originalState.getProjectDescription().getLanguages().getValue()).clone();
Computer originalComputer = originalState.getProjectDescription().getComputer().getValue();
String originalComputerDescription = originalComputer.getDescription();
changeObject(originalState);
Employee employee = (Employee) getSession().readObject(originalState);
if (employee != originalState) {
throw new TestErrorException("Always refresh cache does not work.");
}
if (originalComputer != employee.getProjectDescription().getComputer().getValue()) {
throw new TestErrorException("Always refresh cache does not work.");
}
for (Enumeration enumtr = originalResponsibilities.elements(); enumtr.hasMoreElements(); ) {
Responsibility responsibility = (Responsibility) enumtr.nextElement();
if (!employee.getProjectDescription().getResponsibilities().getValue().contains(responsibility)) {
throw new TestErrorException("Always refresh cache does not work.");
}
}
for (Enumeration enumtr = originalLanguages.elements(); enumtr.hasMoreElements(); ) {
Language language = (Language) enumtr.nextElement();
if (!employee.getProjectDescription().getLanguages().getValue().contains(language)) {
throw new TestErrorException("Always refresh cache does not work.");
}
}
ProjectDescription projectDescription = employee.getProjectDescription();
Vector responsibilities = (Vector) projectDescription.getResponsibilities().getValue();
Vector languages = (Vector) projectDescription.getLanguages().getValue();
Computer computer = projectDescription.getComputer().getValue();
if (!employee.getFirstName().equals(originalFirstName)) {
throw new TestErrorException("Always refresh cache does not work.");
}
if (!projectDescription.getDescription().equals(originalProjectDescription)) {
throw new TestErrorException("Always refresh cache does not work.");
}
if (responsibilities.size() != originalResponsibilities.size()) {
throw new TestErrorException("Always refresh cache does not work.");
}
if (languages.size() != originalLanguages.size()) {
throw new TestErrorException("Always refresh cache does not work.");
}
if (!computer.getDescription().equals(originalComputerDescription)) {
throw new TestErrorException("Always refresh cache does not work.");
}
}
use of org.eclipse.persistence.testing.models.aggregate.Responsibility in project eclipselink by eclipse-ee4j.
the class UnitOfWorkTest method changeUnitOfWorkWorkingCopy.
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;
// Root object changed
employee.setFirstName("ChangedFirstName");
employee.setLastName("ChangedLastName");
// First lever aggregate object changed
projectDescription.setDescription("ProjectDescription's Description changed");
// Third level aggregate object changed
addressDescription.getPeriodDescription().getPeriod().setEndDate(Helper.dateFromYearMonthDate(1995, 2, 1));
// 1 to 1 mapped object changed
projectDescription.getComputer().setValue(null);
// 1 level aggregate's 1:M mapping, removing an element
responsibility.setResponsibility("Changed Reponsibility");
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");
// 1 level aggregate's M:M mapping, adding a new element
languages.addElement(Language.example7());
}
use of org.eclipse.persistence.testing.models.aggregate.Responsibility 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++;
}
Aggregations