Search in sources :

Example 1 with Computer

use of org.eclipse.persistence.testing.models.aggregate.Computer 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 2 with Computer

use of org.eclipse.persistence.testing.models.aggregate.Computer 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 3 with Computer

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

Aggregations

Computer (org.eclipse.persistence.testing.models.aggregate.Computer)3 ProjectDescription (org.eclipse.persistence.testing.models.aggregate.ProjectDescription)3 Employee (org.eclipse.persistence.testing.models.aggregate.Employee)1 Language (org.eclipse.persistence.testing.models.aggregate.Language)1 Responsibility (org.eclipse.persistence.testing.models.aggregate.Responsibility)1