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.");
}
}
}
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.");
}
}
}
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");
}
}
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.");
}
}
}
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");
}
}
Aggregations