Search in sources :

Example 1 with ValueStore

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

the class SDOTestCase method assertValueStoresInitializedAfterLoggingOn.

/**
 */
// test undo when logging is off (with previous changes)
protected void assertValueStoresInitializedAfterLoggingOn(DataObject aRootObject) {
    // verify logging is on
    assertTrue(aRootObject.getChangeSummary().isLogging());
    // verify original VS is null and save a copy of current VS for object
    // identity testing after undo
    ValueStore aCurrentValueStore = ((SDODataObject) aRootObject)._getCurrentValueStore();
    assertNotNull(aCurrentValueStore);
    ValueStore anOriginalValueStore = (ValueStore) ((SDOChangeSummary) aRootObject.getChangeSummary()).getOriginalValueStores().get(aRootObject);
    assertNull(anOriginalValueStore);
}
Also used : ValueStore(org.eclipse.persistence.sdo.ValueStore) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 2 with ValueStore

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

the class SDOTestCase method assertValueStoresReturnedToStartStateAfterUndoChanges.

/**
 */
protected void assertValueStoresReturnedToStartStateAfterUndoChanges(DataObject aRootObject, ValueStore aCurrentValueStoreAfterLoggingFirstOnParam) {
    // verify logging is on
    assertTrue(aRootObject.getChangeSummary().isLogging());
    ValueStore anOriginalValueStoreAfterUndo = (ValueStore) ((SDOChangeSummary) aRootObject.getChangeSummary()).getOriginalValueStores().get(aRootObject);
    ValueStore aCurrentValueStoreAfterUndo = ((SDODataObject) aRootObject)._getCurrentValueStore();
    assertNull(anOriginalValueStoreAfterUndo);
    assertNotNull(aCurrentValueStoreAfterUndo);
    // we return the original value store back to the current VS
    assertTrue(aCurrentValueStoreAfterUndo == aCurrentValueStoreAfterLoggingFirstOnParam);
}
Also used : ValueStore(org.eclipse.persistence.sdo.ValueStore) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 3 with ValueStore

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

the class SDOTestCase method assertValueStoresCopiedAndSwappedAfterFirstModifyOperation.

/**
 */
protected void assertValueStoresCopiedAndSwappedAfterFirstModifyOperation(DataObject aRootObject, ValueStore aCurrentValueStoreAfterLoggingFirstOnParam) {
    // verify logging is on
    assertTrue(aRootObject.getChangeSummary().isLogging());
    assertNotNull(aCurrentValueStoreAfterLoggingFirstOnParam);
    ValueStore anOriginalValueStoreAfterOperation = (ValueStore) ((SDOChangeSummary) aRootObject.getChangeSummary()).getOriginalValueStores().get(aRootObject);
    ValueStore aCurrentValueStoreAfterOperation = ((SDODataObject) aRootObject)._getCurrentValueStore();
    assertNotNull(anOriginalValueStoreAfterOperation);
    assertNotNull(aCurrentValueStoreAfterOperation);
    assertTrue(anOriginalValueStoreAfterOperation == aCurrentValueStoreAfterLoggingFirstOnParam);
}
Also used : ValueStore(org.eclipse.persistence.sdo.ValueStore) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 4 with ValueStore

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

the class ChangeSummaryXSDwSeqTestCases method testDeleteItemsAndUndo.

public void testDeleteItemsAndUndo() {
    // 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
    ValueStore aCurrentValueStore = ((SDODataObject) rootObject)._getCurrentValueStore();
    assertNotNull(aCurrentValueStore);
    ValueStore anOriginalValueStore = (ValueStore) ((SDOChangeSummary) cs).getOriginalValueStores().get(rootObject);
    assertNull(anOriginalValueStore);
    itemsDO.delete();
    // check valueStores
    assertNotNull(aCurrentValueStore);
    ValueStore anOriginalValueStoreAfterOperation = (ValueStore) ((SDOChangeSummary) cs).getOriginalValueStores().get(rootObject);
    ValueStore aCurrentValueStoreAfterOperation = ((SDODataObject) rootObject)._getCurrentValueStore();
    assertNotNull(anOriginalValueStoreAfterOperation);
    assertNotNull(aCurrentValueStoreAfterOperation);
    assertTrue(anOriginalValueStoreAfterOperation == aCurrentValueStore);
    assertNotNull(item1DO);
    assertNotNull(item2DO);
    assertModified(rootObject, cs);
    assertDeleted(itemsDO, cs);
    assertDeleted(item1DO, cs);
    assertDeleted(item2DO, cs);
    assertDeleted(item1ProductDO, cs);
    assertDeleted(item1ProductPrice1DO, cs);
    assertDeleted(item1ProductPrice2DO, cs);
    assertDeleted(item2ProductDO, cs);
    assertDeleted(item2ProductPrice1DO, cs);
    assertDeleted(item2ProductPrice2DO, cs);
    assertEquals(10, cs.getChangedDataObjects().size());
    // from 9
    assertEquals(14, ((SDOChangeSummary) cs).getOldContainer().size());
    // from 9
    assertEquals(14, ((SDOChangeSummary) cs).getOldContainmentProperty().size());
    assertUndoChangesEqualToOriginal(cs, rootObject, originalRootDO);
    // verify that property is reset
    assertTrue(rootObject.isSet("items"));
    // get back items object
    DataObject itemsDOundone = rootObject.getDataObject("items");
    ValueStore anOriginalValueStoreAfterUndo = (ValueStore) ((SDOChangeSummary) cs).getOriginalValueStores().get(rootObject);
    ValueStore aCurrentValueStoreAfterUndo = ((SDODataObject) rootObject)._getCurrentValueStore();
    assertNull(anOriginalValueStoreAfterUndo);
    assertNotNull(aCurrentValueStoreAfterUndo);
    // we return the original value store back to the current VS
    assertTrue(aCurrentValueStoreAfterUndo == aCurrentValueStore);
}
Also used : SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) ValueStore(org.eclipse.persistence.sdo.ValueStore) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 5 with ValueStore

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

the class ChangeSummaryUndoChangeTest method testUndoChangeAfterChangeDataObjectContainer.

// purpose: after logging, change property value, and undoChange() should bring the
// original value back to property
public void testUndoChangeAfterChangeDataObjectContainer() {
    SDODataObject original = (SDODataObject) copyHelper.copy(root);
    // logging
    changeSummary.beginLogging();
    // verify original VS is null and save a copy of current VS for object identity testing after undo
    ValueStore aCurrentValueStore = root._getCurrentValueStore();
    assertNotNull(aCurrentValueStore);
    ValueStore anOriginalValueStore = (ValueStore) changeSummary.getOriginalValueStores().get(root);
    assertNull(anOriginalValueStore);
    assertNotNull(containedDataObject.getChangeSummary());
    // unset property
    root.unset(rootProperty);
    // verify CS is null on removed trees
    assertChangeSummaryStatusIfClearedIfCSIsAncestor(containedDataObject, true);
    assertNotNull(aCurrentValueStore);
    ValueStore anOriginalValueStoreAfterOperation = (ValueStore) changeSummary.getOriginalValueStores().get(root);
    ValueStore aCurrentValueStoreAfterOperation = root._getCurrentValueStore();
    assertNotNull(anOriginalValueStoreAfterOperation);
    assertNotNull(aCurrentValueStoreAfterOperation);
    assertTrue(anOriginalValueStoreAfterOperation == aCurrentValueStore);
    assertFalse(root.isSet(rootProperty));
    // make sure it is changed
    assertNull(containedDataObject.getContainer());
    // undo and verify equality
    assertUndoChangesEqualToOriginal(changeSummary, root, original);
    // verify that property is reset
    assertTrue(root.isSet(rootProperty));
    // we have object identity
    assertTrue(equalityHelper.equal(original, root));
    ValueStore anOriginalValueStoreAfterUndo = (ValueStore) changeSummary.getOriginalValueStores().get(root);
    ValueStore aCurrentValueStoreAfterUndo = root._getCurrentValueStore();
    assertNull(anOriginalValueStoreAfterUndo);
    assertNotNull(aCurrentValueStoreAfterUndo);
    // we return the original value store back to the current VS
    assertTrue(aCurrentValueStoreAfterUndo == aCurrentValueStore);
}
Also used : DefaultValueStore(org.eclipse.persistence.sdo.DefaultValueStore) ValueStore(org.eclipse.persistence.sdo.ValueStore) 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