use of org.eclipse.persistence.sdo.SDOChangeSummary in project eclipselink by eclipse-ee4j.
the class ChangeSummaryXSDwSeqTestCases method testDeleteItem2Price1.
// Test Scenarios:
// - many delete
public void testDeleteItem2Price1() {
// 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();
item2ProductPrice1DO.delete();
assertModified(item2ProductDO, cs);
assertDeleted(item2ProductPrice1DO, cs);
assertEquals(2, cs.getChangedDataObjects().size());
assertEquals(14, ((SDOChangeSummary) cs).getOldContainer().size());
assertEquals(14, ((SDOChangeSummary) cs).getOldContainmentProperty().size());
ChangeSummary.Setting containmentSetting = (ChangeSummary.Setting) cs.getOldValues(item2ProductDO).get(0);
assertEquals("price", containmentSetting.getProperty().getName());
assertTrue(containmentSetting.getValue() instanceof List);
assertEquals(2, ((List) containmentSetting.getValue()).size());
assertEquals(true, containmentSetting.isSet());
// writeXML(rootObject);
// undo and verify equality
assertUndoChangesEqualToOriginal(cs, rootObject, originalRootDO);
}
use of org.eclipse.persistence.sdo.SDOChangeSummary in project eclipselink by eclipse-ee4j.
the class ChangeSummaryXSDwSeqTestCases method testCSonRootDeleteComplexSingleAtRoot.
public void testCSonRootDeleteComplexSingleAtRoot() {
// testDeleteShipTo() {
DataObject shipToDO = rootObject.getDataObject("shipTo");
DataObject yardDO = shipToDO.getDataObject("yard");
List phoneList = shipToDO.getList("phone");
DataObject phone1 = (DataObject) phoneList.get(0);
DataObject phone2 = (DataObject) phoneList.get(1);
Property containmentProp = shipToDO.getContainmentProperty();
cs.beginLogging();
shipToDO.delete();
// for dataType verify copy of shipTo has a set child in deleted list and current value is unset
assertNull(shipToDO.get("street"));
DataObject oldContainer = ((SDOChangeSummary) cs).getOldContainer(shipToDO);
Property shipToProp = oldContainer.getInstanceProperty("shipTo");
ChangeSummary.Setting oldSetting = cs.getOldValue(oldContainer, shipToProp);
DataObject deepCopyShipTo = (DataObject) oldSetting.getValue();
assertEquals("123 Maple Street", deepCopyShipTo.get("street"));
assertEquals(14, ((SDOChangeSummary) cs).getOldContainer().size());
assertEquals(14, ((SDOChangeSummary) cs).getOldContainmentProperty().size());
assertModified(rootObject, cs);
assertNotNull(cs.getOldContainmentProperty(shipToDO));
assertNotNull(cs.getOldContainer(shipToDO));
assertEquals(rootObject, cs.getOldContainer(shipToDO));
assertEquals(shipToDO, cs.getOldContainer(yardDO));
assertEquals(shipToDO, cs.getOldContainer(phone1));
assertEquals(shipToDO, cs.getOldContainer(phone2));
assertEquals(containmentProp, cs.getOldContainmentProperty(shipToDO));
assertDeleted(shipToDO, cs);
// assertDeleted(yardDO, cs);
assertYardDeleted(shipToDO, yardDO, cs, true);
assertDeleted(phone1, cs);
assertDeleted(phone2, cs);
assertEquals(5, cs.getChangedDataObjects().size());
assertEquals(1, cs.getOldValues(rootObject).size());
ChangeSummary.Setting setting = (ChangeSummary.Setting) cs.getOldValues(rootObject).get(0);
assertEquals(containmentProp, setting.getProperty());
DataObject shipToDeepCopy = (DataObject) ((SDOChangeSummary) cs).getDeepCopies().get(shipToDO);
assertEquals(shipToDeepCopy, setting.getValue());
assertEquals(true, setting.isSet());
assertEquals(8, cs.getOldValues(shipToDO).size());
assertEquals(1, cs.getOldValues(phone1).size());
assertEquals(1, cs.getOldValues(phone2).size());
ChangeSummary.Setting phone2setting = (ChangeSummary.Setting) cs.getOldValues(phone2).get(0);
assertEquals("number", phone2setting.getProperty().getName());
assertEquals("2345678", phone2setting.getValue());
assertEquals(true, phone2setting.isSet());
// writeXML(rootObject);
}
use of org.eclipse.persistence.sdo.SDOChangeSummary in project eclipselink by eclipse-ee4j.
the class ChangeSummaryXSDwSeqTestCases method verifyDeepCopyObjectWithCSLoggingOnDoesNotLogChangesInTheDeepCopy.
private SDODataObject verifyDeepCopyObjectWithCSLoggingOnDoesNotLogChangesInTheDeepCopy(SDODataObject aRootObject) {
List preOrderList = null;
int numberOfDataObjectsInSubTree = 0;
// verify logging is on
// turn on logging
cs.beginLogging();
assertTrue(cs.isLogging());
// take an object with CS on and deep copy it
SDODataObject copy = (SDODataObject) copyHelper.copy(aRootObject);
// verify that logging is still on
assertNotNull(cs);
assertTrue(cs.isLogging());
ChangeSummary cs2 = copy.getChangeSummary();
assertNotNull(cs2);
assertTrue(cs2.isLogging());
// verify that we have not logged changes during the copy (we dont have to worry about nested changesummaries)
// we should not have 5 old settings after a copy
assertEquals(0, cs2.getChangedDataObjects().size());
preOrderList = preOrderTraversalDataObjectList(copy, false);
numberOfDataObjectsInSubTree = preOrderList.size();
// assume that for logging=true copies we should have oldContainer, oldContProperties
assertEquals(15, numberOfDataObjectsInSubTree);
assertEquals(//
((SDOChangeSummary) cs2).getOldContainer().size(), copy.getChangeSummary().getOldContainer().size());
assertEquals(//
((SDOChangeSummary) cs2).getOldContainmentProperty().size(), copy.getChangeSummary().getOldContainmentProperty().size());
return copy;
}
use of org.eclipse.persistence.sdo.SDOChangeSummary in project eclipselink by eclipse-ee4j.
the class ChangeSummaryXSDwSeqTestCases method testDeleteMultipleInList.
// test deletion inside a list - see detach() isMany section
// Test Scenarios:
// - many delete
public void testDeleteMultipleInList() {
cs.endLogging();
DataObject itemsDO = rootObject.getDataObject("items");
DataObject item1DO = rootObject.getDataObject("items/item[1]");
DataObject item3DO = dataFactory.create(item1DO.getType());
DataObject item4DO = dataFactory.create(item1DO.getType());
DataObject item5DO = dataFactory.create(item1DO.getType());
DataObject item6DO = dataFactory.create(item1DO.getType());
itemsDO.getList("item").add(item3DO);
itemsDO.getList("item").add(item4DO);
itemsDO.getList("item").add(item5DO);
itemsDO.getList("item").add(item6DO);
cs.beginLogging();
item3DO.delete();
item5DO.delete();
// 5/2
assertDeleted(item3DO, cs);
// 5/2
assertDeleted(item5DO, cs);
assertModified(itemsDO, cs);
assertEquals(3, cs.getChangedDataObjects().size());
// 14 + 4 new objects
assertEquals(18, ((SDOChangeSummary) cs).getOldContainer().size());
// 14 + 4 new objects
assertEquals(18, ((SDOChangeSummary) cs).getOldContainmentProperty().size());
// from 2 (only 1st change on items is recorded)
assertEquals(1, cs.getOldValues(itemsDO).size());
// 1
assertEquals(5, cs.getOldValues(item3DO).size());
// 1
assertEquals(5, cs.getOldValues(item5DO).size());
List aSettingList = cs.getOldValues(itemsDO);
assertTrue(aSettingList.size() > 0);
ChangeSummary.Setting containmentSetting = (ChangeSummary.Setting) aSettingList.get(0);
assertEquals("item", containmentSetting.getProperty().getName());
assertTrue(containmentSetting.getValue() instanceof List);
assertEquals(6, ((List) containmentSetting.getValue()).size());
// see detach(boolean)
assertEquals(true, containmentSetting.isSet());
// writeXML(rootObject);
}
use of org.eclipse.persistence.sdo.SDOChangeSummary in project eclipselink by eclipse-ee4j.
the class SDODataObjectGetPathTest method testGetXPathFromAncestorDeletedFromChildToAncestorInsideListWrapperLoggingOn.
public void testGetXPathFromAncestorDeletedFromChildToAncestorInsideListWrapperLoggingOn() {
SDODataObject anItem = (SDODataObject) aRoot5.get("billTo/phone[1]");
// start logging
SDOChangeSummary aCS = aRoot5.getChangeSummary();
aCS.beginLogging();
assertTrue(aCS.isLogging());
// delete source object
SDODataObject deletedObjectParent = ((SDODataObject) aRoot5.get("billTo"));
// detach();
deletedObjectParent.delete();
String aPath = ((SDOMarshalListener) ((SDOXMLHelper) xmlHelper).getXmlMarshaller().getMarshalListener()).getPathFromAncestor(anItem, aRoot5, aRoot5.getChangeSummary());
// SDODataObject anItemFromPath = (SDODataObject)aRoot5.get(aPath);
// System.out.println("testGetPathFromAncestorDeletedFromChildToRootLoggingOn: " + aPath);
assertNotNull(aPath);
// TODO: no storage of deleted indexed postition - defaults to size() = start of list for now
// see SDODataObject: index = ((SDODataObject)parent).getList(aChild).size();
assertEquals("ns0:billTo/ns0:phone[1]", aPath);
}
Aggregations