Search in sources :

Example 1 with ProjectDescription

use of org.eclipse.persistence.testing.models.aggregate.ProjectDescription in project eclipselink by eclipse-ee4j.

the class MergingUnitOfWorkTest method changeWorkingCopy1.

protected void changeWorkingCopy1() {
    (this.workingCopy1).setFirstName("Kevin");
    ProjectDescription projectDescription = (this.workingCopy1).getProjectDescription();
    projectDescription.setDescription("Quality Assurance project");
    ((Vector) projectDescription.getResponsibilities().getValue()).removeElement(((Vector) projectDescription.getResponsibilities().getValue()).firstElement());
    ((Vector) projectDescription.getResponsibilities().getValue()).addElement(Responsibility.example1(this.workingCopy1));
    ((Vector) projectDescription.getResponsibilities().getValue()).addElement(Responsibility.example2(this.workingCopy1));
    ((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("Commodore 64");
}
Also used : ProjectDescription(org.eclipse.persistence.testing.models.aggregate.ProjectDescription)

Example 2 with ProjectDescription

use of org.eclipse.persistence.testing.models.aggregate.ProjectDescription in project eclipselink by eclipse-ee4j.

the class MergingUnitOfWorkTest method standardMergeWorkingCopies.

protected void standardMergeWorkingCopies() {
    // Everything except languages should have changed
    this.unitOfWork2 = getSession().acquireUnitOfWork();
    this.workingCopy2 = (Employee) this.unitOfWork2.registerObject(this.originalObject);
    this.mergedCopy = (Employee) this.unitOfWork2.mergeClone(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("Standard Merge did not merge changes in Employee.");
    }
    if (projectDescription.getDescription() != "Quality Assurance project") {
        throw new TestErrorException("Standard Merge did not merge changes in ProjectDescription (Aggregate mapping).");
    }
    if (responsibilities.size() != this.workingCopy1.getProjectDescription().getResponsibilities().getValue().size()) {
        throw new TestErrorException("Standard Merge did not merge changes in Responsibility (private 1:M).");
    }
    if (languages.size() == this.workingCopy1.getProjectDescription().getLanguages().getValue().size()) {
        throw new TestErrorException("Standard Merge merged changes in Language (public M:M) but shouldn't have.");
    }
    if (computer.getDescription() != "Commodore 64") {
        throw new TestErrorException("Standard Merge did not merge changes in Computer (private 1:1).");
    }
}
Also used : Computer(org.eclipse.persistence.testing.models.aggregate.Computer) ProjectDescription(org.eclipse.persistence.testing.models.aggregate.ProjectDescription)

Example 3 with ProjectDescription

use of org.eclipse.persistence.testing.models.aggregate.ProjectDescription in project eclipselink by eclipse-ee4j.

the class CheckForNullUnitOfWorkTest method changeUnitOfWorkWorkingCopy.

protected void changeUnitOfWorkWorkingCopy() {
    Employee employee = (Employee) this.unitOfWorkWorkingCopy;
    AddressDescription addressDescription = employee.getAddressDescription();
    ProjectDescription projectDescription = employee.getProjectDescription();
    Language language;
    Vector languages;
    // Root object changed
    employee.setFirstName(null);
    employee.setLastName(null);
    // Third level aggregate object changed
    addressDescription.setPeriodDescription(null);
    // 1 to 1 mapped object changed
    projectDescription.getComputer().setValue(null);
    // 1 level aggregate's 1:M mapping
    projectDescription.getResponsibilities().setValue(null);
    languages = (Vector) projectDescription.getLanguages().getValue();
    language = (Language) languages.firstElement();
    language.setLanguage(null);
// 1 level aggregate's M:M mapping, adding a new element
// languages.addElement(null);
}
Also used : Employee(org.eclipse.persistence.testing.models.aggregate.Employee) Language(org.eclipse.persistence.testing.models.aggregate.Language) AddressDescription(org.eclipse.persistence.testing.models.aggregate.AddressDescription) ProjectDescription(org.eclipse.persistence.testing.models.aggregate.ProjectDescription)

Example 4 with ProjectDescription

use of org.eclipse.persistence.testing.models.aggregate.ProjectDescription 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.");
    }
}
Also used : Employee(org.eclipse.persistence.testing.models.aggregate.Employee) Language(org.eclipse.persistence.testing.models.aggregate.Language) Computer(org.eclipse.persistence.testing.models.aggregate.Computer) Responsibility(org.eclipse.persistence.testing.models.aggregate.Responsibility) ProjectDescription(org.eclipse.persistence.testing.models.aggregate.ProjectDescription)

Example 5 with ProjectDescription

use of org.eclipse.persistence.testing.models.aggregate.ProjectDescription 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());
}
Also used : Employee(org.eclipse.persistence.testing.models.aggregate.Employee) Language(org.eclipse.persistence.testing.models.aggregate.Language) AddressDescription(org.eclipse.persistence.testing.models.aggregate.AddressDescription) Responsibility(org.eclipse.persistence.testing.models.aggregate.Responsibility) ProjectDescription(org.eclipse.persistence.testing.models.aggregate.ProjectDescription)

Aggregations

ProjectDescription (org.eclipse.persistence.testing.models.aggregate.ProjectDescription)8 Employee (org.eclipse.persistence.testing.models.aggregate.Employee)4 Language (org.eclipse.persistence.testing.models.aggregate.Language)4 AddressDescription (org.eclipse.persistence.testing.models.aggregate.AddressDescription)3 Computer (org.eclipse.persistence.testing.models.aggregate.Computer)3 Responsibility (org.eclipse.persistence.testing.models.aggregate.Responsibility)3