use of org.eclipse.persistence.testing.models.collections.map.AggregateMapValue 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.models.collections.map.AggregateMapValue in project eclipselink by eclipse-ee4j.
the class TestReadEntityAggregateMapMapping method setup.
@Override
public void setup() {
mapping = (AggregateCollectionMapping) getSession().getProject().getDescriptor(EntityAggregateMapHolder.class).getMappingForAttributeName("entityToAggregateMap");
oldFetchJoinValue = mapping.getJoinFetch();
mapping.setJoinFetch(fetchJoinRelationship);
getSession().getProject().getDescriptor(EntityAggregateMapHolder.class).reInitializeJoinedAttributes();
UnitOfWork uow = getSession().acquireUnitOfWork();
EntityAggregateMapHolder holder = new EntityAggregateMapHolder();
AggregateMapValue value = new AggregateMapValue();
value.setValue(1);
EntityMapKey key = new EntityMapKey();
key.setData("11");
key.setId(1);
holder.addEntityToAggregateMapItem(key, value);
uow.registerObject(key);
AggregateMapValue value2 = new AggregateMapValue();
value2.setValue(2);
key = new EntityMapKey();
key.setData("22");
key.setId(2);
holder.addEntityToAggregateMapItem(key, value2);
uow.registerObject(holder);
uow.registerObject(key);
uow.commit();
holderExp = (new ExpressionBuilder()).get("id").equal(holder.getId());
getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
}
use of org.eclipse.persistence.testing.models.collections.map.AggregateMapValue 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.AggregateMapValue in project eclipselink by eclipse-ee4j.
the class TestUpdateEntityAggregateMapMapping method verify.
@Override
public void verify() {
getSession().getIdentityMapAccessor().initializeIdentityMaps();
holders = getSession().readAllObjects(EntityAggregateMapHolder.class, holderExp);
EntityAggregateMapHolder holder = (EntityAggregateMapHolder) holders.get(0);
if (!compareObjects(holder, changedHolder)) {
throw new TestErrorException("Objects do not match reinitialize");
}
EntityMapKey key = new EntityMapKey();
key.setId(1);
if (holder.getEntityToAggregateMap().containsKey(key)) {
throw new TestErrorException("Item that was removed is still present in map.");
}
key = new EntityMapKey();
key.setId(3);
AggregateMapValue value = (AggregateMapValue) holder.getEntityToAggregateMap().get(key);
if (value.getValue() != 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);
key = (EntityMapKey) getSession().executeQuery(query);
if (key != null) {
throw new TestErrorException("PrivateOwned EntityMapKey was not deleted.");
}
}
}
use of org.eclipse.persistence.testing.models.collections.map.AggregateMapValue 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");
}
}
Aggregations