Search in sources :

Example 6 with TestErrorException

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

the class TestUpdateAggregateEntity1MMapMapping method verify.

@Override
public void verify() {
    getSession().getIdentityMapAccessor().initializeIdentityMaps();
    holders = getSession().readAllObjects(AggregateEntity1MMapHolder.class, holderExp);
    AggregateEntity1MMapHolder holder = (AggregateEntity1MMapHolder) holders.get(0);
    if (!compareObjects(holder, changedHolder)) {
        throw new TestErrorException("Objects do not match reinitialize");
    }
    AggregateMapKey key = new AggregateMapKey();
    key.setKey(11);
    if (holder.getAggregateToEntityMap().containsKey(key)) {
        throw new TestErrorException("Item that was removed is still present in map.");
    }
    key = new AggregateMapKey();
    key.setKey(33);
    AEOTMMapValue value = (AEOTMMapValue) holder.getAggregateToEntityMap().get(key);
    if (value.getId() != 3) {
        throw new TestErrorException("Item was not correctly added to map");
    }
    if (mapping.isPrivateOwned()) {
        ReadObjectQuery query = new ReadObjectQuery(AEOTMMapValue.class);
        ExpressionBuilder values = new ExpressionBuilder();
        Expression criteria = values.get("id").equal(1);
        query.setSelectionCriteria(criteria);
        value = (AEOTMMapValue) getSession().executeQuery(query);
        if (value != null) {
            throw new TestErrorException("PrivateOwned DEOTMMapValue was not deleted.");
        }
    }
}
Also used : ReadObjectQuery(org.eclipse.persistence.queries.ReadObjectQuery) Expression(org.eclipse.persistence.expressions.Expression) 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) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder) AEOTMMapValue(org.eclipse.persistence.testing.models.collections.map.AEOTMMapValue)

Example 7 with TestErrorException

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

the class TestUpdateAggregateEntityMapMapping method verify.

@Override
public void verify() {
    getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
    Object changedHolder = holder;
    holder = (AggregateEntityMapHolder) getSession().readObject(holder);
    if (holder == null) {
        throw new TestErrorException("AggregateKeyMapHolder could not be read.");
    }
    if (!compareObjects(holder, changedHolder)) {
        throw new TestErrorException("Objects do not match reinitialize");
    }
    if (holder.getAggregateToEntityMap().size() != 2) {
        throw new TestErrorException("Incorrect Number of MapEntityValues was read.");
    }
    AggregateMapKey mapKey = new AggregateMapKey();
    mapKey.setKey(33);
    EntityMapValue value = (EntityMapValue) holder.getAggregateToEntityMap().get(mapKey);
    if (value.getId() != 3) {
        throw new TestErrorException("MapEntityValue was not added properly.");
    }
    mapKey = new AggregateMapKey();
    mapKey.setKey(11);
    value = (EntityMapValue) holder.getAggregateToEntityMap().get(mapKey);
    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) AggregateMapKey(org.eclipse.persistence.testing.models.collections.map.AggregateMapKey) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Example 8 with TestErrorException

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

the class TestUpdateEntityAggregateMapMapping method test.

@Override
public void test() {
    UnitOfWork uow = getSession().acquireUnitOfWork();
    holders = uow.readAllObjects(EntityAggregateMapHolder.class, holderExp);
    changedHolder = (EntityAggregateMapHolder) holders.get(0);
    EntityMapKey key = new EntityMapKey();
    key.setId(1);
    changedHolder.removeEntityToAggregateMapItem(key);
    AggregateMapValue mapValue = new AggregateMapValue();
    mapValue.setValue(3);
    key = new EntityMapKey();
    key.setId(3);
    key = (EntityMapKey) uow.registerObject(key);
    changedHolder.addEntityToAggregateMapItem(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) AggregateMapValue(org.eclipse.persistence.testing.models.collections.map.AggregateMapValue) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) EntityAggregateMapHolder(org.eclipse.persistence.testing.models.collections.map.EntityAggregateMapHolder) EntityMapKey(org.eclipse.persistence.testing.models.collections.map.EntityMapKey)

Example 9 with TestErrorException

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

the class TestUpdateEntityDirectMapMapping method verify.

@Override
public void verify() {
    getSession().getIdentityMapAccessor().initializeIdentityMaps();
    holders = getSession().readAllObjects(EntityDirectMapHolder.class, holderExp);
    EntityDirectMapHolder holder = (EntityDirectMapHolder) holders.get(0);
    if (!compareObjects(holder, changedHolder)) {
        throw new TestErrorException("Objects do not match reinitialize");
    }
    EntityMapKey mapKey = new EntityMapKey();
    mapKey.setId(1);
    if (holder.getEntityToDirectMap().containsKey(mapKey)) {
        throw new TestErrorException("Item that was removed is still present in map.");
    }
    mapKey = new EntityMapKey();
    mapKey.setId(3);
    Integer value = (Integer) holder.getEntityToDirectMap().get(mapKey);
    if (value != 3) {
        throw new TestErrorException("Item was not correctly added to map");
    }
    if (keyMapping.isPrivateOwned()) {
        ReadObjectQuery query = new ReadObjectQuery(EntityMapKey.class);
        ExpressionBuilder keys = new ExpressionBuilder();
        Expression keycriteria = keys.get("id").equal(1);
        query.setSelectionCriteria(keycriteria);
        mapKey = (EntityMapKey) getSession().executeQuery(query);
        if (mapKey != null) {
            throw new TestErrorException("PrivateOwned EntityMapKey was not deleted.");
        }
    }
}
Also used : EntityDirectMapHolder(org.eclipse.persistence.testing.models.collections.map.EntityDirectMapHolder) ReadObjectQuery(org.eclipse.persistence.queries.ReadObjectQuery) Expression(org.eclipse.persistence.expressions.Expression) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder) EntityMapKey(org.eclipse.persistence.testing.models.collections.map.EntityMapKey)

Example 10 with TestErrorException

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

the class TestUpdateEntityEntityU1MMapMapping method test.

@Override
public void test() {
    UnitOfWork uow = getSession().acquireUnitOfWork();
    holders = uow.readAllObjects(EntityEntityU1MMapHolder.class, holderExp);
    changedHolder = (EntityEntityU1MMapHolder) holders.get(0);
    EntityMapKey key = new EntityMapKey();
    key.setId(11);
    changedHolder.removeEntityToEntityMapItem(key);
    EntityMapValue mapValue = new EntityMapValue();
    mapValue.setId(3);
    mapValue = (EntityMapValue) uow.registerObject(mapValue);
    key = new EntityMapKey();
    key.setId(33);
    key = (EntityMapKey) uow.registerObject(key);
    changedHolder.addEntityToEntityMapItem(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) 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)

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