Search in sources :

Example 11 with TestErrorException

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

the class TestReadAggregateEntity1MMapMapping method reset.

@Override
public void reset() {
    UnitOfWork uow = getSession().acquireUnitOfWork();
    Iterator i = holders.iterator();
    while (i.hasNext()) {
        AggregateEntity1MMapHolder holder = (AggregateEntity1MMapHolder) i.next();
        Iterator j = holder.getAggregateToEntityMap().keySet().iterator();
        while (j.hasNext()) {
            uow.deleteObject(holder.getAggregateToEntityMap().get(j.next()));
        }
    }
    uow.deleteAllObjects(holders);
    uow.commit();
    if (!verifyDelete(holders.get(0))) {
        throw new TestErrorException("Delete was unsuccessful.");
    }
    mapping.setJoinFetch(oldFetchJoinValue);
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) Iterator(java.util.Iterator) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) AggregateEntity1MMapHolder(org.eclipse.persistence.testing.models.collections.map.AggregateEntity1MMapHolder)

Example 12 with TestErrorException

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

the class TestReadAggregateEntity1MMapMapping method verify.

@Override
public void verify() {
    if (holders == null || holders.size() != 1) {
        throw new TestErrorException("Incorrect number of MapHolders was read.");
    }
    AggregateEntity1MMapHolder holder = (AggregateEntity1MMapHolder) 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);
    AEOTMMapValue value = (AEOTMMapValue) holder.getAggregateToEntityMap().get(mapKey);
    if (value.getId() != 1) {
        throw new TestErrorException("Incorrect MapEntityValues was read.");
    }
}
Also used : TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) AggregateEntity1MMapHolder(org.eclipse.persistence.testing.models.collections.map.AggregateEntity1MMapHolder) AggregateMapKey(org.eclipse.persistence.testing.models.collections.map.AggregateMapKey) AEOTMMapValue(org.eclipse.persistence.testing.models.collections.map.AEOTMMapValue)

Example 13 with TestErrorException

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

the class TestReadDirectEntityMapMapping method verify.

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

Example 14 with TestErrorException

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

the class TestReadDirectEntityU1MMapMapping method verify.

@Override
public void verify() {
    if (holders == null || holders.size() != 1) {
        throw new TestErrorException("Incorrect number of MapHolders was read.");
    }
    DirectEntityU1MMapHolder holder = (DirectEntityU1MMapHolder) holders.get(0);
    if (!((IndirectMap) holder.getDirectToEntityMap()).getValueHolder().isInstantiated() && fetchJoinRelationship > 0) {
        throw new TestErrorException("Relationship was not properly joined.");
    }
    if (holder.getDirectToEntityMap().size() != 2) {
        throw new TestErrorException("Incorrect Number of MapEntityValues was read.");
    }
    EntityMapValue value = (EntityMapValue) holder.getDirectToEntityMap().get(11);
    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) DirectEntityU1MMapHolder(org.eclipse.persistence.testing.models.collections.map.DirectEntityU1MMapHolder)

Example 15 with TestErrorException

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

the class TestReadEntityDirectMapMapping method reset.

@Override
public void reset() {
    UnitOfWork uow = getSession().acquireUnitOfWork();
    Iterator i = holders.iterator();
    while (i.hasNext()) {
        EntityDirectMapHolder holder = (EntityDirectMapHolder) i.next();
        Iterator j = holder.getEntityToDirectMap().keySet().iterator();
        while (j.hasNext()) {
            uow.deleteObject(j.next());
        }
    }
    uow.deleteAllObjects(holders);
    uow.commit();
    if (!verifyDelete(holders.get(0))) {
        throw new TestErrorException("Delete was unsuccessful.");
    }
    mapping.setJoinFetch(oldFetchJoinValue);
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) EntityDirectMapHolder(org.eclipse.persistence.testing.models.collections.map.EntityDirectMapHolder) Iterator(java.util.Iterator) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException)

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