Search in sources :

Example 1 with AbstractSalesRep

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));
}
Also used : AbstractSalesRep(org.eclipse.persistence.testing.models.transparentindirection.AbstractSalesRep) AbstractOrder(org.eclipse.persistence.testing.models.transparentindirection.AbstractOrder) IndirectContainer(org.eclipse.persistence.indirection.IndirectContainer)

Example 2 with AbstractSalesRep

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));
}
Also used : AbstractSalesRep(org.eclipse.persistence.testing.models.transparentindirection.AbstractSalesRep) AbstractOrder(org.eclipse.persistence.testing.models.transparentindirection.AbstractOrder) IndirectContainer(org.eclipse.persistence.indirection.IndirectContainer)

Example 3 with AbstractSalesRep

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));
}
Also used : AbstractSalesRep(org.eclipse.persistence.testing.models.transparentindirection.AbstractSalesRep) AbstractOrder(org.eclipse.persistence.testing.models.transparentindirection.AbstractOrder)

Example 4 with AbstractSalesRep

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);
}
Also used : AbstractSalesRep(org.eclipse.persistence.testing.models.transparentindirection.AbstractSalesRep) AbstractOrderLine(org.eclipse.persistence.testing.models.transparentindirection.AbstractOrderLine) MappedOrder(org.eclipse.persistence.testing.models.transparentindirection.MappedOrder) AbstractOrder(org.eclipse.persistence.testing.models.transparentindirection.AbstractOrder)

Example 5 with AbstractSalesRep

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));
}
Also used : AbstractSalesRep(org.eclipse.persistence.testing.models.transparentindirection.AbstractSalesRep) AbstractOrder(org.eclipse.persistence.testing.models.transparentindirection.AbstractOrder)

Aggregations

AbstractOrder (org.eclipse.persistence.testing.models.transparentindirection.AbstractOrder)5 AbstractSalesRep (org.eclipse.persistence.testing.models.transparentindirection.AbstractSalesRep)5 IndirectContainer (org.eclipse.persistence.indirection.IndirectContainer)2 AbstractOrderLine (org.eclipse.persistence.testing.models.transparentindirection.AbstractOrderLine)1 MappedOrder (org.eclipse.persistence.testing.models.transparentindirection.MappedOrder)1