use of org.eclipse.persistence.sdo.SDODataObject in project eclipselink by eclipse-ee4j.
the class ChangeSummaryDeleteOpenContentTestCases method verifyAfterLoad.
@Override
protected void verifyAfterLoad(XMLDocument document) {
super.verifyAfterLoad(document);
ChangeSummary teamCS = document.getRootObject().getChangeSummary();
assertNotNull(teamCS);
DataObject manager = document.getRootObject().getDataObject("manager");
assertNotNull(manager);
ChangeSummary managerCS = manager.getChangeSummary();
assertEquals(teamCS, managerCS);
assertTrue(teamCS.isLogging());
assertTrue(teamCS.isLogging());
List yards = manager.getList("theYard");
assertTrue(yards.isEmpty());
assertEquals(1, ((SDOChangeSummary) managerCS).getModified().size());
assertEquals(4, ((SDOChangeSummary) managerCS).getDeleted().size());
DataObject deletedYard = (DataObject) ((SDOChangeSummary) managerCS).getDeleted().get(0);
// TODO: what should be deletedYard.get"width" vs. get oldSetting "width
assertEquals("theSqFootage", deletedYard.get("squarefootage"));
assertEquals("thelength", deletedYard.get("length"));
assertEquals("theWidth", deletedYard.get("width"));
// theYardDefined
DataObject deletedYardDefined = (DataObject) ((SDOChangeSummary) managerCS).getDeleted().get(1);
ChangeSummary.Setting setting = managerCS.getOldValue(deletedYardDefined, deletedYardDefined.getInstanceProperty("squarefootage"));
assertNotNull(setting);
assertEquals("theSqFootageDefined", setting.getValue());
setting = managerCS.getOldValue(deletedYardDefined, deletedYardDefined.getInstanceProperty("length"));
assertNotNull(setting);
assertEquals("thelengthDefined", setting.getValue());
setting = managerCS.getOldValue(deletedYardDefined, deletedYardDefined.getInstanceProperty("width"));
assertNotNull(setting);
assertEquals("theWidthDefined", setting.getValue());
// theYardUndefined
DataObject deletedYardUndefined = (DataObject) ((SDOChangeSummary) managerCS).getDeleted().get(2);
setting = managerCS.getOldValue(deletedYardUndefined, deletedYardUndefined.getInstanceProperty("squarefootage"));
assertNotNull(setting);
assertEquals(1, ((List) setting.getValue()).size());
assertEquals("theSqFootageUndefined", ((List) setting.getValue()).get(0));
setting = managerCS.getOldValue(deletedYardUndefined, deletedYardUndefined.getInstanceProperty("length"));
assertNotNull(setting);
assertEquals(1, ((List) setting.getValue()).size());
assertEquals("thelengthUndefined", ((List) setting.getValue()).get(0));
setting = managerCS.getOldValue(deletedYardUndefined, deletedYardUndefined.getInstanceProperty("width"));
assertNotNull(setting);
assertEquals(1, ((List) setting.getValue()).size());
assertEquals("theWidthUndefined", ((List) setting.getValue()).get(0));
//
// address
DataObject address = (DataObject) ((SDOChangeSummary) managerCS).getDeleted().get(3);
setting = managerCS.getOldValue(address, address.getInstanceProperty("street"));
assertNotNull(setting);
assertEquals("theStreet", setting.getValue());
assertTrue(setting.isSet());
ChangeSummary.Setting oldNameSetting = managerCS.getOldValue(manager, manager.getInstanceProperty("name"));
List oldValues = managerCS.getOldValues(manager);
Sequence oldSequence = managerCS.getOldSequence(manager);
assertEquals(4, oldValues.size());
assertEquals(5, oldSequence.size());
assertEquals("Jane Doe", oldSequence.getValue(0));
assertEquals("name", oldSequence.getProperty(0).getName());
DataObject yardValue = (DataObject) oldSequence.getValue(1);
assertNotNull(yardValue);
assertEquals("Yard", yardValue.getType().getName());
assertEquals("theYard", oldSequence.getProperty(1).getName());
DataObject yardDefinedValue = (DataObject) oldSequence.getValue(2);
assertEquals("Yard", yardDefinedValue.getType().getName());
assertNotNull(yardDefinedValue);
// assertEquals("theYardDefined" ,oldSequence.getProperty(2).getName());
SDODataObject yardUnDefinedValue = (SDODataObject) oldSequence.getValue(3);
assertNotNull(yardUnDefinedValue);
assertTrue(yardUnDefinedValue.getType().isOpenSequencedType());
assertEquals("theYardUndefined", oldSequence.getProperty(3).getName());
DataObject addressValue = (DataObject) oldSequence.getValue(4);
assertEquals("Address", addressValue.getType().getName());
assertEquals("address", oldSequence.getProperty(4).getName());
// olsequence is size 2 with name + address
// DataObject yard = manager.getDataObject("theYard");
/* List yards = manager.getList("theYard");
assertEquals(1, yards.size());
DataObject yard = (DataObject)yards.get(0);
assertNotNull(yard);
assertEquals("theSqFootage", yard.get("squarefootage"));
assertEquals("thelength", yard.get("length"));
assertEquals("theWidth", yard.get("width"));
*/
}
use of org.eclipse.persistence.sdo.SDODataObject in project eclipselink by eclipse-ee4j.
the class ChangeSummaryChildSimpleDeleteTestCases method verifyAfterLoad.
@Override
protected void verifyAfterLoad(XMLDocument document) {
super.verifyAfterLoad(document);
ChangeSummary teamCS = document.getRootObject().getChangeSummary();
assertNull(teamCS);
DataObject manager = document.getRootObject().getDataObject("manager");
assertNotNull(manager);
ChangeSummary managerCS = manager.getChangeSummary();
assertNotNull(managerCS);
assertTrue(managerCS.isLogging());
assertTrue(managerCS.isLogging());
int deletedSize = ((SDOChangeSummary) managerCS).getDeleted().size();
assertEquals(3, deletedSize);
assertTrue(managerCS.isModified(manager));
Iterator iter = ((SDOChangeSummary) managerCS).getDeleted().iterator();
while (iter.hasNext()) {
SDODataObject nextDeleted = (SDODataObject) iter.next();
assertEquals(nextDeleted.getInstanceProperties().size(), managerCS.getOldValues(nextDeleted).size());
}
assertEquals(2, managerCS.getOldValues(manager).size());
List teamOldValues = managerCS.getOldValues(manager);
// assertEquals(2, teamOldValues.size());
// assertTrue(teamOldValues.size() <= 4);
ChangeSummary.Setting idSetting = managerCS.getOldValue(manager, manager.getInstanceProperty("id"));
assertNull(idSetting);
// TODO: uncomment when Node null policy works
ChangeSummary.Setting nameSetting = managerCS.getOldValue(manager, manager.getInstanceProperty("name"));
assertNull(nameSetting);
ChangeSummary.Setting addressSetting = managerCS.getOldValue(manager, manager.getInstanceProperty("address"));
assertNotNull(addressSetting);
DataObject addressDO = (DataObject) addressSetting.getValue();
assertNotNull(addressDO);
Object streetValue = addressDO.get("street");
assertEquals("theStreet", streetValue);
DataObject originalAddress = (DataObject) ((SDOChangeSummary) managerCS).getReverseDeletedMap().get(addressDO);
DataObject oldContainer = managerCS.getOldContainer(originalAddress);
assertEquals(oldContainer, manager);
Property oldContainmentProp = managerCS.getOldContainmentProperty(originalAddress);
assertNotNull(oldContainmentProp);
assertEquals(oldContainmentProp, manager.getInstanceProperty("address"));
// TODO: yard stuff
ChangeSummary.Setting yardOldSetting = managerCS.getOldValue(originalAddress, addressDO.getInstanceProperty("yard"));
DataObject yardDO = (DataObject) yardOldSetting.getValue();
assertNotNull(yardDO);
DataObject originalYard = (DataObject) ((SDOChangeSummary) managerCS).getReverseDeletedMap().get(yardDO);
DataObject yardOldContainer = managerCS.getOldContainer(originalYard);
assertEquals(yardOldContainer, originalAddress);
assertNotNull(yardOldContainer);
Property yardOldContainmentProp = managerCS.getOldContainmentProperty(originalYard);
assertNotNull(yardOldContainmentProp);
assertEquals(yardOldContainmentProp, addressDO.getInstanceProperty("yard"));
managerCS.getOldValues(yardDO);
ChangeSummary.Setting phoneSetting = managerCS.getOldValue(manager, manager.getInstanceProperty("phone"));
assertNotNull(phoneSetting);
assertNotNull(phoneSetting.getValue());
assertTrue(phoneSetting.getValue() instanceof List);
assertEquals(4, ((List) phoneSetting.getValue()).size());
/*teamCS.endLogging();
teamCS.beginLogging();
manager.set("name","Suzanne");
manager.set("id","123");
*/
// assertTrue(teamCS.isCreated(manager));
// assertEquals(0, teamCS.getOldValues(manager).size());
}
use of org.eclipse.persistence.sdo.SDODataObject in project eclipselink by eclipse-ee4j.
the class DefineAndGenerateBidirectionalTestCases method testDefineAndGenerateUsingSpecMethod.
/**
* This function will define control types programmatically to compare to XSD definition
* by using the standard spec SDODataObject generation method on page
*
* The existing getControlTypes() uses non-public Property constructors
*/
public void testDefineAndGenerateUsingSpecMethod() throws Exception {
boolean useXSD = false;
List types;
DefaultSchemaLocationResolver resolver = new DefaultSchemaLocationResolver(getMap());
if (useXSD) {
// InputStream is = getSchemaInputStream(getSchemaToDefine());
// List types = xsdHelper.define(is, getSchemaLocation());
types = xsdHelper.define(getXSDString(XSD_PATH));
// compareGeneratedTypes(getControlTypesViaSpecMethod(), types);
} else {
registerTypes();
types = getTypesToGenerateFrom();
}
String generatedSchema = ((SDOXSDHelper) xsdHelper).generate(types, resolver);
log(generatedSchema);
try {
// false, types);
root = createRootObject(true, types);
} catch (Exception e) {
// SDOTestCase will currently throw a fail()
fail(e.getMessage());
}
int aRootsize = preOrderTraversalDataObjectList((SDODataObject) root).size();
// assertEquals(4, aRootsize);
// get opposite properties
// check that opposite bidirectional links resolve
// DataObject porderDO = (DataObject)root.get("porder[1]");
assertTrue(writeXML(root, URINAME, COMPANY_TYPENAME, System.out));
// assertXMLIdentical(getDocument(getControlGeneratedFileName()), generatedSchemaDoc);
}
use of org.eclipse.persistence.sdo.SDODataObject in project eclipselink by eclipse-ee4j.
the class ChangeSummaryXSDwSeqTestCases method testReverseDeletedMapUsageDuringDeepCopyChangeSummary.
// This test exercises bug 5913485: deepcopy is placed into cs.originalElements during a getOldValue()
// SDOCopyHelper.copyChangeSummary()
// 536 // if deleted list is not found look in the reverse deleted map - if getOldSettings was called
// 537 0 SDODataObject reverseDeletedDO = (SDODataObject)originalCS.getReverseDeletedMap().get(aListItem);
//
public void testReverseDeletedMapUsageDuringDeepCopyChangeSummary() {
// unset isMany=true (to fill unsetPropsMap and createdList later when we (re)set it back)
SDODataObject shipTo = (SDODataObject) rootObject.get(PROPERTY_NAME_PO_SHIPTO);
// use index 2 to avoid a swap later
SDODataObject phone2 = (SDODataObject) rootObject.get(PROPERTY_NAME_PO_SHIPTO_PHONE2);
shipTo.unset("phone[2]");
cs.beginLogging();
assertTrue(cs.isLogging());
SDODataObject items = (SDODataObject) rootObject.get(PROPERTY_NAME_PO_ITEMS);
// detach isMany=false (to fill deletedList and modifiedList)
items.delete();
// (re)set isMany=true (to fill createdList, unsetPropsMap)
List phones = (List) shipTo.get("phone");
phones.add(phone2);
// get an oldSetting in order to enable caching to fill the oldSettings hash map in the cs
Object oldValueItems = cs.getOldValue(rootObject, rootObject.getInstanceProperty("items")).getValue();
assertNotNull(oldValueItems);
assertNull(rootObject.get("items"));
// save fields lengths for later comparision
List<DataObject> changedObjects = cs.getChangedDataObjects();
int changedObjectsLength = changedObjects.size();
// verify #5913485 will cause an undone copy to be !deep equal
// invoke usage of the reverseDeletedMap
int itemsOldValuesSize = cs.getOldValues(items).size();
// take an object with CS on and deep copy it
SDODataObject copy = (SDODataObject) copyHelper.copy(rootObject);
// verify that logging is still on
ChangeSummary cs2 = copy.getChangeSummary();
// verify saved field lengths from above
assertEquals(changedObjectsLength, cs2.getChangedDataObjects().size());
// check shallow equality
boolean isEqual = equalityHelper.equalShallow(rootObject, copy);
assertTrue(isEqual);
// check deep equal is unaffected (we should have a copy of the copy for List items
// - ListWrapper.add(item) will remove the item from its original wrapper)
assertTrue(equalityHelper.equal(rootObject, copy));
// verify rootDataObject
assertEquals(copy, cs2.getRootObject());
// perform an undo on the copy and compare to the undone original (not the undone copy)
cs2.undoChanges();
// undo changes on original
cs.undoChanges();
// check shallow equality
assertTrue(equalityHelper.equalShallow(rootObject, copy));
// check deep equal is unaffected (we should have a copy of the copy for List items
// - ListWrapper.add(item) will remove the item from its original wrapper)
assertTrue(equalityHelper.equal(rootObject, copy));
}
use of org.eclipse.persistence.sdo.SDODataObject in project eclipselink by eclipse-ee4j.
the class ChangeSummaryXSDwSeqTestCases method testResetOfUnsetOpenContentPropertyClearsUnsetOCPropMap.
// Exercise cs.removeUnsetOCProperty()
public void testResetOfUnsetOpenContentPropertyClearsUnsetOCPropMap() {
List preOrderList = null;
int numberOfDataObjectsInSubTree = 0;
// unset isMany=true (to fill unsetPropsMap and createdList later when we (re)set it back)
SDODataObject shipTo = (SDODataObject) rootObject.get(PROPERTY_NAME_PO_SHIPTO);
// use index 2 to avoid a swap later
SDODataObject phone2 = (SDODataObject) rootObject.get(PROPERTY_NAME_PO_SHIPTO_PHONE2);
shipTo.unset("phone[2]");
// save size of tree before CS was turned on
preOrderList = preOrderTraversalDataObjectList((SDODataObject) rootObject, false);
numberOfDataObjectsInSubTree = preOrderList.size();
int numberOfNodesInRootBeforeCSon = 14;
assertEquals(numberOfNodesInRootBeforeCSon, numberOfDataObjectsInSubTree);
// set a simple-single Open Content property
SDOProperty openRootProperty = new SDOProperty(aHelperContext);
openRootProperty.setName(OC_PROP1SimpleSingleNAME);
openRootProperty.setType(SDOConstants.SDO_STRING);
// aRootTypeOC.setOpen(true);
((SDOType) rootObject.getType()).setOpen(true);
rootObject.set(openRootProperty, OC_PROP1SimpleSingleVALUE);
// set an Open Content property and delete it
SDOProperty openRootPropertyToBeDeleted = new SDOProperty(aHelperContext);
openRootPropertyToBeDeleted.setName(OC_PROP2SimpleSingleNAME);
openRootPropertyToBeDeleted.setType(SDOConstants.SDO_STRING);
// aRootTypeOC.setOpen(true);
rootObject.set(openRootPropertyToBeDeleted, OC_PROP2SimpleSingleVALUE);
// turn on logging
cs.beginLogging();
assertTrue(cs.isLogging());
// delete an Open Content property
rootObject.unset(openRootPropertyToBeDeleted);
assertFalse(((SDOChangeSummary) cs).getUnsetOCPropertiesMap().isEmpty());
// reset it
rootObject.set(openRootPropertyToBeDeleted, OC_PROP2SimpleSingleVALUE);
assertTrue(((SDOChangeSummary) cs).getUnsetOCPropertiesMap().isEmpty());
}
Aggregations