Search in sources :

Example 1 with Employee

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

the class AggregateTestModel method getSRGReadObjectTestSuite.

// SRG test set is maintained by QA only, do NOT add any new tests into it.
public static TestSuite getSRGReadObjectTestSuite() {
    TestSuite suite = new TestSuite();
    suite.setName("AggregateReadObjectTestSuite");
    suite.setDescription("This suite test the reading of each object in the aggregate model.");
    // =====================================
    Class<Employee1> employee1Class = Employee1.class;
    // ======================================
    Class<Employee> employeeClass = Employee.class;
    Class<Client> clientClass = Client.class;
    Class<EvaluationClient> evaluationClientClass = EvaluationClient.class;
    PopulationManager manager = PopulationManager.getDefaultManager();
    // ===============================================================================
    suite.addTest(new ReadObjectTest(manager.getObject(employee1Class, "example1")));
    suite.addTest(new ReadObjectTest(manager.getObject(employee1Class, "example2")));
    // ==================================================================================
    suite.addTest(new ReadObjectTest(manager.getObject(employeeClass, "example1")));
    suite.addTest(new ReadObjectTest(manager.getObject(employeeClass, "example2")));
    suite.addTest(new ReadObjectTest(manager.getObject(employeeClass, "example3")));
    suite.addTest(new ReadObjectTest(manager.getObject(clientClass, "example1")));
    suite.addTest(new ReadObjectTest(manager.getObject(clientClass, "example2")));
    suite.addTest(new ReadObjectTest(manager.getObject(clientClass, "example3")));
    suite.addTest(new ReadObjectTest(manager.getObject(evaluationClientClass, "example1")));
    suite.addTest(new ReadObjectTest(manager.getObject(evaluationClientClass, "example2")));
    suite.addTest(new ReadObjectTest(manager.getObject(evaluationClientClass, "example3")));
    // aggregate collection read
    suite.addTest(new ReadObjectTest(manager.getObject(Agent.class, "example1")));
    if (useNewAggregateCollection) {
        suite.addTest(new ReadObjectTest(manager.getObject(Builder.class, "example1")));
    }
    return suite;
}
Also used : Employee(org.eclipse.persistence.testing.models.aggregate.Employee) TestSuite(org.eclipse.persistence.testing.framework.TestSuite) PopulationManager(org.eclipse.persistence.tools.schemaframework.PopulationManager) EvaluationClient(org.eclipse.persistence.testing.models.aggregate.EvaluationClient) Client(org.eclipse.persistence.testing.models.aggregate.Client) EvaluationClient(org.eclipse.persistence.testing.models.aggregate.EvaluationClient) ReadObjectTest(org.eclipse.persistence.testing.framework.ReadObjectTest) Employee1(org.eclipse.persistence.testing.models.aggregate.Employee1)

Example 2 with Employee

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

the class AggregateTestModel method getSRGDeleteObjectTestSuite.

// SRG test set is maintained by QA only, do NOT add any new tests into it.
public static TestSuite getSRGDeleteObjectTestSuite() {
    TestSuite suite = new TestSuite();
    suite.setName("AggregateDeleteObjectTestSuite");
    suite.setDescription("This suite tests the deletion of each object in the aggregate model.");
    Class<Employee> employeeClass = Employee.class;
    Class<Client> clientClass = Client.class;
    Class<EvaluationClient> evaluationClientClass = EvaluationClient.class;
    PopulationManager manager = PopulationManager.getDefaultManager();
    suite.addTest(new DeleteObjectTest(manager.getObject(employeeClass, "example1")));
    suite.addTest(new DeleteObjectTest(manager.getObject(employeeClass, "example2")));
    suite.addTest(new DeleteObjectTest(manager.getObject(employeeClass, "example3")));
    suite.addTest(new DeleteObjectTest(manager.getObject(clientClass, "example1")));
    suite.addTest(new DeleteObjectTest(manager.getObject(clientClass, "example2")));
    suite.addTest(new DeleteObjectTest(manager.getObject(clientClass, "example3")));
    suite.addTest(new DeleteObjectTest(manager.getObject(evaluationClientClass, "example1")));
    suite.addTest(new DeleteObjectTest(manager.getObject(evaluationClientClass, "example2")));
    suite.addTest(new DeleteObjectTest(manager.getObject(evaluationClientClass, "example3")));
    // aggregate 1:m delete test
    suite.addTest(new DeleteObjectTest(manager.getObject(Agent.class, "example1")));
    suite.addTest(new VerifyCascadeDelete(Agent.class));
    suite.addTest(new AggregateCollectionClearTest(Agent.class));
    if (useNewAggregateCollection) {
        suite.addTest(new DeleteObjectTest(manager.getObject(Builder.class, "example1")));
        suite.addTest(new VerifyCascadeDelete(Builder.class));
        suite.addTest(new AggregateCollectionClearTest(Builder.class));
    }
    return suite;
}
Also used : Agent(org.eclipse.persistence.testing.models.aggregate.Agent) Builder(org.eclipse.persistence.testing.models.aggregate.Builder) DeleteObjectTest(org.eclipse.persistence.testing.framework.DeleteObjectTest) Employee(org.eclipse.persistence.testing.models.aggregate.Employee) TestSuite(org.eclipse.persistence.testing.framework.TestSuite) PopulationManager(org.eclipse.persistence.tools.schemaframework.PopulationManager) EvaluationClient(org.eclipse.persistence.testing.models.aggregate.EvaluationClient) Client(org.eclipse.persistence.testing.models.aggregate.Client) EvaluationClient(org.eclipse.persistence.testing.models.aggregate.EvaluationClient)

Example 3 with Employee

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

the class AggregateTestModel method getSRGUnitOfWorkTestSuite.

// SRG test set is maintained by QA only, do NOT add any new tests into it.
public static TestSuite getSRGUnitOfWorkTestSuite() {
    TestSuite suite = new TestSuite();
    suite.setName("AggregateUnitOfWorkTestSuite");
    suite.setDescription("This suite tests updating objects with UOW in the aggregate model.");
    Class<Employee> employeeClass = Employee.class;
    Class<Client> clientClass = Client.class;
    PopulationManager manager = PopulationManager.getDefaultManager();
    suite.addTest(new UnitOfWorkTest(manager.getObject(employeeClass, "example1")));
    suite.addTest(new UnitOfWorkTest(manager.getObject(employeeClass, "example2")));
    suite.addTest(new UnitOfWorkTest(manager.getObject(employeeClass, "example3")));
    /*    suite.addTest(new DeletionUnitOfWorkTest(manager.getObject(clientClass, "example1")));
            suite.addTest(new DeleteObjectTest(manager.getObject(clientClass, "example2")));
            suite.addTest(new DeleteObjectTest(manager.getObject(clientClass, "example3"))); */
    // aggregate collection UoW test
    suite.addTest(new AggregateCollectionUoWTest(manager.getObject(Agent.class, "example1")));
    suite.addTest(new AggregateCollectionMultipleUoWTest(manager.getObject(Agent.class, "example1")));
    // aggregate with transformation mapping test
    suite.addTest(new TransformationMappingTest());
    // For CR#2285, handle adding nulls to a collection.
    suite.addTest(new AddNullToAggregateCollectionTest((Agent) manager.getObject(Agent.class, "example1")));
    if (useNewAggregateCollection) {
        suite.addTest(new AggregateCollectionUoWTest(manager.getObject(Builder.class, "example1")));
        suite.addTest(new AggregateCollectionMultipleUoWTest(manager.getObject(Builder.class, "example1")));
        suite.addTest(new AddNullToAggregateCollectionTest((Builder) manager.getObject(Builder.class, "example1")));
    }
    return suite;
}
Also used : Agent(org.eclipse.persistence.testing.models.aggregate.Agent) Builder(org.eclipse.persistence.testing.models.aggregate.Builder) Employee(org.eclipse.persistence.testing.models.aggregate.Employee) TestSuite(org.eclipse.persistence.testing.framework.TestSuite) PopulationManager(org.eclipse.persistence.tools.schemaframework.PopulationManager) Client(org.eclipse.persistence.testing.models.aggregate.Client) EvaluationClient(org.eclipse.persistence.testing.models.aggregate.EvaluationClient)

Example 4 with Employee

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

use of org.eclipse.persistence.testing.models.aggregate.Employee 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)

Aggregations

Employee (org.eclipse.persistence.testing.models.aggregate.Employee)11 TestSuite (org.eclipse.persistence.testing.framework.TestSuite)6 PopulationManager (org.eclipse.persistence.tools.schemaframework.PopulationManager)6 Client (org.eclipse.persistence.testing.models.aggregate.Client)5 EvaluationClient (org.eclipse.persistence.testing.models.aggregate.EvaluationClient)5 AddressDescription (org.eclipse.persistence.testing.models.aggregate.AddressDescription)4 Language (org.eclipse.persistence.testing.models.aggregate.Language)4 ProjectDescription (org.eclipse.persistence.testing.models.aggregate.ProjectDescription)4 Agent (org.eclipse.persistence.testing.models.aggregate.Agent)3 Builder (org.eclipse.persistence.testing.models.aggregate.Builder)3 Responsibility (org.eclipse.persistence.testing.models.aggregate.Responsibility)3 Employee1 (org.eclipse.persistence.testing.models.aggregate.Employee1)2 Vector (java.util.Vector)1 DescriptorEvent (org.eclipse.persistence.descriptors.DescriptorEvent)1 DeleteObjectTest (org.eclipse.persistence.testing.framework.DeleteObjectTest)1 ReadObjectTest (org.eclipse.persistence.testing.framework.ReadObjectTest)1 UnitOfWorkBasicUpdateObjectTest (org.eclipse.persistence.testing.framework.UnitOfWorkBasicUpdateObjectTest)1 WriteObjectTest (org.eclipse.persistence.testing.framework.WriteObjectTest)1 AggregateEventListener (org.eclipse.persistence.testing.models.aggregate.AggregateEventListener)1 Computer (org.eclipse.persistence.testing.models.aggregate.Computer)1