Search in sources :

Example 1 with TestErrorException

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

Example 2 with TestErrorException

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

the class TestReadEntityEntityU1MMapMapping method verify.

@Override
public void verify() {
    if (holders == null || holders.size() != 1) {
        throw new TestErrorException("Incorrect number of MapHolders was read.");
    }
    EntityEntityU1MMapHolder holder = (EntityEntityU1MMapHolder) 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 : EntityEntityU1MMapHolder(org.eclipse.persistence.testing.models.collections.map.EntityEntityU1MMapHolder) EntityMapValue(org.eclipse.persistence.testing.models.collections.map.EntityMapValue) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) EntityMapKey(org.eclipse.persistence.testing.models.collections.map.EntityMapKey)

Example 3 with TestErrorException

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

the class TestReadEntityEntityU1MMapMapping method reset.

@Override
public void reset() {
    UnitOfWork uow = getSession().acquireUnitOfWork();
    Iterator i = holders.iterator();
    while (i.hasNext()) {
        EntityEntityU1MMapHolder holder = (EntityEntityU1MMapHolder) i.next();
        Iterator j = holder.getEntityToEntityMap().keySet().iterator();
        while (j.hasNext()) {
            Object key = j.next();
            uow.deleteObject(holder.getEntityToEntityMap().get(key));
            uow.deleteObject(key);
        }
    }
    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) EntityEntityU1MMapHolder(org.eclipse.persistence.testing.models.collections.map.EntityEntityU1MMapHolder) Iterator(java.util.Iterator) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException)

Example 4 with TestErrorException

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

the class TestUpdateAggregateDirectMapMapping method verify.

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

Example 5 with TestErrorException

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

the class TestUpdateAggregateEntity1MMapMapping method test.

@Override
public void test() {
    UnitOfWork uow = getSession().acquireUnitOfWork();
    holders = uow.readAllObjects(AggregateEntity1MMapHolder.class, holderExp);
    changedHolder = (AggregateEntity1MMapHolder) holders.get(0);
    AggregateMapKey key = new AggregateMapKey();
    key.setKey(11);
    changedHolder.removeAggregateToEntityMapItem(key);
    AEOTMMapValue mapValue = new AEOTMMapValue();
    mapValue.setId(3);
    mapValue = (AEOTMMapValue) uow.registerObject(mapValue);
    key = new AggregateMapKey();
    key.setKey(33);
    mapValue.getHolder().setValue(changedHolder);
    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) 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)

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