Search in sources :

Example 1 with EntityMapKey

use of org.eclipse.persistence.testing.models.collections.map.EntityMapKey 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 EntityMapKey

use of org.eclipse.persistence.testing.models.collections.map.EntityMapKey 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 EntityMapKey

use of org.eclipse.persistence.testing.models.collections.map.EntityMapKey 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 EntityMapKey

use of org.eclipse.persistence.testing.models.collections.map.EntityMapKey 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 EntityMapKey

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

the class TestReadEntityEntityMapMapping method verify.

@Override
public void verify() {
    if (holders == null || holders.size() != 1) {
        throw new TestErrorException("Incorrect number of MapHolders was read.");
    }
    EntityEntityMapHolder holder = (EntityEntityMapHolder) holders.get(0);
    if (!((IndirectMap) holder.getEntityToEntityMap()).getValueHolder().isInstantiated() && fetchJoinRelationship > 0) {
        throw new TestErrorException("Relationship was not properly joined.");
    }
    if (holder.getEntityToEntityMap().size() != 2) {
        throw new TestErrorException("Incorrect Number of MapEntityValues was read.");
    }
    EntityMapKey mapKey = new EntityMapKey();
    mapKey.setId(11);
    EntityMapValue value = (EntityMapValue) holder.getEntityToEntityMap().get(mapKey);
    if (value.getId() != 1) {
        throw new TestErrorException("Incorrect MapEntityValues was read.");
    }
    mapKey = (EntityMapKey) getSession().readObject(mapKey);
    if (!mapKey.getData().equals("data1")) {
        throw new TestErrorException("EntityMapKey had wrong data");
    }
}
Also used : EntityMapValue(org.eclipse.persistence.testing.models.collections.map.EntityMapValue) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) EntityEntityMapHolder(org.eclipse.persistence.testing.models.collections.map.EntityEntityMapHolder) EntityMapKey(org.eclipse.persistence.testing.models.collections.map.EntityMapKey)

Aggregations

EntityMapKey (org.eclipse.persistence.testing.models.collections.map.EntityMapKey)26 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)15 TestErrorException (org.eclipse.persistence.testing.framework.TestErrorException)15 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)11 Expression (org.eclipse.persistence.expressions.Expression)10 EntityMapValue (org.eclipse.persistence.testing.models.collections.map.EntityMapValue)9 ReadObjectQuery (org.eclipse.persistence.queries.ReadObjectQuery)5 TestSuite (org.eclipse.persistence.testing.framework.TestSuite)5 AggregateMapKey (org.eclipse.persistence.testing.models.collections.map.AggregateMapKey)5 EntityAggregateMapHolder (org.eclipse.persistence.testing.models.collections.map.EntityAggregateMapHolder)5 EntityDirectMapHolder (org.eclipse.persistence.testing.models.collections.map.EntityDirectMapHolder)5 EntityEntity1MMapHolder (org.eclipse.persistence.testing.models.collections.map.EntityEntity1MMapHolder)5 EntityEntityU1MMapHolder (org.eclipse.persistence.testing.models.collections.map.EntityEntityU1MMapHolder)5 ReadAllExpressionTest (org.eclipse.persistence.testing.tests.expressions.ReadAllExpressionTest)5 AggregateMapValue (org.eclipse.persistence.testing.models.collections.map.AggregateMapValue)4 EEOTMMapValue (org.eclipse.persistence.testing.models.collections.map.EEOTMMapValue)4 EntityEntityMapHolder (org.eclipse.persistence.testing.models.collections.map.EntityEntityMapHolder)4 MappedKeyMapContainerPolicy (org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy)1 AggregateAggregateMapHolder (org.eclipse.persistence.testing.models.collections.map.AggregateAggregateMapHolder)1 AggregateDirectMapHolder (org.eclipse.persistence.testing.models.collections.map.AggregateDirectMapHolder)1