use of commonj.sdo.Sequence in project eclipselink by eclipse-ee4j.
the class ChangeSummaryGetOldSequenceTestCases method testGetOldSequenceAndOldValueAreEqual.
public void testGetOldSequenceAndOldValueAreEqual() {
cs.beginLogging();
DataObject lineItem1 = (DataObject) itemsObject.getList("item").get(0);
assertNotNull(lineItem1);
lineItem1.delete();
Sequence oldSeq1 = cs.getOldSequence(itemsObject);
assertNotNull(oldSeq1);
Object seqFirstOldValue = oldSeq1.getValue(0);
ChangeSummary.Setting itemOldSetting = cs.getOldValue(itemsObject, itemsObject.getInstanceProperty("item"));
assertNotNull(itemOldSetting);
Object firstValue = ((List) itemOldSetting.getValue()).get(0);
assertEquals(seqFirstOldValue, firstValue);
}
use of commonj.sdo.Sequence in project eclipselink by eclipse-ee4j.
the class ChangeSummaryGetOldSequenceTestCases method testGetOldSequenceUnchanged.
public void testGetOldSequenceUnchanged() {
cs.beginLogging();
// if the sequence has not changed return the current sequence
Sequence oldSeq = cs.getOldSequence(address1Object);
assertNotNull(oldSeq);
assertEquals(4, ((SDOSequence) oldSeq).getSettings().size());
assertEquals("name", oldSeq.getProperty(0).getName());
assertEquals("street", oldSeq.getProperty(1).getName());
assertEquals("city", oldSeq.getProperty(2).getName());
assertEquals("state", oldSeq.getProperty(3).getName());
assertEquals("Alice Smith", oldSeq.getValue(0));
assertEquals("123 Maple Street", oldSeq.getValue(1));
assertEquals("Mill Valley", oldSeq.getValue(2));
assertEquals("CA", oldSeq.getValue(3));
}
use of commonj.sdo.Sequence in project eclipselink by eclipse-ee4j.
the class ChangeSummaryXSDwSeqTestCases method testAddUnstructuredTextAffectsChangeSummaryUndo.
// modify sequence without modifying container and undo
public void testAddUnstructuredTextAffectsChangeSummaryUndo() {
DataObject shipToDO = rootObject.getDataObject("shipTo");
// Property containmentProp = shipToDO.getInstanceProperty("yard");
DataObject yardDO = shipToDO.getDataObject("yard");
// Object length = yardDO.get("length");
cs.beginLogging();
Sequence aSequence = shipToDO.getSequence();
// modify sequence without modifying container dataObject
// int yardIndex = getNthSequenceIndexFor((SDOSequence)aSequence, "yard");
// aSequence.remove(yardIndex);
// yardDO.detach();
aSequence.addText("Unstructured1");
List yardDOSettings = cs.getOldValues(yardDO);
// no change to container when unstructured text is added
// TODO: is this the case? adding unstructured text
// should cause the data object to be considered 'modified'
assertEquals(0, yardDOSettings.size());
assertTrue(cs.isModified(shipToDO));
// assertDetached(yardDO, cs);
// assertModified(shipToDO, cs);
assertFalse(cs.isModified(yardDO));
// TODO: since "addText()" now sets modified on the dataObject, we will
// have a changed dataObject. Verify this...
// assertEquals(0, cs.getChangedDataObjects().size());
assertEquals(1, cs.getChangedDataObjects().size());
// return yardDOSettings;
// check oldSequence before undo
Sequence shipToSeqBefore = cs.getOldSequence(shipToDO);
assertNotNull(shipToSeqBefore);
cs.undoChanges();
// check oldSequence after undo
Sequence shipToSeqAfter = cs.getOldSequence(shipToDO);
assertNotNull(shipToSeqAfter);
// verify that object references in settings are the same ones on the valueStore
assertFalse(cs.isDeleted(yardDO));
// if we add new logic
assertFalse(cs.isModified(shipToDO));
// assertTrue(cs.isModified(shipToDO)); // see bug# 5882923 - we should clear the setting here
assertFalse(cs.isModified(yardDO));
// if we add new logic
assertEquals(0, cs.getChangedDataObjects().size());
// assertEquals(1, cs.getChangedDataObjects().size());//just shipTo
assertEquals(14, ((SDOChangeSummary) cs).getOldContainer().size());
assertEquals(14, ((SDOChangeSummary) cs).getOldContainmentProperty().size());
List shipToSettings = cs.getOldValues(shipToDO);
// 20070214: modified from 1
assertEquals(0, shipToSettings.size());
yardDOSettings = cs.getOldValues(yardDO);
// see cs.getOldValues() does not return and empty List when yardDO is !modified and !deleted (but !created as well) - (re)set
// was 3 before we implemented undoChanges()
assertEquals(0, yardDOSettings.size());
// see cs.getOldValue() does not return null when yardDO is !modified and !deleted (but !created as well) - (re)set
ChangeSummary.Setting lengthSetting = cs.getOldValue(yardDO, yardDO.getInstanceProperty("length"));
// assertNotNull(lengthSetting);
assertNull(lengthSetting);
// assertEquals(length, lengthSetting.getValue());
// writeXML(rootObject);
}
use of commonj.sdo.Sequence in project eclipselink by eclipse-ee4j.
the class ChangeSummaryXSDwSeqTestCases method testDetachYardDOViaContainerAndUndo.
public void testDetachYardDOViaContainerAndUndo() {
DataObject shipToDO = rootObject.getDataObject("shipTo");
// Property containmentProp = shipToDO.getInstanceProperty("yard");
DataObject yardDO = shipToDO.getDataObject("yard");
Object length = yardDO.get("length");
cs.beginLogging();
yardDO.detach();
List yardDOSettings = cs.getOldValues(yardDO);
assertEquals(3, yardDOSettings.size());
assertDetached(yardDO, cs);
assertModified(shipToDO, cs);
assertFalse(cs.isModified(yardDO));
assertEquals(2, cs.getChangedDataObjects().size());
// return yardDOSettings;
// check oldSequence before undo
Sequence shipToSeqBefore = cs.getOldSequence(shipToDO);
assertNotNull(shipToSeqBefore);
cs.undoChanges();
// check oldSequence after undo
Sequence shipToSeqAfter = cs.getOldSequence(shipToDO);
assertNotNull(shipToSeqAfter);
// different sequences in originalSequences
assertFalse(shipToSeqBefore == shipToSeqAfter);
// different settings in originalSequences
assertFalse(((SDOSequence) shipToSeqBefore).getSettings().get(0) == ((SDOSequence) shipToSeqAfter).getSettings().get(0));
// verify that object references in settings are the same ones on the valueStore
assertFalse(cs.isDeleted(yardDO));
// if we add new logic
assertFalse(cs.isModified(shipToDO));
// assertTrue(cs.isModified(shipToDO)); // see bug# 5882923 - we should clear the setting here
assertFalse(cs.isModified(yardDO));
// if we add new logic
assertEquals(0, cs.getChangedDataObjects().size());
// assertEquals(1, cs.getChangedDataObjects().size());//just shipTo
assertEquals(14, ((SDOChangeSummary) cs).getOldContainer().size());
assertEquals(14, ((SDOChangeSummary) cs).getOldContainmentProperty().size());
List shipToSettings = cs.getOldValues(shipToDO);
// 20070214: modified from 1
assertEquals(0, shipToSettings.size());
yardDOSettings = cs.getOldValues(yardDO);
// see cs.getOldValues() does not return and empty List when yardDO is !modified and !deleted (but !created as well) - (re)set
// was 3 before we implemented undoChanges()
assertEquals(0, yardDOSettings.size());
// see cs.getOldValue() does not return null when yardDO is !modified and !deleted (but !created as well) - (re)set
ChangeSummary.Setting lengthSetting = cs.getOldValue(yardDO, yardDO.getInstanceProperty("length"));
// assertNotNull(lengthSetting);
assertNull(lengthSetting);
// assertEquals(length, lengthSetting.getValue());
// writeXML(rootObject);
}
use of commonj.sdo.Sequence in project eclipselink by eclipse-ee4j.
the class ChangeSummaryGetOldSequenceTestCases method testGetOldSequenceWithText.
public void testGetOldSequenceWithText() {
assertEquals(4, address1Object.getSequence().size());
address1Object.getSequence().addText("abc");
assertEquals(5, address1Object.getSequence().size());
cs.beginLogging();
address1Object.getSequence().addText("def");
assertEquals(6, address1Object.getSequence().size());
assertEquals("def", (String) address1Object.getSequence().getValue(5));
Sequence oldSeq = cs.getOldSequence(address1Object);
assertNotNull(oldSeq);
assertEquals(5, oldSeq.size());
assertEquals("abc", (String) oldSeq.getValue(4));
}
Aggregations