use of org.eclipse.persistence.testing.models.collections.map.DirectAggregateMapHolder in project eclipselink by eclipse-ee4j.
the class TestUpdateDirectAggregateMapMapping method verify.
@Override
public void verify() {
getSession().getIdentityMapAccessor().initializeIdentityMaps();
Object initialHolder = holders.get(0);
holders = getSession().readAllObjects(DirectAggregateMapHolder.class, holderExp);
DirectAggregateMapHolder holder = (DirectAggregateMapHolder) holders.get(0);
if (!compareObjects(holder, changedHolder)) {
throw new TestErrorException("Objects do not match reinitialize");
}
if (holder.getDirectToAggregateMap().containsKey(1)) {
throw new TestErrorException("Item that was removed is still present in map.");
}
AggregateMapValue value = (AggregateMapValue) holder.getDirectToAggregateMap().get(3);
if (value.getValue() != 3) {
throw new TestErrorException("Item was not correctly added to map");
}
}
use of org.eclipse.persistence.testing.models.collections.map.DirectAggregateMapHolder in project eclipselink by eclipse-ee4j.
the class TestUpdateDirectAggregateMapMapping method test.
@Override
public void test() {
UnitOfWork uow = getSession().acquireUnitOfWork();
holders = uow.readAllObjects(DirectAggregateMapHolder.class, holderExp);
changedHolder = (DirectAggregateMapHolder) holders.get(0);
changedHolder.removeDirectToAggregateMapItem(1);
AggregateMapValue mapValue = new AggregateMapValue();
mapValue.setValue(3);
changedHolder.addDirectToAggregateMapItem(3, 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.models.collections.map.DirectAggregateMapHolder in project eclipselink by eclipse-ee4j.
the class TestReadDirectAggregateMapMapping method verify.
@Override
public void verify() {
if (holders == null || holders.size() != 1) {
throw new TestErrorException("Incorrect number of MapHolders was read.");
}
DirectAggregateMapHolder holder = (DirectAggregateMapHolder) holders.get(0);
if (!((IndirectMap) holder.getDirectToAggregateMap()).getValueHolder().isInstantiated() && fetchJoinRelationship > 0) {
throw new TestErrorException("Relationship was not properly joined.");
}
if (holder.getDirectToAggregateMap().size() != 2) {
throw new TestErrorException("Incorrect Number of Map values was read.");
}
AggregateMapValue value = (AggregateMapValue) holder.getDirectToAggregateMap().get(1);
if (value.getValue() != 1) {
throw new TestErrorException("Incorrect map value was read.");
}
}
use of org.eclipse.persistence.testing.models.collections.map.DirectAggregateMapHolder in project eclipselink by eclipse-ee4j.
the class TestReadDirectAggregateMapMapping method setup.
@Override
public void setup() {
mapping = (AggregateCollectionMapping) getSession().getProject().getDescriptor(DirectAggregateMapHolder.class).getMappingForAttributeName("directToAggregateMap");
oldFetchJoinValue = mapping.getJoinFetch();
mapping.setJoinFetch(fetchJoinRelationship);
getSession().getProject().getDescriptor(DirectAggregateMapHolder.class).reInitializeJoinedAttributes();
UnitOfWork uow = getSession().acquireUnitOfWork();
DirectAggregateMapHolder holder = new DirectAggregateMapHolder();
AggregateMapValue value = new AggregateMapValue();
value.setValue(1);
holder.addDirectToAggregateMapItem(1, value);
value = new AggregateMapValue();
value.setValue(2);
holder.addDirectToAggregateMapItem(2, value);
uow.registerObject(holder);
uow.commit();
holderExp = (new ExpressionBuilder()).get("id").equal(holder.getId());
getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
}
Aggregations