use of org.eclipse.persistence.testing.models.collections.map.AggregateAggregateMapHolder in project eclipselink by eclipse-ee4j.
the class TestUpdateAggregateAggregateMapMapping method verify.
@Override
public void verify() {
getSession().getIdentityMapAccessor().initializeIdentityMaps();
Object initialHolder = holders.get(0);
holders = getSession().readAllObjects(AggregateAggregateMapHolder.class, holderExp);
AggregateAggregateMapHolder holder = (AggregateAggregateMapHolder) holders.get(0);
if (!compareObjects(holder, initialHolder)) {
throw new TestErrorException("Objects do not match reinitialize");
}
AggregateMapKey key = new AggregateMapKey();
key.setKey(11);
if (holder.getAggregateToAggregateMap().containsKey(key)) {
throw new TestErrorException("Item that was removed is still present in map.");
}
key = new AggregateMapKey();
key.setKey(33);
AggregateMapKey value = (AggregateMapKey) holder.getAggregateToAggregateMap().get(key);
if (value.getKey() != 3) {
throw new TestErrorException("Item was not correctly added to map");
}
}
use of org.eclipse.persistence.testing.models.collections.map.AggregateAggregateMapHolder in project eclipselink by eclipse-ee4j.
the class TestUpdateAggregateAggregateMapMapping method test.
@Override
public void test() {
UnitOfWork uow = getSession().acquireUnitOfWork();
holders = uow.readAllObjects(AggregateAggregateMapHolder.class, holderExp);
AggregateAggregateMapHolder holder = (AggregateAggregateMapHolder) holders.get(0);
AggregateMapKey key = new AggregateMapKey();
key.setKey(11);
holder.removeAggregateToAggregateMapItem(key);
AggregateMapKey mapValue = new AggregateMapKey();
mapValue.setKey(3);
key = new AggregateMapKey();
key.setKey(33);
holder.addAggregateToAggregateMapItem(key, mapValue);
uow.commit();
Object holderForComparison = uow.readObject(holder);
if (!compareObjects(holder, holderForComparison)) {
throw new TestErrorException("Objects do not match after write");
}
}
use of org.eclipse.persistence.testing.models.collections.map.AggregateAggregateMapHolder in project eclipselink by eclipse-ee4j.
the class TestReadAggregateAggregateMapMapping method verify.
@Override
public void verify() {
if (holders == null || holders.size() != 1) {
throw new TestErrorException("Incorrect number of MapHolders was read.");
}
AggregateAggregateMapHolder holder = (AggregateAggregateMapHolder) holders.get(0);
if (!((IndirectMap) holder.getAggregateToAggregateMap()).getValueHolder().isInstantiated() && fetchJoinRelationship > 0) {
throw new TestErrorException("Relationship was not properly joined.");
}
if (holder.getAggregateToAggregateMap().size() != 2) {
throw new TestErrorException("Incorrect Number of MapEntityValues was read.");
}
AggregateMapKey mapKey = new AggregateMapKey();
mapKey.setKey(11);
AggregateMapKey value = (AggregateMapKey) holder.getAggregateToAggregateMap().get(mapKey);
if (value.getKey() != 1) {
throw new TestErrorException("Incorrect MapEntityValues was read.");
}
}
use of org.eclipse.persistence.testing.models.collections.map.AggregateAggregateMapHolder in project eclipselink by eclipse-ee4j.
the class TestReadAggregateAggregateMapMapping method setup.
@Override
public void setup() {
mapping = (AggregateCollectionMapping) getSession().getProject().getDescriptor(AggregateAggregateMapHolder.class).getMappingForAttributeName("aggregateToAggregateMap");
oldFetchJoinValue = mapping.getJoinFetch();
mapping.setJoinFetch(fetchJoinRelationship);
getSession().getProject().getDescriptor(AggregateAggregateMapHolder.class).reInitializeJoinedAttributes();
UnitOfWork uow = getSession().acquireUnitOfWork();
AggregateAggregateMapHolder holder = new AggregateAggregateMapHolder();
AggregateMapKey value = new AggregateMapKey();
value.setKey(1);
AggregateMapKey key = new AggregateMapKey();
key.setKey(11);
holder.addAggregateToAggregateMapItem(key, value);
AggregateMapKey value2 = new AggregateMapKey();
value2.setKey(2);
key = new AggregateMapKey();
key.setKey(22);
holder.addAggregateToAggregateMapItem(key, value2);
uow.registerObject(holder);
uow.commit();
holderExp = (new ExpressionBuilder()).get("id").equal(holder.getId());
getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
}
Aggregations