Search in sources :

Example 1 with AggregateMapKey

use of org.eclipse.persistence.testing.models.collections.map.AggregateMapKey in project eclipselink by eclipse-ee4j.

the class MapCollectionsTestModel method getDirectMapMappingTestSuite.

public static TestSuite getDirectMapMappingTestSuite() {
    TestSuite suite = new TestSuite();
    suite.setName("Direct Map Mapping Map Test Suite");
    suite.setDescription("This suite tests using DirectMapMapping with different types of keys.");
    // Read
    suite.addTest(new TestReadDirectDirectMapMapping());
    suite.addTest(new TestReadAggregateDirectMapMapping());
    suite.addTest(new TestReadEntityDirectMapMapping());
    // Update
    suite.addTest(new TestUpdateDirectDirectMapMapping());
    suite.addTest(new TestUpdateAggregateDirectMapMapping());
    suite.addTest(new TestUpdateEntityDirectMapMapping());
    // Private Owned - DirectMapMappings are automatically private owned
    // as a result, the only relevant test here is one with an EntityKey
    suite.addTest(new TestUpdateEntityDirectMapMapping(true));
    // Join
    suite.addTest(new TestReadDirectDirectMapMapping(ForeignReferenceMapping.INNER_JOIN));
    suite.addTest(new TestReadAggregateDirectMapMapping(ForeignReferenceMapping.INNER_JOIN));
    suite.addTest(new TestReadEntityDirectMapMapping(ForeignReferenceMapping.INNER_JOIN));
    // Expressions
    ReadAllExpressionTest test = new ReadAllExpressionTest(DirectDirectMapHolder.class, 1);
    ExpressionBuilder holders = new ExpressionBuilder();
    Expression exp = holders.anyOf("directToDirectMap").mapKey().equal(1);
    test.setExpression(exp);
    suite.addTest(test);
    test = new ReadAllExpressionTest(AggregateDirectMapHolder.class, 1);
    AggregateMapKey aggkey = new AggregateMapKey();
    aggkey.setKey(11);
    holders = new ExpressionBuilder();
    exp = holders.anyOf("aggregateToDirectMap").mapKey().equal(aggkey);
    test.setExpression(exp);
    suite.addTest(test);
    test = new ReadAllExpressionTest(EntityDirectMapHolder.class, 1);
    EntityMapKey entKey = new EntityMapKey();
    entKey.setId(333);
    entKey.setData("data3");
    holders = new ExpressionBuilder();
    exp = holders.anyOf("entityToDirectMap").mapKey().equal(entKey);
    test.setExpression(exp);
    suite.addTest(test);
    return suite;
}
Also used : AggregateMapKey(org.eclipse.persistence.testing.models.collections.map.AggregateMapKey) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder) AggregateDirectMapHolder(org.eclipse.persistence.testing.models.collections.map.AggregateDirectMapHolder) EntityMapKey(org.eclipse.persistence.testing.models.collections.map.EntityMapKey) EntityDirectMapHolder(org.eclipse.persistence.testing.models.collections.map.EntityDirectMapHolder) TestSuite(org.eclipse.persistence.testing.framework.TestSuite) Expression(org.eclipse.persistence.expressions.Expression) ReadAllExpressionTest(org.eclipse.persistence.testing.tests.expressions.ReadAllExpressionTest)

Example 2 with AggregateMapKey

use of org.eclipse.persistence.testing.models.collections.map.AggregateMapKey in project eclipselink by eclipse-ee4j.

the class MapCollectionsTestModel method getUnidirectionalOneToManyMappingTestSuite.

public static TestSuite getUnidirectionalOneToManyMappingTestSuite() {
    TestSuite suite = new TestSuite();
    suite.setName("UnidirectionalOneToManyMapping Map Test Suite");
    suite.setDescription("This suite tests using UnidirectionalOneToManyMapping with a Map");
    // Read
    suite.addTest(new TestReadDirectEntityU1MMapMapping());
    suite.addTest(new TestReadAggregateEntityU1MMapMapping());
    suite.addTest(new TestReadEntityEntityU1MMapMapping());
    // Update
    suite.addTest(new TestUpdateDirectEntityU1MMapMapping());
    suite.addTest(new TestUpdateAggregateEntityU1MMapMapping());
    suite.addTest(new TestUpdateEntityEntityU1MMapMapping());
    // Private Owned
    suite.addTest(new TestUpdateDirectEntityU1MMapMapping(true));
    suite.addTest(new TestUpdateAggregateEntityU1MMapMapping(true));
    suite.addTest(new TestUpdateEntityEntityU1MMapMapping(true));
    // Joining
    suite.addTest(new TestReadDirectEntityU1MMapMapping(ForeignReferenceMapping.INNER_JOIN));
    suite.addTest(new TestReadAggregateEntityU1MMapMapping(ForeignReferenceMapping.INNER_JOIN));
    suite.addTest(new TestReadEntityEntityU1MMapMapping(ForeignReferenceMapping.INNER_JOIN));
    // Expressions
    ReadAllExpressionTest test = new ReadAllExpressionTest(DirectEntityU1MMapHolder.class, 1);
    ExpressionBuilder holders = new ExpressionBuilder();
    Expression exp = holders.anyOf("directToEntityMap").mapKey().equal(11);
    test.setExpression(exp);
    suite.addTest(test);
    test = new ReadAllExpressionTest(AggregateEntityU1MMapHolder.class, 1);
    AggregateMapKey aggkey = new AggregateMapKey();
    aggkey.setKey(11);
    holders = new ExpressionBuilder();
    exp = holders.anyOf("aggregateToEntityMap").mapKey().equal(aggkey);
    test.setExpression(exp);
    suite.addTest(test);
    test = new ReadAllExpressionTest(EntityEntityU1MMapHolder.class, 1);
    EntityMapKey entKey = new EntityMapKey();
    entKey.setId(999);
    entKey.setData("data9");
    holders = new ExpressionBuilder();
    exp = holders.anyOf("entityToEntityMap").mapKey().equal(entKey);
    test.setExpression(exp);
    suite.addTest(test);
    return suite;
}
Also used : AggregateMapKey(org.eclipse.persistence.testing.models.collections.map.AggregateMapKey) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder) EntityMapKey(org.eclipse.persistence.testing.models.collections.map.EntityMapKey) TestSuite(org.eclipse.persistence.testing.framework.TestSuite) Expression(org.eclipse.persistence.expressions.Expression) EntityEntityU1MMapHolder(org.eclipse.persistence.testing.models.collections.map.EntityEntityU1MMapHolder) ReadAllExpressionTest(org.eclipse.persistence.testing.tests.expressions.ReadAllExpressionTest) AggregateEntityU1MMapHolder(org.eclipse.persistence.testing.models.collections.map.AggregateEntityU1MMapHolder)

Example 3 with AggregateMapKey

use of org.eclipse.persistence.testing.models.collections.map.AggregateMapKey in project eclipselink by eclipse-ee4j.

the class MapCollectionsTestModel method getOneToManyMappingTestSuite.

public static TestSuite getOneToManyMappingTestSuite() {
    TestSuite suite = new TestSuite();
    suite.setName("OneToManyMapping Map Test Suite");
    suite.setDescription("This suite tests using OneToManyMapping with a Map");
    // Read
    suite.addTest(new TestReadDirectEntity1MMapMapping());
    suite.addTest(new TestReadAggregateEntity1MMapMapping());
    suite.addTest(new TestReadEntityEntity1MMapMapping());
    // Update
    suite.addTest(new TestUpdateDirectEntity1MMapMapping());
    suite.addTest(new TestUpdateAggregateEntity1MMapMapping());
    suite.addTest(new TestUpdateEntityEntity1MMapMapping());
    // Private Owned
    suite.addTest(new TestUpdateDirectEntity1MMapMapping(true));
    suite.addTest(new TestUpdateAggregateEntity1MMapMapping(true));
    suite.addTest(new TestUpdateEntityEntity1MMapMapping(true));
    // Joining
    suite.addTest(new TestReadDirectEntity1MMapMapping(ForeignReferenceMapping.INNER_JOIN));
    suite.addTest(new TestReadAggregateEntity1MMapMapping(ForeignReferenceMapping.INNER_JOIN));
    suite.addTest(new TestReadEntityEntity1MMapMapping(ForeignReferenceMapping.INNER_JOIN));
    // Expressions
    ReadAllExpressionTest test = new ReadAllExpressionTest(DirectEntity1MMapHolder.class, 1);
    ExpressionBuilder holders = new ExpressionBuilder();
    Expression exp = holders.anyOf("directToEntityMap").mapKey().equal(11);
    test.setExpression(exp);
    suite.addTest(test);
    test = new ReadAllExpressionTest(AggregateEntity1MMapHolder.class, 1);
    AggregateMapKey aggkey = new AggregateMapKey();
    aggkey.setKey(11);
    holders = new ExpressionBuilder();
    exp = holders.anyOf("aggregateToEntityMap").mapKey().equal(aggkey);
    test.setExpression(exp);
    suite.addTest(test);
    test = new ReadAllExpressionTest(AggregateEntity1MMapHolder.class, 1);
    holders = new ExpressionBuilder();
    exp = holders.anyOf("aggregateToEntityMap").mapKey().get("key").equal(11);
    test.setExpression(exp);
    suite.addTest(test);
    test = new ReadAllExpressionTest(EntityEntity1MMapHolder.class, 1);
    EntityMapKey entKey = new EntityMapKey();
    entKey.setId(555);
    entKey.setData("data5");
    holders = new ExpressionBuilder();
    exp = holders.anyOf("entityToEntityMap").mapKey().equal(entKey);
    test.setExpression(exp);
    suite.addTest(test);
    test = new ReadAllExpressionTest(EntityEntity1MMapHolder.class, 1);
    holders = new ExpressionBuilder();
    exp = holders.anyOf("entityToEntityMap").mapKey().get("data").equal("data5");
    test.setExpression(exp);
    suite.addTest(test);
    suite.addTest(new MapKeyDirectEntity1MReportQueryTestCase());
    suite.addTest(new MapKeyAggregateEntity1MReportQueryTestCase());
    suite.addTest(new MapKeyEntityEntity1MReportQueryTestCase());
    suite.addTest(new MapEntryDirectEntity1MReportQueryTest());
    suite.addTest(new InMemoryDirectEntity1MTest());
    return suite;
}
Also used : EntityEntity1MMapHolder(org.eclipse.persistence.testing.models.collections.map.EntityEntity1MMapHolder) AggregateMapKey(org.eclipse.persistence.testing.models.collections.map.AggregateMapKey) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder) EntityMapKey(org.eclipse.persistence.testing.models.collections.map.EntityMapKey) TestSuite(org.eclipse.persistence.testing.framework.TestSuite) Expression(org.eclipse.persistence.expressions.Expression) AggregateEntity1MMapHolder(org.eclipse.persistence.testing.models.collections.map.AggregateEntity1MMapHolder) ReadAllExpressionTest(org.eclipse.persistence.testing.tests.expressions.ReadAllExpressionTest)

Example 4 with AggregateMapKey

use of org.eclipse.persistence.testing.models.collections.map.AggregateMapKey in project eclipselink by eclipse-ee4j.

the class MapCollectionsTestModel method getManyToManyMappingTestSuite.

public static TestSuite getManyToManyMappingTestSuite() {
    TestSuite suite = new TestSuite();
    suite.setName("ManyToManyMapping Map Test Suite");
    suite.setDescription("This suite tests using ManyToManyMapping with a Map");
    // Read
    suite.addTest(new TestReadDirectEntityMapMapping());
    suite.addTest(new TestReadAggregateEntityMapMapping());
    suite.addTest(new TestReadEntityEntityMapMapping());
    // Update
    suite.addTest(new TestUpdateDirectEntityMapMapping());
    suite.addTest(new TestUpdateAggregateEntityMapMapping());
    suite.addTest(new TestUpdateEntityEntityMapMapping());
    // private owned
    suite.addTest(new TestUpdateDirectEntityMapMapping(true));
    suite.addTest(new TestUpdateAggregateEntityMapMapping(true));
    suite.addTest(new TestUpdateEntityEntityMapMapping(true));
    // Joining
    suite.addTest(new TestReadDirectEntityMapMapping(ForeignReferenceMapping.INNER_JOIN));
    suite.addTest(new TestReadAggregateEntityMapMapping(ForeignReferenceMapping.INNER_JOIN));
    suite.addTest(new TestReadEntityEntityMapMapping(ForeignReferenceMapping.INNER_JOIN));
    // Expressions
    ReadAllExpressionTest test = new ReadAllExpressionTest(DirectEntityMapHolder.class, 1);
    ExpressionBuilder holders = new ExpressionBuilder();
    Expression exp = holders.anyOf("directToEntityMap").mapKey().equal(11);
    test.setExpression(exp);
    suite.addTest(test);
    test = new ReadAllExpressionTest(AggregateEntityMapHolder.class, 1);
    AggregateMapKey aggkey = new AggregateMapKey();
    aggkey.setKey(11);
    holders = new ExpressionBuilder();
    exp = holders.anyOf("aggregateToEntityMap").mapKey().equal(aggkey);
    test.setExpression(exp);
    suite.addTest(test);
    test = new ReadAllExpressionTest(EntityEntityMapHolder.class, 1);
    EntityMapKey entKey = new EntityMapKey();
    entKey.setId(777);
    entKey.setData("data7");
    holders = new ExpressionBuilder();
    exp = holders.anyOf("entityToEntityMap").mapKey().equal(entKey);
    test.setExpression(exp);
    suite.addTest(test);
    return suite;
}
Also used : AggregateMapKey(org.eclipse.persistence.testing.models.collections.map.AggregateMapKey) EntityEntityMapHolder(org.eclipse.persistence.testing.models.collections.map.EntityEntityMapHolder) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder) AggregateEntityMapHolder(org.eclipse.persistence.testing.models.collections.map.AggregateEntityMapHolder) EntityMapKey(org.eclipse.persistence.testing.models.collections.map.EntityMapKey) TestSuite(org.eclipse.persistence.testing.framework.TestSuite) Expression(org.eclipse.persistence.expressions.Expression) ReadAllExpressionTest(org.eclipse.persistence.testing.tests.expressions.ReadAllExpressionTest)

Example 5 with AggregateMapKey

use of org.eclipse.persistence.testing.models.collections.map.AggregateMapKey in project eclipselink by eclipse-ee4j.

the class TestUpdateAggregateDirectMapMapping method verify.

@Override
public void verify() {
    getSession().getIdentityMapAccessor().initializeIdentityMaps();
    Object changedHolder = holders.get(0);
    holders = getSession().readAllObjects(AggregateDirectMapHolder.class, holderExp);
    AggregateDirectMapHolder holder = (AggregateDirectMapHolder) holders.get(0);
    if (!compareObjects(holder, changedHolder)) {
        throw new TestErrorException("Objects do not match reinitialize");
    }
    AggregateMapKey mapKey = new AggregateMapKey();
    mapKey.setKey(1);
    if (holder.getAggregateToDirectMap().containsKey(mapKey)) {
        throw new TestErrorException("Item that was removed is still present in map.");
    }
    mapKey = new AggregateMapKey();
    mapKey.setKey(3);
    Integer value = (Integer) holder.getAggregateToDirectMap().get(mapKey);
    if (value != 3) {
        throw new TestErrorException("Item was not correctly added to map");
    }
}
Also used : TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) AggregateMapKey(org.eclipse.persistence.testing.models.collections.map.AggregateMapKey) AggregateDirectMapHolder(org.eclipse.persistence.testing.models.collections.map.AggregateDirectMapHolder)

Aggregations

AggregateMapKey (org.eclipse.persistence.testing.models.collections.map.AggregateMapKey)29 TestErrorException (org.eclipse.persistence.testing.framework.TestErrorException)16 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)13 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)13 EntityMapValue (org.eclipse.persistence.testing.models.collections.map.EntityMapValue)11 Expression (org.eclipse.persistence.expressions.Expression)8 TestSuite (org.eclipse.persistence.testing.framework.TestSuite)5 AggregateAggregateMapHolder (org.eclipse.persistence.testing.models.collections.map.AggregateAggregateMapHolder)5 AggregateDirectMapHolder (org.eclipse.persistence.testing.models.collections.map.AggregateDirectMapHolder)5 AggregateEntity1MMapHolder (org.eclipse.persistence.testing.models.collections.map.AggregateEntity1MMapHolder)5 AggregateEntityMapHolder (org.eclipse.persistence.testing.models.collections.map.AggregateEntityMapHolder)5 AggregateEntityU1MMapHolder (org.eclipse.persistence.testing.models.collections.map.AggregateEntityU1MMapHolder)5 EntityMapKey (org.eclipse.persistence.testing.models.collections.map.EntityMapKey)5 ReadAllExpressionTest (org.eclipse.persistence.testing.tests.expressions.ReadAllExpressionTest)5 AEOTMMapValue (org.eclipse.persistence.testing.models.collections.map.AEOTMMapValue)4 ReadObjectQuery (org.eclipse.persistence.queries.ReadObjectQuery)3 Iterator (java.util.Iterator)1 EntityAggregateMapHolder (org.eclipse.persistence.testing.models.collections.map.EntityAggregateMapHolder)1 EntityDirectMapHolder (org.eclipse.persistence.testing.models.collections.map.EntityDirectMapHolder)1 EntityEntity1MMapHolder (org.eclipse.persistence.testing.models.collections.map.EntityEntity1MMapHolder)1