Search in sources :

Example 1 with DirectAggregateMapHolder

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

the class TestUpdateDirectAggregateMapMapping method verify.

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

Example 2 with DirectAggregateMapHolder

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

the class TestUpdateDirectAggregateMapMapping method test.

@Override
public void test() {
    UnitOfWork uow = getSession().acquireUnitOfWork();
    holders = uow.readAllObjects(DirectAggregateMapHolder.class, holderExp);
    changedHolder = (DirectAggregateMapHolder) holders.get(0);
    changedHolder.removeDirectToAggregateMapItem(1);
    AggregateMapValue mapValue = new AggregateMapValue();
    mapValue.setValue(3);
    changedHolder.addDirectToAggregateMapItem(3, mapValue);
    uow.commit();
    Object holderForComparison = uow.readObject(changedHolder);
    if (!compareObjects(changedHolder, holderForComparison)) {
        throw new TestErrorException("Objects do not match after write");
    }
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) AggregateMapValue(org.eclipse.persistence.testing.models.collections.map.AggregateMapValue) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) DirectAggregateMapHolder(org.eclipse.persistence.testing.models.collections.map.DirectAggregateMapHolder)

Example 3 with DirectAggregateMapHolder

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

the class TestReadDirectAggregateMapMapping method verify.

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

Example 4 with DirectAggregateMapHolder

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

the class TestReadDirectAggregateMapMapping method setup.

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

Aggregations

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