Search in sources :

Example 1 with AggregateAggregateMapHolder

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

the class TestUpdateAggregateAggregateMapMapping method verify.

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

Example 2 with AggregateAggregateMapHolder

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

the class TestUpdateAggregateAggregateMapMapping method test.

@Override
public void test() {
    UnitOfWork uow = getSession().acquireUnitOfWork();
    holders = uow.readAllObjects(AggregateAggregateMapHolder.class, holderExp);
    AggregateAggregateMapHolder holder = (AggregateAggregateMapHolder) holders.get(0);
    AggregateMapKey key = new AggregateMapKey();
    key.setKey(11);
    holder.removeAggregateToAggregateMapItem(key);
    AggregateMapKey mapValue = new AggregateMapKey();
    mapValue.setKey(3);
    key = new AggregateMapKey();
    key.setKey(33);
    holder.addAggregateToAggregateMapItem(key, mapValue);
    uow.commit();
    Object holderForComparison = uow.readObject(holder);
    if (!compareObjects(holder, holderForComparison)) {
        throw new TestErrorException("Objects do not match after write");
    }
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) AggregateAggregateMapHolder(org.eclipse.persistence.testing.models.collections.map.AggregateAggregateMapHolder) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) AggregateMapKey(org.eclipse.persistence.testing.models.collections.map.AggregateMapKey)

Example 3 with AggregateAggregateMapHolder

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

the class TestReadAggregateAggregateMapMapping method verify.

@Override
public void verify() {
    if (holders == null || holders.size() != 1) {
        throw new TestErrorException("Incorrect number of MapHolders was read.");
    }
    AggregateAggregateMapHolder holder = (AggregateAggregateMapHolder) holders.get(0);
    if (!((IndirectMap) holder.getAggregateToAggregateMap()).getValueHolder().isInstantiated() && fetchJoinRelationship > 0) {
        throw new TestErrorException("Relationship was not properly joined.");
    }
    if (holder.getAggregateToAggregateMap().size() != 2) {
        throw new TestErrorException("Incorrect Number of MapEntityValues was read.");
    }
    AggregateMapKey mapKey = new AggregateMapKey();
    mapKey.setKey(11);
    AggregateMapKey value = (AggregateMapKey) holder.getAggregateToAggregateMap().get(mapKey);
    if (value.getKey() != 1) {
        throw new TestErrorException("Incorrect MapEntityValues was read.");
    }
}
Also used : TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) AggregateAggregateMapHolder(org.eclipse.persistence.testing.models.collections.map.AggregateAggregateMapHolder) AggregateMapKey(org.eclipse.persistence.testing.models.collections.map.AggregateMapKey)

Example 4 with AggregateAggregateMapHolder

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

the class TestReadAggregateAggregateMapMapping method setup.

@Override
public void setup() {
    mapping = (AggregateCollectionMapping) getSession().getProject().getDescriptor(AggregateAggregateMapHolder.class).getMappingForAttributeName("aggregateToAggregateMap");
    oldFetchJoinValue = mapping.getJoinFetch();
    mapping.setJoinFetch(fetchJoinRelationship);
    getSession().getProject().getDescriptor(AggregateAggregateMapHolder.class).reInitializeJoinedAttributes();
    UnitOfWork uow = getSession().acquireUnitOfWork();
    AggregateAggregateMapHolder holder = new AggregateAggregateMapHolder();
    AggregateMapKey value = new AggregateMapKey();
    value.setKey(1);
    AggregateMapKey key = new AggregateMapKey();
    key.setKey(11);
    holder.addAggregateToAggregateMapItem(key, value);
    AggregateMapKey value2 = new AggregateMapKey();
    value2.setKey(2);
    key = new AggregateMapKey();
    key.setKey(22);
    holder.addAggregateToAggregateMapItem(key, value2);
    uow.registerObject(holder);
    uow.commit();
    holderExp = (new ExpressionBuilder()).get("id").equal(holder.getId());
    getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) AggregateAggregateMapHolder(org.eclipse.persistence.testing.models.collections.map.AggregateAggregateMapHolder) AggregateMapKey(org.eclipse.persistence.testing.models.collections.map.AggregateMapKey) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Aggregations

AggregateAggregateMapHolder (org.eclipse.persistence.testing.models.collections.map.AggregateAggregateMapHolder)4 AggregateMapKey (org.eclipse.persistence.testing.models.collections.map.AggregateMapKey)4 TestErrorException (org.eclipse.persistence.testing.framework.TestErrorException)3 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)2 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)1