Search in sources :

Example 1 with AbstractOrder

use of org.eclipse.persistence.testing.models.transparentindirection.AbstractOrder in project eclipselink by eclipse-ee4j.

the class IndirectContainerTestDatabase method testUOWNewObject.

public void testUOWNewObject() {
    UnitOfWork uow = this.getSession().acquireUnitOfWork();
    AbstractOrder originalOrder = this.buildTestOrder2();
    uow.registerObject(originalOrder);
    uow.commit();
    this.getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
    AbstractOrder key = this.buildOrderShell();
    key.id = originalOrder.id;
    AbstractOrder orderFromDB = (AbstractOrder) this.getSession().readObject(key);
    this.compareOrders(originalOrder, orderFromDB);
}
Also used : AbstractOrder(org.eclipse.persistence.testing.models.transparentindirection.AbstractOrder)

Example 2 with AbstractOrder

use of org.eclipse.persistence.testing.models.transparentindirection.AbstractOrder in project eclipselink by eclipse-ee4j.

the class IndirectContainerTestDatabase method testUOWRemoveContact.

/**
 */
public void testUOWRemoveContact() {
    UnitOfWork uow = this.getSession().acquireUnitOfWork();
    AbstractOrder key = this.buildOrderShell();
    key.id = originalID;
    AbstractOrder orderFromDB = (AbstractOrder) uow.readObject(key);
    String contact = (String) orderFromDB.getContactStream().nextElement();
    orderFromDB.removeContact(contact);
    uow.commit();
    this.getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
    orderFromDB = (AbstractOrder) this.getSession().readObject(key);
    assertTrue("The contacts should NOT be populated.", !((IndirectContainer) orderFromDB.getContactContainer()).isInstantiated());
    assertEquals("The number of contacts is incorrect.", this.buildTestOrder1().getNumberOfContacts() - 1, orderFromDB.getNumberOfContacts());
    assertTrue("Removed contact still present.", !orderFromDB.containsContact(contact));
}
Also used : AbstractOrder(org.eclipse.persistence.testing.models.transparentindirection.AbstractOrder) IndirectContainer(org.eclipse.persistence.indirection.IndirectContainer)

Example 3 with AbstractOrder

use of org.eclipse.persistence.testing.models.transparentindirection.AbstractOrder in project eclipselink by eclipse-ee4j.

the class IndirectContainerTestDatabase method testRefreshObject.

/**
 */
public void testRefreshObject() {
    AbstractOrder key = this.buildOrderShell();
    key.id = originalID;
    AbstractOrder orderFromDB = (AbstractOrder) this.getSession().readObject(key);
    assertTrue("The order lines should NOT be populated.", !((IndirectContainer) orderFromDB.getLineContainer()).isInstantiated());
    AbstractOrderLine orderLine = (AbstractOrderLine) orderFromDB.getLineStream().nextElement();
    assertTrue("The order lines should be populated.", ((IndirectContainer) orderFromDB.getLineContainer()).isInstantiated());
    // there were problems with TransformationMappings, so make sure they work too
    AbstractOrder expected = this.buildTestOrder1();
    assertTrue("The total should NOT be instantiated yet.", !(orderFromDB.total.isInstantiated()));
    assertEquals("The total is incorrect.", expected.getTotal(), orderFromDB.getTotal());
    assertTrue("The total should be instantiated.", orderFromDB.total.isInstantiated());
    assertEquals("The total 2 is incorrect.", expected.total2, orderFromDB.total2);
    orderLine = (AbstractOrderLine) orderLine.clone();
    orderLine.itemName = "munged";
    this.getBackdoorSession().executeNonSelectingSQL("update ORDLINE set ITEM_NAME = '" + orderLine.itemName + "' where ID = " + orderLine.id);
    orderFromDB = (AbstractOrder) this.getSession().refreshObject(orderFromDB);
    assertTrue("The order lines should NOT be populated.", !((IndirectContainer) orderFromDB.getLineContainer()).isInstantiated());
    assertTrue("New order line not found.", orderFromDB.containsLine(orderLine));
    assertTrue("The order lines should be populated.", ((IndirectContainer) orderFromDB.getLineContainer()).isInstantiated());
    // there were problems with TransformationMappings, so make sure they work too
    assertTrue("The total should NOT be instantiated yet.", !(orderFromDB.total.isInstantiated()));
    assertEquals("The total is incorrect.", expected.getTotal(), orderFromDB.getTotal());
    assertTrue("The total should be instantiated.", orderFromDB.total.isInstantiated());
    assertEquals("The total 2 is incorrect.", expected.total2, orderFromDB.total2);
}
Also used : AbstractOrderLine(org.eclipse.persistence.testing.models.transparentindirection.AbstractOrderLine) AbstractOrder(org.eclipse.persistence.testing.models.transparentindirection.AbstractOrder) IndirectContainer(org.eclipse.persistence.indirection.IndirectContainer)

Example 4 with AbstractOrder

use of org.eclipse.persistence.testing.models.transparentindirection.AbstractOrder in project eclipselink by eclipse-ee4j.

the class IndirectContainerTestDatabase method testUOWAddContact.

/**
 */
public void testUOWAddContact() {
    UnitOfWork uow = this.getSession().acquireUnitOfWork();
    AbstractOrder key = this.buildOrderShell();
    key.id = originalID;
    AbstractOrder orderFromDB = (AbstractOrder) uow.readObject(key);
    String contact = this.buildTestContact1();
    orderFromDB.addContact(contact);
    uow.commit();
    this.getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
    orderFromDB = (AbstractOrder) this.getSession().readObject(key);
    assertTrue("The contacts should NOT be populated.", !((IndirectContainer) orderFromDB.getContactContainer()).isInstantiated());
    assertEquals("The number of contacts is incorrect.", this.buildTestOrder1().getNumberOfContacts() + 1, orderFromDB.getNumberOfContacts());
    assertTrue("New contact not found.", orderFromDB.containsContact(contact));
}
Also used : AbstractOrder(org.eclipse.persistence.testing.models.transparentindirection.AbstractOrder) IndirectContainer(org.eclipse.persistence.indirection.IndirectContainer)

Example 5 with AbstractOrder

use of org.eclipse.persistence.testing.models.transparentindirection.AbstractOrder 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)

Aggregations

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