Search in sources :

Example 11 with ValueStore

use of org.eclipse.persistence.sdo.ValueStore in project eclipselink by eclipse-ee4j.

the class ChangeSummaryXSDWithCSonRootUndoTestCases method testUnsetItemsResetAndUndo_MultiOperation_UnsetComplexSingleWithManyChildBelowRootResetAndUndo.

public void testUnsetItemsResetAndUndo_MultiOperation_UnsetComplexSingleWithManyChildBelowRootResetAndUndo() {
    // save original root for later comparison after undo
    DataObject originalRootDO = copyHelper.copy(rootObject);
    assertTrue(equalityHelper.equal(rootObject, originalRootDO));
    DataObject itemsDO = rootObject.getDataObject("items");
    DataObject item1DO = rootObject.getDataObject("items/item[1]");
    DataObject item2DO = rootObject.getDataObject("items/item[2]");
    DataObject item1ProductDO = item1DO.getDataObject("product");
    DataObject item1ProductPrice1DO = item1ProductDO.getDataObject("price[1]");
    DataObject item1ProductPrice2DO = item1ProductDO.getDataObject("price[2]");
    DataObject item2ProductDO = item2DO.getDataObject("product");
    DataObject item2ProductPrice1DO = item2ProductDO.getDataObject("price[1]");
    DataObject item2ProductPrice2DO = item2ProductDO.getDataObject("price[2]");
    cs.beginLogging();
    // verify original VS is null and save a copy of current VS for object identity testing after undo
    assertValueStoresInitializedAfterLoggingOn(rootObject);
    // save a copy of current VS for object identity testing after undo
    ValueStore aCurrentValueStoreAfterLoggingFirstOn = ((SDODataObject) rootObject)._getCurrentValueStore();
    assertNotNull(itemsDO.getChangeSummary());
    rootObject.unset("items");
    boolean wasDeleted = false;
    // verify CS is null on removed trees
    assertChangeSummaryStatusIfClearedIfCSIsAncestor(itemsDO, true);
    // check valueStores
    assertValueStoresCopiedAndSwappedAfterFirstModifyOperation(rootObject, aCurrentValueStoreAfterLoggingFirstOn);
    assertNotNull(item1DO);
    assertNotNull(item2DO);
    assertModified(rootObject, cs);
    // 20070206 CS is not being deleted
    assertDetached(itemsDO, cs);
    assertDetached(item1DO, cs, wasDeleted);
    assertDetached(item2DO, cs, wasDeleted);
    assertDetached(item1ProductDO, cs, wasDeleted);
    assertDetached(item1ProductPrice1DO, cs, wasDeleted);
    assertDetached(item1ProductPrice2DO, cs, wasDeleted);
    assertDetached(item2ProductDO, cs, wasDeleted);
    assertDetached(item2ProductPrice1DO, cs, wasDeleted);
    assertDetached(item2ProductPrice2DO, cs, wasDeleted);
    assertEquals(10, cs.getChangedDataObjects().size());
    // from 9
    assertEquals(14, ((SDOChangeSummary) cs).getOldContainer().size());
    // from 9
    assertEquals(14, ((SDOChangeSummary) cs).getOldContainmentProperty().size());
    // set the items back  (in effect doing an undo)
    rootObject.set("items", itemsDO);
    assertUndoChangesEqualToOriginal(cs, rootObject, originalRootDO);
    // verify that property is reset
    assertTrue(rootObject.isSet("items"));
    // get back items object
    DataObject itemsDOundone = rootObject.getDataObject("items");
    // compare with original
    assertTrue(equalityHelper.equal(itemsDOundone, itemsDO));
    assertValueStoresReturnedToStartStateAfterUndoChanges(rootObject, aCurrentValueStoreAfterLoggingFirstOn);
}
Also used : DataObject(commonj.sdo.DataObject) SDODataObject(org.eclipse.persistence.sdo.SDODataObject) ValueStore(org.eclipse.persistence.sdo.ValueStore) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 12 with ValueStore

use of org.eclipse.persistence.sdo.ValueStore in project eclipselink by eclipse-ee4j.

the class ChangeSummaryXSDWithCSonChildUndoTestCases method testMoveUsingSetBetweenDifferentTreesInDifferentChangeSummarysAndUndo_MoveItemsInTree1CS1toTree2CS2.

// *  UC 10.3            move obj inside corp1.sales.po1 to itself
// * UC 10.3.1            move obj inside corp1.cs1 (same tree/same cs)
// * UC 10.3.2             swap obj inside corp1.cs1 (same tree/same cs)
// * UC 10.3.3             reset obj inside corp1.cs1 (same tree/same cs)
// * UC 10.6    .1        move corp2.sales.po1.obj to corp2.sales.obj (different tree/different cs) using single op set
// * UC 10.6.2        move corp2.sales.po1.obj to corp2.sales.obj (different tree/different cs) using dual op detach/set
public void testMoveUsingSetBetweenDifferentTreesInDifferentChangeSummarysAndUndo_MoveItemsInTree1CS1toTree2CS2() {
    // save original root for later comparison after undo
    DataObject originalRootDO = copyHelper.copy(rootObject);
    assertTrue(equalityHelper.equal(rootObject, originalRootDO));
    DataObject salesDO = rootObject.getDataObject("sales");
    DataObject salesDO2 = rootObject2.getDataObject("sales");
    DataObject salesPO1DO = salesDO.getDataObject("purchaseOrder[1]");
    DataObject originalSalesPO1DO = copyHelper.copy(salesPO1DO);
    assertTrue(equalityHelper.equal(salesPO1DO, originalSalesPO1DO));
    DataObject salesPO2DO = salesDO.getDataObject("purchaseOrder[2]");
    DataObject salesPO1DO2 = salesDO2.getDataObject("purchaseOrder[1]");
    DataObject salesPO2DO2 = salesDO2.getDataObject("purchaseOrder[2]");
    DataObject salesPO1BuyerDO = salesPO1DO.getDataObject("buyer");
    DataObject salesPO2BuyerDO = salesPO2DO.getDataObject("buyer");
    DataObject salesPO1BuyerDO2 = salesPO1DO2.getDataObject("buyer");
    DataObject salesPO2BuyerDO2 = salesPO2DO2.getDataObject("buyer");
    DataObject salesPO1ItemsDO = salesPO1DO.getDataObject("items");
    DataObject salesPO2ItemsDO = salesPO2DO.getDataObject("items");
    DataObject salesPO1ItemsDO2 = salesPO1DO2.getDataObject("items");
    DataObject salesPO2ItemsDO2 = salesPO2DO2.getDataObject("items");
    DataObject salesPO1Item1DO = salesPO1ItemsDO.getDataObject("item[1]");
    DataObject salesPO1Item2DO = salesPO1ItemsDO.getDataObject("item[2]");
    DataObject salesPO2Item1DO = salesPO2ItemsDO.getDataObject("item[1]");
    DataObject salesPO2Item2DO = salesPO2ItemsDO.getDataObject("item[2]");
    DataObject salesPO1Item1ProductDO = salesPO1Item1DO.getDataObject("product");
    DataObject salesPO1Item2ProductDO = salesPO1Item2DO.getDataObject("product");
    DataObject salesPO2Item1ProductDO = salesPO2Item1DO.getDataObject("product");
    DataObject salesPO2Item2ProductDO = salesPO2Item2DO.getDataObject("product");
    DataObject salesPO1Item1ProductPrice1DO = salesPO1Item1ProductDO.getDataObject("price[1]");
    DataObject salesPO1Item1ProductPrice2DO = salesPO1Item1ProductDO.getDataObject("price[2]");
    DataObject salesPO1Item2ProductPrice1DO = salesPO1Item2ProductDO.getDataObject("price[1]");
    DataObject salesPO1Item2ProductPrice2DO = salesPO1Item2ProductDO.getDataObject("price[2]");
    DataObject salesPO2Item1ProductPrice1DO = salesPO2Item1ProductDO.getDataObject("price[1]");
    DataObject salesPO2Item1ProductPrice2DO = salesPO2Item1ProductDO.getDataObject("price[2]");
    DataObject salesPO2Item2ProductPrice1DO = salesPO2Item2ProductDO.getDataObject("price[1]");
    DataObject salesPO2Item2ProductPrice2DO = salesPO2Item2ProductDO.getDataObject("price[2]");
    // DataObject developmentDO = rootObject.getDataObject("development");
    DataObject stock1DO = rootObject.getDataObject("stock[1]");
    DataObject stock2DO = rootObject.getDataObject("stock[2]");
    DataObject stock3DO = rootObject.getDataObject("stock[3]");
    assertNull(salesDO.getChangeSummary());
    assertNotNull(salesPO1DO.getChangeSummary());
    assertNotNull(salesPO2DO.getChangeSummary());
    assertNotNull(salesPO1ItemsDO.getChangeSummary());
    assertNotNull(salesPO2ItemsDO.getChangeSummary());
    assertNull(salesDO2.getChangeSummary());
    assertNotNull(salesPO1DO2.getChangeSummary());
    assertNotNull(salesPO2DO2.getChangeSummary());
    assertNotNull(salesPO1ItemsDO2.getChangeSummary());
    assertNotNull(salesPO2ItemsDO2.getChangeSummary());
    // preoperation setup
    // delete the original items on the 2nd tree
    salesPO1ItemsDO2.detach();
    DataObject originalSalesPO1DO2 = copyHelper.copy(salesPO1DO2);
    assertTrue(equalityHelper.equal(salesPO1DO2, originalSalesPO1DO2));
    salesPO1CS.beginLogging();
    salesPO2CS.beginLogging();
    stock1CS.beginLogging();
    stock2CS.beginLogging();
    stock3CS.beginLogging();
    salesPO1CS2.beginLogging();
    salesPO2CS2.beginLogging();
    stock1CS2.beginLogging();
    stock2CS2.beginLogging();
    stock3CS2.beginLogging();
    // verify original VS is null and save a copy of current VS for object identity testing after undo
    assertValueStoresInitializedAfterLoggingOn(salesPO1DO);
    assertValueStoresInitializedAfterLoggingOn(salesPO2DO);
    assertValueStoresInitializedAfterLoggingOn(stock1DO);
    assertValueStoresInitializedAfterLoggingOn(stock2DO);
    assertValueStoresInitializedAfterLoggingOn(stock3DO);
    // save a copy of current VS for object identity testing after undo
    ValueStore aCurrentValueStoreAfterLoggingFirstOn = ((SDODataObject) salesPO1DO)._getCurrentValueStore();
    // move from buyer to emp[1]
    salesPO1DO2.set("items", salesPO1ItemsDO);
    // salesDO.set("employee[2]", null); NPE
    boolean wasDeleted = false;
    boolean wasReattachedInContextOfSourceChangeSummary = false;
    boolean wasReattachedInContextOfDestinationChangeSummary = true;
    // buyer was set to null
    assertModified(salesPO1DO, salesPO1CS);
    // buyer was set to null
    assertModified(salesPO1DO2, salesPO1CS2);
    assertNull(salesPO1DO.get("items"));
    assertNotNull(salesPO1DO2.get("items"));
    // moving an object outside and reattaching in another tree with another cs clears it from the original cs tree
    assertDetached(salesPO1ItemsDO, salesPO1CS, wasDeleted, wasReattachedInContextOfSourceChangeSummary, false);
    assertCreated(salesPO1ItemsDO, salesPO1CS2);
    // assertUnchanged(someChildofBuyerDO, salesPO1CS);
    // 1 + 9
    assertEquals(10, salesPO1CS.getChangedDataObjects().size());
    assertEquals(16, ((SDOChangeSummary) salesPO1CS).getOldContainer().size());
    assertEquals(16, ((SDOChangeSummary) salesPO1CS).getOldContainmentProperty().size());
    assertEquals(2, salesPO1CS2.getChangedDataObjects().size());
    // 20070228: all copies of the CS now contain the full # of old* references
    assertEquals(7, ((SDOChangeSummary) salesPO1CS2).getOldContainer().size());
    assertEquals(7, ((SDOChangeSummary) salesPO1CS2).getOldContainmentProperty().size());
    // assertValueStoresReturnedToStartStateAfterUndoChanges(salesPO1DO, aCurrentValueStoreAfterLoggingFirstOn);
    // writeXML(rootObject, URINAME, TYPENAME, System.out);
    // undo first changeSummary
    assertUndoChangesEqualToOriginal(salesPO1CS, salesPO1DO, originalSalesPO1DO);
    // assertUndoChangesEqualToOriginal(salesPO1CS2, salesPO1DO2, originalSalesPO1DO2);
    // verify that the objects are returned back to their original stes
    // undo should bring back the deepcopy not the original
    assertNotNull(salesPO1DO.get("items"));
    assertNotNull(salesPO1DO2.get("items"));
    // undo 2nd changeSummary
    // assertUndoChangesEqualToOriginal(salesPO1CS, salesPO1DO, originalSalesPO1DO);
    assertUndoChangesEqualToOriginal(salesPO1CS2, salesPO1DO2, originalSalesPO1DO2);
    // verify that the objects are returned back to their original stes
    assertNotNull(salesPO1DO.get("items"));
    assertNull(salesPO1DO2.get("items"));
    List<DataObject> preOrderList = preOrderTraversalDataObjectList((SDODataObject) rootObject, false);
    assertEquals(62, preOrderList.size());
}
Also used : DataObject(commonj.sdo.DataObject) SDODataObject(org.eclipse.persistence.sdo.SDODataObject) ValueStore(org.eclipse.persistence.sdo.ValueStore) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 13 with ValueStore

use of org.eclipse.persistence.sdo.ValueStore in project eclipselink by eclipse-ee4j.

the class ChangeSummaryXSDWithCSonChildUndoTestCases method testMoveWithinSameTreeOutOfChangeSummaryAndUndo_MoveBuyerInCS1upasEmployeeOnParentWithoutCS.

// * UC 10.7            move corp1.sales.po1.obj to corp1.sales.po2.obj (same tree/different cs)
// * UC 10.8            move corp1.sales.obj above cs to corp2.sales.obj (different tree/no cs)
// * UC 10.9            move obj corp1.sales.obj above cs to itself
// * UC 10.9.1            move obj above cs (same tree/ no cs)
// * UC 10.9.2            swap obj above cs (same tree/ no cs)
// * UC 10.9.3            reset obj above cs (same tree/ no cs)
// * UC 10.1             move corp1.sales.po1.buyer outside/above cs1 to corp1.sales.emp[1] (same tree/ out of cs)
public void testMoveWithinSameTreeOutOfChangeSummaryAndUndo_MoveBuyerInCS1upasEmployeeOnParentWithoutCS() {
    // save original root for later comparison after undo
    DataObject originalRootDO = copyHelper.copy(rootObject);
    assertTrue(equalityHelper.equal(rootObject, originalRootDO));
    DataObject salesDO = rootObject.getDataObject("sales");
    DataObject salesPO1DO = salesDO.getDataObject("purchaseOrder[1]");
    DataObject originalSalesPO1DO = copyHelper.copy(salesPO1DO);
    assertTrue(equalityHelper.equal(salesPO1DO, originalSalesPO1DO));
    DataObject salesPO2DO = salesDO.getDataObject("purchaseOrder[2]");
    DataObject salesPO1BuyerDO = salesPO1DO.getDataObject("buyer");
    DataObject salesPO2BuyerDO = salesPO2DO.getDataObject("buyer");
    DataObject salesPO1ItemsDO = salesPO1DO.getDataObject("items");
    DataObject salesPO2ItemsDO = salesPO2DO.getDataObject("items");
    DataObject salesPO1Item1DO = salesPO1ItemsDO.getDataObject("item[1]");
    DataObject salesPO1Item2DO = salesPO1ItemsDO.getDataObject("item[2]");
    DataObject salesPO2Item1DO = salesPO2ItemsDO.getDataObject("item[1]");
    DataObject salesPO2Item2DO = salesPO2ItemsDO.getDataObject("item[2]");
    DataObject salesPO1Item1ProductDO = salesPO1Item1DO.getDataObject("product");
    DataObject salesPO1Item2ProductDO = salesPO1Item2DO.getDataObject("product");
    DataObject salesPO2Item1ProductDO = salesPO2Item1DO.getDataObject("product");
    DataObject salesPO2Item2ProductDO = salesPO2Item2DO.getDataObject("product");
    DataObject salesPO1Item1ProductPrice1DO = salesPO1Item1ProductDO.getDataObject("price[1]");
    DataObject salesPO1Item1ProductPrice2DO = salesPO1Item1ProductDO.getDataObject("price[2]");
    DataObject salesPO1Item2ProductPrice1DO = salesPO1Item2ProductDO.getDataObject("price[1]");
    DataObject salesPO1Item2ProductPrice2DO = salesPO1Item2ProductDO.getDataObject("price[2]");
    DataObject salesPO2Item1ProductPrice1DO = salesPO2Item1ProductDO.getDataObject("price[1]");
    DataObject salesPO2Item1ProductPrice2DO = salesPO2Item1ProductDO.getDataObject("price[2]");
    DataObject salesPO2Item2ProductPrice1DO = salesPO2Item2ProductDO.getDataObject("price[1]");
    DataObject salesPO2Item2ProductPrice2DO = salesPO2Item2ProductDO.getDataObject("price[2]");
    // DataObject developmentDO = rootObject.getDataObject("development");
    DataObject stock1DO = rootObject.getDataObject("stock[1]");
    DataObject stock2DO = rootObject.getDataObject("stock[2]");
    DataObject stock3DO = rootObject.getDataObject("stock[3]");
    assertNull(salesDO.getChangeSummary());
    assertNotNull(salesPO1DO.getChangeSummary());
    assertNotNull(salesPO2DO.getChangeSummary());
    assertNotNull(salesPO1ItemsDO.getChangeSummary());
    assertNotNull(salesPO2ItemsDO.getChangeSummary());
    // preoperation setup
    salesPO1CS.beginLogging();
    salesPO2CS.beginLogging();
    stock1CS.beginLogging();
    stock2CS.beginLogging();
    stock3CS.beginLogging();
    // verify original VS is null and save a copy of current VS for object identity testing after undo
    assertValueStoresInitializedAfterLoggingOn(salesPO1DO);
    assertValueStoresInitializedAfterLoggingOn(salesPO2DO);
    assertValueStoresInitializedAfterLoggingOn(stock1DO);
    assertValueStoresInitializedAfterLoggingOn(stock2DO);
    assertValueStoresInitializedAfterLoggingOn(stock3DO);
    // save a copy of current VS for object identity testing after undo
    ValueStore aCurrentValueStoreAfterLoggingFirstOn = ((SDODataObject) salesPO1DO)._getCurrentValueStore();
    // move from buyer to emp[1]
    salesDO.set("employee[1]", salesPO1BuyerDO);
    // salesDO.set("employee[2]", null); NPE
    boolean wasDeleted = false;
    boolean wasReattachedInContextOfAChangeSummary = false;
    // buyer was set to null
    assertModified(salesPO1DO, salesPO1CS);
    assertNull(salesPO1DO.get("buyer"));
    // moving an object outside and reattaching above clears it from the cs tree
    assertDetached(salesPO1BuyerDO, salesPO1CS, wasDeleted, wasReattachedInContextOfAChangeSummary, false);
    // assertUnchanged(someChildofBuyerDO, salesPO1CS);
    assertEquals(2, salesPO1CS.getChangedDataObjects().size());
    // from 14 (sales has 2 PO's not 1)
    assertEquals(16, ((SDOChangeSummary) salesPO1CS).getOldContainer().size());
    assertEquals(16, ((SDOChangeSummary) salesPO1CS).getOldContainmentProperty().size());
    // assertValueStoresReturnedToStartStateAfterUndoChanges(salesPO1DO, aCurrentValueStoreAfterLoggingFirstOn);
    // writeXML(rootObject, URINAME, TYPENAME, System.out);
    // undo will only work on the cs subtree, objects modified above - stay modified
    assertUndoChangesEqualToOriginal(salesPO1CS, salesPO1DO, originalSalesPO1DO);
    // verify that the object above the tree is still set
    assertNotNull(salesDO.get("employee[1]"));
    assertNotNull(salesPO1DO.get("buyer"));
    List<DataObject> preOrderList = preOrderTraversalDataObjectList((SDODataObject) rootObject, false);
    assertEquals(63, preOrderList.size());
}
Also used : DataObject(commonj.sdo.DataObject) SDODataObject(org.eclipse.persistence.sdo.SDODataObject) ValueStore(org.eclipse.persistence.sdo.ValueStore) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 14 with ValueStore

use of org.eclipse.persistence.sdo.ValueStore in project eclipselink by eclipse-ee4j.

the class ChangeSummaryXSDWithCSonChildUndoTestCases method testMoveBetweenDifferentTreesOutOfChangeSummaryAndUndo_MoveBuyerInCS1UpasEmployeeOnParentWithoutCSInDiffTree.

// * UC 10.4             move corp1.sales.po2.emp(buyer) outside/above cs1 to corp2 as sales.emp (diff tree/ out of cs)
public void testMoveBetweenDifferentTreesOutOfChangeSummaryAndUndo_MoveBuyerInCS1UpasEmployeeOnParentWithoutCSInDiffTree() {
    // save original root for later comparison after undo
    DataObject originalRootDO = copyHelper.copy(rootObject);
    assertTrue(equalityHelper.equal(rootObject, originalRootDO));
    DataObject salesDO = rootObject.getDataObject("sales");
    DataObject salesDO2 = rootObject2.getDataObject("sales");
    DataObject salesPO1DO = salesDO.getDataObject("purchaseOrder[1]");
    DataObject salesPO2DO = salesDO.getDataObject("purchaseOrder[2]");
    DataObject salesPO1DO2 = salesDO2.getDataObject("purchaseOrder[1]");
    DataObject salesPO2DO2 = salesDO2.getDataObject("purchaseOrder[2]");
    DataObject salesPO1BuyerDO = salesPO1DO.getDataObject("buyer");
    DataObject salesPO2BuyerDO = salesPO2DO.getDataObject("buyer");
    DataObject salesPO1BuyerDO2 = salesPO1DO2.getDataObject("buyer");
    DataObject salesPO2BuyerDO2 = salesPO2DO2.getDataObject("buyer");
    DataObject salesPO1ItemsDO = salesPO1DO.getDataObject("items");
    DataObject salesPO2ItemsDO = salesPO2DO.getDataObject("items");
    DataObject salesPO1ItemsDO2 = salesPO1DO2.getDataObject("items");
    DataObject salesPO2ItemsDO2 = salesPO2DO2.getDataObject("items");
    DataObject salesPO1Item1DO = salesPO1ItemsDO.getDataObject("item[1]");
    DataObject salesPO1Item2DO = salesPO1ItemsDO.getDataObject("item[2]");
    DataObject salesPO2Item1DO = salesPO2ItemsDO.getDataObject("item[1]");
    DataObject salesPO2Item2DO = salesPO2ItemsDO.getDataObject("item[2]");
    DataObject salesPO1Item1ProductDO = salesPO1Item1DO.getDataObject("product");
    DataObject salesPO1Item2ProductDO = salesPO1Item2DO.getDataObject("product");
    DataObject salesPO2Item1ProductDO = salesPO2Item1DO.getDataObject("product");
    DataObject salesPO2Item2ProductDO = salesPO2Item2DO.getDataObject("product");
    DataObject salesPO1Item1ProductPrice1DO = salesPO1Item1ProductDO.getDataObject("price[1]");
    DataObject salesPO1Item1ProductPrice2DO = salesPO1Item1ProductDO.getDataObject("price[2]");
    DataObject salesPO1Item2ProductPrice1DO = salesPO1Item2ProductDO.getDataObject("price[1]");
    DataObject salesPO1Item2ProductPrice2DO = salesPO1Item2ProductDO.getDataObject("price[2]");
    DataObject salesPO2Item1ProductPrice1DO = salesPO2Item1ProductDO.getDataObject("price[1]");
    DataObject salesPO2Item1ProductPrice2DO = salesPO2Item1ProductDO.getDataObject("price[2]");
    DataObject salesPO2Item2ProductPrice1DO = salesPO2Item2ProductDO.getDataObject("price[1]");
    DataObject salesPO2Item2ProductPrice2DO = salesPO2Item2ProductDO.getDataObject("price[2]");
    // DataObject developmentDO = rootObject.getDataObject("development");
    DataObject stock1DO = rootObject.getDataObject("stock[1]");
    DataObject stock2DO = rootObject.getDataObject("stock[2]");
    DataObject stock3DO = rootObject.getDataObject("stock[3]");
    assertNull(salesDO.getChangeSummary());
    assertNotNull(salesPO1DO.getChangeSummary());
    assertNotNull(salesPO2DO.getChangeSummary());
    assertNotNull(salesPO1ItemsDO.getChangeSummary());
    assertNotNull(salesPO2ItemsDO.getChangeSummary());
    assertNull(salesDO2.getChangeSummary());
    assertNotNull(salesPO1DO2.getChangeSummary());
    assertNotNull(salesPO2DO2.getChangeSummary());
    assertNotNull(salesPO1ItemsDO2.getChangeSummary());
    assertNotNull(salesPO2ItemsDO2.getChangeSummary());
    // preoperation setup
    // move from buyer to emp[1] on tree2
    // salesDO2.set("employee[1]", salesPO1BuyerDO2);
    // delete buyer on tree1
    // salesPO1BuyerDO.delete();
    assertEquals(0, salesDO2.getList("employee").size());
    salesPO1CS.beginLogging();
    salesPO2CS.beginLogging();
    stock1CS.beginLogging();
    stock2CS.beginLogging();
    stock3CS.beginLogging();
    salesPO1CS2.beginLogging();
    salesPO2CS2.beginLogging();
    stock1CS2.beginLogging();
    stock2CS2.beginLogging();
    stock3CS2.beginLogging();
    // verify original VS is null and save a copy of current VS for object identity testing after undo
    assertValueStoresInitializedAfterLoggingOn(salesPO1DO);
    assertValueStoresInitializedAfterLoggingOn(salesPO2DO);
    assertValueStoresInitializedAfterLoggingOn(stock1DO);
    assertValueStoresInitializedAfterLoggingOn(stock2DO);
    assertValueStoresInitializedAfterLoggingOn(stock3DO);
    // save a copy of current VS for object identity testing after undo
    ValueStore aCurrentValueStoreAfterLoggingFirstOn = ((SDODataObject) salesPO1DO)._getCurrentValueStore();
    // move from buyer to emp[1]
    // salesPO1DO.set("buyer", salesEmp1DO2);
    salesDO2.set("employee[1]", salesPO1BuyerDO);
    // salesDO.set("employee[2]", null); NPE
    boolean wasDeleted = false;
    boolean wasReattachedInContextOfAChangeSummary = false;
    // buyer was set to null
    assertModified(salesPO1DO, salesPO1CS);
    assertNull(salesPO1DO.get("buyer"));
    // moving an object outside and reattaching above clears it from the cs tree
    assertDetached(salesPO1BuyerDO, salesPO1CS, wasDeleted, wasReattachedInContextOfAChangeSummary, false);
    // assertUnchanged(someChildofBuyerDO, salesPO1CS);
    assertEquals(2, salesPO1CS.getChangedDataObjects().size());
    // from 14 (sales has 2 PO's not 1)
    assertEquals(16, ((SDOChangeSummary) salesPO1CS).getOldContainer().size());
    assertEquals(16, ((SDOChangeSummary) salesPO1CS).getOldContainmentProperty().size());
// assertValueStoresReturnedToStartStateAfterUndoChanges(salesPO1DO, aCurrentValueStoreAfterLoggingFirstOn);
// writeXML(rootObject, URINAME, TYPENAME, System.out);
// null xpath for create
}
Also used : DataObject(commonj.sdo.DataObject) SDODataObject(org.eclipse.persistence.sdo.SDODataObject) ValueStore(org.eclipse.persistence.sdo.ValueStore) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 15 with ValueStore

use of org.eclipse.persistence.sdo.ValueStore in project eclipselink by eclipse-ee4j.

the class ChangeSummaryXSDWithCSonChildUndoTestCases method testMoveWithinSameTreeIntoChildChangeSummaryAndUndo_MoveEmployeeDownIntoCS1asBuyerOfCurrentWithoutCS.

// * UC 10.2             move corp1.sales.emp[1] inside/down to cs1 as sales.po1.buyer (same tree/ into cs)
public void testMoveWithinSameTreeIntoChildChangeSummaryAndUndo_MoveEmployeeDownIntoCS1asBuyerOfCurrentWithoutCS() {
    // save original root for later comparison after undo
    DataObject originalRootDO = copyHelper.copy(rootObject);
    assertTrue(equalityHelper.equal(rootObject, originalRootDO));
    DataObject salesDO = rootObject.getDataObject("sales");
    DataObject salesPO1DO = salesDO.getDataObject("purchaseOrder[1]");
    DataObject salesPO2DO = salesDO.getDataObject("purchaseOrder[2]");
    DataObject salesPO1BuyerDO = salesPO1DO.getDataObject("buyer");
    DataObject salesPO2BuyerDO = salesPO2DO.getDataObject("buyer");
    DataObject salesPO1ItemsDO = salesPO1DO.getDataObject("items");
    DataObject salesPO2ItemsDO = salesPO2DO.getDataObject("items");
    DataObject salesPO1Item1DO = salesPO1ItemsDO.getDataObject("item[1]");
    DataObject salesPO1Item2DO = salesPO1ItemsDO.getDataObject("item[2]");
    DataObject salesPO2Item1DO = salesPO2ItemsDO.getDataObject("item[1]");
    DataObject salesPO2Item2DO = salesPO2ItemsDO.getDataObject("item[2]");
    DataObject salesPO1Item1ProductDO = salesPO1Item1DO.getDataObject("product");
    DataObject salesPO1Item2ProductDO = salesPO1Item2DO.getDataObject("product");
    DataObject salesPO2Item1ProductDO = salesPO2Item1DO.getDataObject("product");
    DataObject salesPO2Item2ProductDO = salesPO2Item2DO.getDataObject("product");
    DataObject salesPO1Item1ProductPrice1DO = salesPO1Item1ProductDO.getDataObject("price[1]");
    DataObject salesPO1Item1ProductPrice2DO = salesPO1Item1ProductDO.getDataObject("price[2]");
    DataObject salesPO1Item2ProductPrice1DO = salesPO1Item2ProductDO.getDataObject("price[1]");
    DataObject salesPO1Item2ProductPrice2DO = salesPO1Item2ProductDO.getDataObject("price[2]");
    DataObject salesPO2Item1ProductPrice1DO = salesPO2Item1ProductDO.getDataObject("price[1]");
    DataObject salesPO2Item1ProductPrice2DO = salesPO2Item1ProductDO.getDataObject("price[2]");
    DataObject salesPO2Item2ProductPrice1DO = salesPO2Item2ProductDO.getDataObject("price[1]");
    DataObject salesPO2Item2ProductPrice2DO = salesPO2Item2ProductDO.getDataObject("price[2]");
    // DataObject developmentDO = rootObject.getDataObject("development");
    DataObject stock1DO = rootObject.getDataObject("stock[1]");
    DataObject stock2DO = rootObject.getDataObject("stock[2]");
    DataObject stock3DO = rootObject.getDataObject("stock[3]");
    assertNull(salesDO.getChangeSummary());
    assertNotNull(salesPO1DO.getChangeSummary());
    assertNotNull(salesPO2DO.getChangeSummary());
    assertNotNull(salesPO1ItemsDO.getChangeSummary());
    assertNotNull(salesPO2ItemsDO.getChangeSummary());
    // preoperation setup
    // move from buyer to emp[1]
    salesDO.set("employee[1]", salesPO1BuyerDO);
    DataObject originalSalesPO1DO = copyHelper.copy(salesPO1DO);
    assertTrue(equalityHelper.equal(salesPO1DO, originalSalesPO1DO));
    DataObject salesEmp1DO = salesDO.getDataObject("employee[1]");
    salesPO1CS.beginLogging();
    salesPO2CS.beginLogging();
    stock1CS.beginLogging();
    stock2CS.beginLogging();
    stock3CS.beginLogging();
    // verify original VS is null and save a copy of current VS for object identity testing after undo
    assertValueStoresInitializedAfterLoggingOn(salesPO1DO);
    assertValueStoresInitializedAfterLoggingOn(salesPO2DO);
    assertValueStoresInitializedAfterLoggingOn(stock1DO);
    assertValueStoresInitializedAfterLoggingOn(stock2DO);
    assertValueStoresInitializedAfterLoggingOn(stock3DO);
    // save a copy of current VS for object identity testing after undo
    ValueStore aCurrentValueStoreAfterLoggingFirstOn = ((SDODataObject) salesPO1DO)._getCurrentValueStore();
    // move from buyer to emp[1]
    salesPO1DO.set("buyer", salesEmp1DO);
    // salesDO.set("employee[2]", null); NPE
    boolean wasDeleted = false;
    boolean wasReattachedInContextOfAChangeSummary = false;
    // buyer was set to null
    assertModified(salesPO1DO, salesPO1CS);
    assertEquals(0, salesDO.getList("employee").size());
    // moving an object outside and reattaching above clears it from the cs tree
    // , wasDeleted, wasReattachedInContextOfAChangeSummary, false);
    assertCreated(salesEmp1DO, salesPO1CS);
    // assertUnchanged(someChildofBuyerDO, salesPO1CS);
    assertEquals(2, salesPO1CS.getChangedDataObjects().size());
    // from 14 (sales has 2 PO's not 1)
    assertEquals(15, ((SDOChangeSummary) salesPO1CS).getOldContainer().size());
    assertEquals(15, ((SDOChangeSummary) salesPO1CS).getOldContainmentProperty().size());
    // assertValueStoresReturnedToStartStateAfterUndoChanges(salesPO1DO, aCurrentValueStoreAfterLoggingFirstOn);
    // writeXML(rootObject, URINAME, TYPENAME, System.out);
    // undo will only work on the cs subtree, objects modified above - stay modified
    assertUndoChangesEqualToOriginal(salesPO1CS, salesPO1DO, originalSalesPO1DO);
    // verify that the object above the tree is still set
    assertEquals(0, salesDO.getList("employee").size());
    assertNull(salesPO1DO.get("buyer"));
}
Also used : DataObject(commonj.sdo.DataObject) SDODataObject(org.eclipse.persistence.sdo.SDODataObject) ValueStore(org.eclipse.persistence.sdo.ValueStore) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Aggregations

SDODataObject (org.eclipse.persistence.sdo.SDODataObject)22 ValueStore (org.eclipse.persistence.sdo.ValueStore)22 DataObject (commonj.sdo.DataObject)17 SDOChangeSummary (org.eclipse.persistence.sdo.SDOChangeSummary)17 Property (commonj.sdo.Property)3 DefaultValueStore (org.eclipse.persistence.sdo.DefaultValueStore)3 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 SDOProperty (org.eclipse.persistence.sdo.SDOProperty)1 SDOSequence (org.eclipse.persistence.sdo.SDOSequence)1