use of org.eclipse.persistence.testing.models.collections.map.AggregateEntity1MMapHolder 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");
}
}
use of org.eclipse.persistence.testing.models.collections.map.AggregateEntity1MMapHolder 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.models.collections.map.AggregateEntity1MMapHolder in project eclipselink by eclipse-ee4j.
the class TestReadAggregateEntity1MMapMapping method reset.
@Override
public void reset() {
UnitOfWork uow = getSession().acquireUnitOfWork();
Iterator i = holders.iterator();
while (i.hasNext()) {
AggregateEntity1MMapHolder holder = (AggregateEntity1MMapHolder) i.next();
Iterator j = holder.getAggregateToEntityMap().keySet().iterator();
while (j.hasNext()) {
uow.deleteObject(holder.getAggregateToEntityMap().get(j.next()));
}
}
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.models.collections.map.AggregateEntity1MMapHolder in project eclipselink by eclipse-ee4j.
the class TestReadAggregateEntity1MMapMapping method verify.
@Override
public void verify() {
if (holders == null || holders.size() != 1) {
throw new TestErrorException("Incorrect number of MapHolders was read.");
}
AggregateEntity1MMapHolder holder = (AggregateEntity1MMapHolder) holders.get(0);
if (!((IndirectMap) holder.getAggregateToEntityMap()).getValueHolder().isInstantiated() && fetchJoinRelationship > 0) {
throw new TestErrorException("Relationship was not properly joined.");
}
if (holder.getAggregateToEntityMap().size() != 2) {
throw new TestErrorException("Incorrect Number of MapEntityValues was read.");
}
AggregateMapKey mapKey = new AggregateMapKey();
mapKey.setKey(11);
AEOTMMapValue value = (AEOTMMapValue) holder.getAggregateToEntityMap().get(mapKey);
if (value.getId() != 1) {
throw new TestErrorException("Incorrect MapEntityValues was read.");
}
}
use of org.eclipse.persistence.testing.models.collections.map.AggregateEntity1MMapHolder in project eclipselink by eclipse-ee4j.
the class TestReadAggregateEntity1MMapMapping method setup.
@Override
public void setup() {
mapping = (OneToManyMapping) getSession().getProject().getDescriptor(AggregateEntity1MMapHolder.class).getMappingForAttributeName("aggregateToEntityMap");
oldFetchJoinValue = mapping.getJoinFetch();
mapping.setJoinFetch(fetchJoinRelationship);
getSession().getProject().getDescriptor(AggregateEntity1MMapHolder.class).reInitializeJoinedAttributes();
UnitOfWork uow = getSession().acquireUnitOfWork();
AggregateEntity1MMapHolder holder = new AggregateEntity1MMapHolder();
AEOTMMapValue value = new AEOTMMapValue();
value.setId(1);
value.getHolder().setValue(holder);
AggregateMapKey key = new AggregateMapKey();
key.setKey(11);
holder.addAggregateToEntityMapItem(key, value);
AEOTMMapValue value2 = new AEOTMMapValue();
value2.setId(2);
value2.getHolder().setValue(holder);
key = new AggregateMapKey();
key.setKey(22);
holder.addAggregateToEntityMapItem(key, value2);
uow.registerObject(holder);
uow.registerObject(value);
uow.registerObject(value2);
uow.commit();
holderExp = (new ExpressionBuilder()).get("id").equal(holder.getId());
getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
}
Aggregations