use of org.eclipse.persistence.testing.models.transparentindirection.AbstractSalesRep in project eclipselink by eclipse-ee4j.
the class IndirectContainerTestDatabase method testUOWAddSalesRep.
/**
*/
public void testUOWAddSalesRep() {
UnitOfWork uow = this.getSession().acquireUnitOfWork();
AbstractOrder key = this.buildOrderShell();
key.id = originalID;
AbstractOrder orderFromDB = (AbstractOrder) uow.readObject(key);
AbstractSalesRep salesRep = this.buildTestSalesRep1();
orderFromDB.addSalesRep(salesRep);
uow.commit();
this.getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
orderFromDB = (AbstractOrder) this.getSession().readObject(key);
assertTrue("The sales reps should NOT be populated.", !((IndirectContainer) orderFromDB.getSalesRepContainer()).isInstantiated());
assertEquals("The number of sales reps is incorrect.", this.buildTestOrder1().getNumberOfSalesReps() + 1, orderFromDB.getNumberOfSalesReps());
assertTrue("New sales rep not found.", orderFromDB.containsSalesRep(salesRep));
}
use of org.eclipse.persistence.testing.models.transparentindirection.AbstractSalesRep in project eclipselink by eclipse-ee4j.
the class IndirectContainerTestDatabase method testUOWRemoveSalesRep.
/**
*/
public void testUOWRemoveSalesRep() {
UnitOfWork uow = this.getSession().acquireUnitOfWork();
AbstractOrder key = this.buildOrderShell();
key.id = originalID;
AbstractOrder orderFromDB = (AbstractOrder) uow.readObject(key);
AbstractSalesRep salesRep = (AbstractSalesRep) orderFromDB.getSalesRepStream().nextElement();
orderFromDB.removeSalesRep(salesRep);
uow.commit();
this.getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
orderFromDB = (AbstractOrder) this.getSession().readObject(key);
assertTrue("The sales reps should NOT be populated.", !((IndirectContainer) orderFromDB.getSalesRepContainer()).isInstantiated());
assertEquals("The number of sales reps is incorrect.", this.buildTestOrder1().getNumberOfSalesReps() - 1, orderFromDB.getNumberOfSalesReps());
assertTrue("Removed sales rep still present.", !orderFromDB.containsSalesRep(salesRep));
}
use of org.eclipse.persistence.testing.models.transparentindirection.AbstractSalesRep in project eclipselink by eclipse-ee4j.
the class IndirectContainerTestDatabase method testUOWRemoveSalesRep2.
/**
*/
public void testUOWRemoveSalesRep2() {
UnitOfWork uow = this.getSession().acquireUnitOfWork();
AbstractOrder key = this.buildOrderShell();
key.id = originalID;
AbstractOrder orderFromDB = (AbstractOrder) uow.readObject(key);
AbstractSalesRep salesRep = (AbstractSalesRep) orderFromDB.getSalesRepStream2().nextElement();
orderFromDB.removeSalesRep2(salesRep);
uow.commit();
this.getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
orderFromDB = (AbstractOrder) this.getSession().readObject(key);
assertEquals("The number of sales reps 2 is incorrect.", this.buildTestOrder1().getNumberOfSalesReps2() - 1, orderFromDB.getNumberOfSalesReps2());
assertTrue("Removed sales rep 2 still present.", !orderFromDB.containsSalesRep2(salesRep));
}
use of org.eclipse.persistence.testing.models.transparentindirection.AbstractSalesRep in project eclipselink by eclipse-ee4j.
the class IndirectMapTestDatabase method testKeysAndValues.
public void testKeysAndValues() {
AbstractOrder key = this.buildOrderShell();
key.id = originalID;
MappedOrder orderFromDB = (MappedOrder) getSession().readObject(key);
AbstractSalesRep tempSalesRep = (AbstractSalesRep) ((MappedOrder) this.buildTestOrder1()).salesReps.values().iterator().next();
assertEquals("Invalid sales rep key/value pair.", tempSalesRep.name, ((AbstractSalesRep) orderFromDB.salesReps.get(tempSalesRep.getKey())).name);
AbstractOrderLine tempLine = (AbstractOrderLine) ((MappedOrder) this.buildTestOrder1()).lines.values().iterator().next();
assertEquals("Invalid order line key/value pair.", tempLine.itemName, ((AbstractOrderLine) orderFromDB.lines.get(tempLine.getKey())).itemName);
}
use of org.eclipse.persistence.testing.models.transparentindirection.AbstractSalesRep in project eclipselink by eclipse-ee4j.
the class IndirectContainerTestDatabase method testUOWAddSalesRep2.
/**
*/
public void testUOWAddSalesRep2() {
UnitOfWork uow = this.getSession().acquireUnitOfWork();
AbstractOrder key = this.buildOrderShell();
key.id = originalID;
AbstractOrder orderFromDB = (AbstractOrder) uow.readObject(key);
AbstractSalesRep salesRep = this.buildTestSalesRep2();
orderFromDB.addSalesRep2(salesRep);
uow.commit();
this.getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
orderFromDB = (AbstractOrder) this.getSession().readObject(key);
assertEquals("The number of sales reps 2 is incorrect.", this.buildTestOrder1().getNumberOfSalesReps2() + 1, orderFromDB.getNumberOfSalesReps2());
assertTrue("New sales rep 2 not found.", orderFromDB.containsSalesRep2(salesRep));
}
Aggregations