use of commonj.sdo.Sequence in project eclipselink by eclipse-ee4j.
the class SDOSequenceTestXSD method testSequencesStillNullAfterIsSequencedSetToTrueOutOfSpec.
public void testSequencesStillNullAfterIsSequencedSetToTrueOutOfSpec() {
// create a dataObject with no sequence - the root
defineAndLoadRoot(false, false);
Sequence aSequence = root.getSequence();
DataObject po = (DataObject) root.get(PO_SEQUENCE_PATH);
// copy po
DataObject rootCopy = copyHelper.copy(root);
// verify we are using the same context
// assertEquals(helperContext, ((SDOCopyHelper)copyHelper).getHelperContext())
// check sequence was copied
SDOSequence aSequenceCopy = getSequence(rootCopy, PO_SEQUENCE_PATH, PO_SEQUENCE_SIZE);
assertNotNull(aSequenceCopy);
// compareSequences(aSequence, aSequenceCopy, PO_SEQUENCE_SIZE, true);
// test equalityHelper
DataObject poCopy = (DataObject) rootCopy.get(PO_SEQUENCE_PATH);
boolean bEqual = equalityHelper.equal(po, poCopy);
assertTrue(bEqual);
// modify copy sequence state - non public method - both po and poCopy will have their state changed because they share an SDOType
assertTrue(po.getType().isSequenced());
assertTrue(poCopy.getType().isSequenced());
// WARNING: Users should not be doing this - however it is supported
((SDOType) poCopy.getType()).setSequenced(false);
assertFalse(po.getType().isSequenced());
assertFalse(poCopy.getType().isSequenced());
bEqual = equalityHelper.equal(po, poCopy);
// sequences will not be compared
assertTrue(bEqual);
// turn on isSequenced - not available via spec interface - do not use
// copy
// check equality
}
use of commonj.sdo.Sequence in project eclipselink by eclipse-ee4j.
the class ChangeSummaryGetOldSequenceTestCases method testGetOldSequenceAfterUnsetAllOnItems.
public void testGetOldSequenceAfterUnsetAllOnItems() {
cs.beginLogging();
Sequence seq1 = itemsObject.getSequence();
// unset item property
itemsObject.unset(0);
Sequence seq2 = itemsObject.getSequence();
assertEquals(seq1, seq2);
Property itemProp = itemsObject.getInstanceProperty("item");
ChangeSummary.Setting itemOldSetting = cs.getOldValue(itemsObject, itemProp);
assertNotNull(itemOldSetting);
Object oldItemValue = itemOldSetting.getValue();
assertNotNull(oldItemValue);
assertTrue(oldItemValue instanceof List);
assertEquals(2, ((List) oldItemValue).size());
Sequence itemsOldSeq = cs.getOldSequence(itemsObject);
assertNotNull(itemsOldSeq);
assertEquals(itemProp, itemsOldSeq.getProperty(0));
Object itemOldSeqValue = itemsOldSeq.getValue(0);
assertNotNull(itemOldSeqValue);
assertTrue(itemOldSeqValue instanceof DataObject);
// assertEquals(2, ((DataObject)itemOldSeqValue).size());
assertEquals(((List) oldItemValue).get(0), itemOldSeqValue);
/* assertEquals(((List)oldItemValue).get(0), ((DataObject)itemOldSeqValue).get(0));
assertEquals(((List)oldItemValue).get(1), ((DataObject)itemOldSeqValue).get(1));
assertEquals(((List)oldItemValue), ((List)itemOldSeqValue));
*/
Sequence itemsOldSeq2 = cs.getOldSequence(itemsObject);
assertEquals(itemsOldSeq, itemsOldSeq2);
}
use of commonj.sdo.Sequence in project eclipselink by eclipse-ee4j.
the class ChangeSummaryGetOldSequenceTestCases method testGetOldSequenceAfterMoveText.
public void testGetOldSequenceAfterMoveText() {
assertEquals(4, address1Object.getSequence().size());
address1Object.getSequence().addText("abc");
address1Object.getSequence().addText("def");
assertEquals(6, address1Object.getSequence().size());
cs.beginLogging();
assertEquals("abc", (String) address1Object.getSequence().getValue(4));
assertEquals("def", (String) address1Object.getSequence().getValue(5));
address1Object.getSequence().move(4, 5);
assertEquals(6, address1Object.getSequence().size());
assertEquals("def", (String) address1Object.getSequence().getValue(4));
assertEquals("abc", (String) address1Object.getSequence().getValue(5));
Sequence oldSeq = cs.getOldSequence(address1Object);
assertNotNull(oldSeq);
assertEquals(6, oldSeq.size());
assertEquals("abc", (String) oldSeq.getValue(4));
assertEquals("def", (String) oldSeq.getValue(5));
}
use of commonj.sdo.Sequence in project eclipselink by eclipse-ee4j.
the class ChangeSummaryGetOldSequenceTestCases method testGetOldSequenceTwice.
public void testGetOldSequenceTwice() {
Sequence originalSeq = address1Object.getSequence();
String originalValue = (String) originalSeq.getValue(0);
assertEquals("Alice Smith", originalValue);
cs.beginLogging();
address1Object.set("name", "newName");
Sequence oldSeq1 = cs.getOldSequence(address1Object);
assertNotNull(oldSeq1);
assertNotSame(oldSeq1, originalSeq);
Sequence oldSeq2 = cs.getOldSequence(address1Object);
assertNotNull(oldSeq2);
assertEquals(oldSeq1, oldSeq2);
address1Object.set("name", "newName2");
Sequence oldSeq3 = cs.getOldSequence(address1Object);
assertNotNull(oldSeq3);
assertEquals(oldSeq2, oldSeq3);
String oldSeqValue = (String) oldSeq3.getValue(0);
assertEquals("Alice Smith", oldSeqValue);
String currentValue = (String) address1Object.getSequence().getValue(0);
assertEquals("newName2", currentValue);
}
use of commonj.sdo.Sequence in project eclipselink by eclipse-ee4j.
the class ChangeSummaryGetOldSequenceTestCases method testGetOldSequenceDeletedItem.
public void testGetOldSequenceDeletedItem() {
cs.beginLogging();
DataObject lineItem1 = (DataObject) itemsObject.getList("item").get(0);
DataObject lineItem2 = (DataObject) itemsObject.getList("item").get(1);
Sequence currentSeq = itemsObject.getSequence();
assertEquals(2, currentSeq.size());
cs.beginLogging();
lineItem1.delete();
assertEquals(1, currentSeq.size());
Sequence oldSeq = cs.getOldSequence(itemsObject);
assertNotNull(oldSeq);
assertEquals(2, ((SDOSequence) oldSeq).getSettings().size());
DataObject oldLineItem1 = (DataObject) oldSeq.getValue(0);
assertEquals("Lawnmower", oldLineItem1.get("productName"));
DataObject oldLineItem2 = (DataObject) oldSeq.getValue(1);
assertEquals("Baby Monitor", oldLineItem2.get("productName"));
// should be a deep copy not the same object
assertNotSame(lineItem1, oldLineItem1);
assertNotSame(lineItem2, oldLineItem2);
assertFalse(lineItem1.equals(oldLineItem1));
assertFalse(lineItem2.equals(oldLineItem2));
}
Aggregations