Search in sources :

Example 16 with TestErrorException

use of org.eclipse.persistence.testing.framework.TestErrorException in project eclipselink by eclipse-ee4j.

the class TestUpdateAggregateEntityU1MMapMapping method test.

@Override
public void test() {
    UnitOfWork uow = getSession().acquireUnitOfWork();
    holders = uow.readAllObjects(AggregateEntityU1MMapHolder.class, holderExp);
    changedHolder = (AggregateEntityU1MMapHolder) holders.get(0);
    AggregateMapKey key = new AggregateMapKey();
    key.setKey(11);
    changedHolder.removeAggregateToEntityMapItem(key);
    EntityMapValue mapValue = new EntityMapValue();
    mapValue.setId(3);
    mapValue = (EntityMapValue) uow.registerObject(mapValue);
    key = new AggregateMapKey();
    key.setKey(33);
    changedHolder.addAggregateToEntityMapItem(key, 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) EntityMapValue(org.eclipse.persistence.testing.models.collections.map.EntityMapValue) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) AggregateMapKey(org.eclipse.persistence.testing.models.collections.map.AggregateMapKey) AggregateEntityU1MMapHolder(org.eclipse.persistence.testing.models.collections.map.AggregateEntityU1MMapHolder)

Example 17 with TestErrorException

use of org.eclipse.persistence.testing.framework.TestErrorException 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 18 with TestErrorException

use of org.eclipse.persistence.testing.framework.TestErrorException in project eclipselink by eclipse-ee4j.

the class TestUpdateDirectDirectMapMapping method verify.

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

Example 19 with TestErrorException

use of org.eclipse.persistence.testing.framework.TestErrorException in project eclipselink by eclipse-ee4j.

the class TestUpdateDirectEntityMapMapping method verify.

@Override
public void verify() {
    getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
    holder = (DirectEntityMapHolder) getSession().readObject(holder);
    if (!compareObjects(holder, changedHolder)) {
        throw new TestErrorException("Objects do not match reinitialize");
    }
    if (holder.getDirectToEntityMap().size() != 2) {
        throw new TestErrorException("Incorrect Number of MapEntityValues was read.");
    }
    EntityMapValue value = (EntityMapValue) holder.getDirectToEntityMap().get(33);
    if (value.getId() != 3) {
        throw new TestErrorException("MapEntityValue was not added properly.");
    }
    value = (EntityMapValue) holder.getDirectToEntityMap().get(11);
    if (value != null) {
        throw new TestErrorException("Deleted EntityMapValue still around.");
    }
    if (mapping.isPrivateOwned()) {
        ReadObjectQuery query = new ReadObjectQuery(EntityMapValue.class);
        ExpressionBuilder values = new ExpressionBuilder();
        Expression criteria = values.get("id").equal(1);
        query.setSelectionCriteria(criteria);
        value = (EntityMapValue) getSession().executeQuery(query);
        if (value != null) {
            throw new TestErrorException("PrivateOwned EntityMapValue was not deleted.");
        }
    }
}
Also used : ReadObjectQuery(org.eclipse.persistence.queries.ReadObjectQuery) Expression(org.eclipse.persistence.expressions.Expression) EntityMapValue(org.eclipse.persistence.testing.models.collections.map.EntityMapValue) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Example 20 with TestErrorException

use of org.eclipse.persistence.testing.framework.TestErrorException in project eclipselink by eclipse-ee4j.

the class TestReadAggregateEntityMapMapping method verify.

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

Aggregations

TestErrorException (org.eclipse.persistence.testing.framework.TestErrorException)227 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)79 Employee (org.eclipse.persistence.testing.models.employee.domain.Employee)50 ReadObjectQuery (org.eclipse.persistence.queries.ReadObjectQuery)27 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)22 Vector (java.util.Vector)20 EntityMapValue (org.eclipse.persistence.testing.models.collections.map.EntityMapValue)20 Expression (org.eclipse.persistence.expressions.Expression)19 UnitOfWorkImpl (org.eclipse.persistence.internal.sessions.UnitOfWorkImpl)18 Iterator (java.util.Iterator)17 AggregateMapKey (org.eclipse.persistence.testing.models.collections.map.AggregateMapKey)16 EntityMapKey (org.eclipse.persistence.testing.models.collections.map.EntityMapKey)15 Project (org.eclipse.persistence.sessions.Project)13 Session (org.eclipse.persistence.sessions.Session)11 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)7 QueryException (org.eclipse.persistence.exceptions.QueryException)7 TestWarningException (org.eclipse.persistence.testing.framework.TestWarningException)7 Address (org.eclipse.persistence.testing.models.employee.domain.Address)7 Test (org.junit.Test)7 BigDecimal (java.math.BigDecimal)6