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