use of org.eclipse.persistence.sdo.SDOSequence in project eclipselink by eclipse-ee4j.
the class SDOTestCase method assertSequencesReturnedToStartStateAfterUndoChanges.
/**
*/
protected void assertSequencesReturnedToStartStateAfterUndoChanges(DataObject aRootObject, Sequence aCurrentSequenceAfterLoggingFirstOnParam) {
// verify logging is on
assertTrue(aRootObject.getChangeSummary().isLogging());
SDOSequence anOriginalSequenceAfterUndo = (SDOSequence) ((SDOChangeSummary) aRootObject.getChangeSummary()).getOriginalSequences().get(aRootObject);
SDOSequence aCurrentSequenceAfterUndo = ((SDODataObject) aRootObject).getSequence();
assertNull(anOriginalSequenceAfterUndo);
assertNotNull(aCurrentSequenceAfterUndo);
// we return the sequence back to the current VS
assertEquals(aCurrentSequenceAfterUndo.size(), aCurrentSequenceAfterLoggingFirstOnParam.size());
assertTrue(compareSequences(aCurrentSequenceAfterUndo, (SDOSequence) aCurrentSequenceAfterLoggingFirstOnParam, true));
}
use of org.eclipse.persistence.sdo.SDOSequence in project eclipselink by eclipse-ee4j.
the class SDOSequenceTestXSD method testEqualDeepComplexManySequenceWithDifferentSequence2.
public void testEqualDeepComplexManySequenceWithDifferentSequence2() {
defineAndLoadRoot(false, false);
SDOSequence aSequence = getSequence(root, PO_SEQUENCE_PATH, PO_SEQUENCE_SIZE);
DataObject po = (DataObject) root.get(PO_SEQUENCE_PATH);
// copy po
DataObject rootCopy = copyHelper.copy(root);
// check sequence was copied
SDOSequence aSequenceCopy = getSequence(rootCopy, PO_SEQUENCE_PATH, PO_SEQUENCE_SIZE);
assertNotNull(aSequenceCopy);
// compareSequences(aSequence, aSequenceCopy, PO_SEQUENCE_SIZE, true);
// modify copy sequence
aSequenceCopy.setValue(0, null);
// test equalityHelper
DataObject poCopy = (DataObject) rootCopy.get(PO_SEQUENCE_PATH);
boolean bEqual = equalityHelper.equal(po, poCopy);
assertFalse(bEqual);
}
use of org.eclipse.persistence.sdo.SDOSequence in project eclipselink by eclipse-ee4j.
the class SDOSequenceTestXSD method testAddOpenContentElementByIndexPropertyViaSequence.
public void testAddOpenContentElementByIndexPropertyViaSequence() {
// make a source object
defineAndLoadRoot(false, false);
SDOSequence aSequence = (SDOSequence) root.getSequence();
int sequenceSizeBefore = aSequence.size();
assertNotNull(aSequence);
SDOProperty openPropString = createOpenContentElementProperty("openContentString", SDOConstants.SDO_STRING);
// perform open content op
aSequence.add(2, openPropString, "openContentValue");
// sequence should be modified
assertEquals(aSequence.size(), sequenceSizeBefore + 1);
// get dataObject side
Object openDOContent = root.get("openContentString");
assertNotNull(openDOContent);
// get sequence side
Object openSequenceContent = aSequence.getValue(2);
assertNotNull(openSequenceContent);
assertEquals(openSequenceContent, openDOContent);
}
use of org.eclipse.persistence.sdo.SDOSequence in project eclipselink by eclipse-ee4j.
the class SDOSequenceTestXSD method testRemoveAllEmptyComplexManyReferenceViaListWrapper.
public void testRemoveAllEmptyComplexManyReferenceViaListWrapper() {
defineAndLoadRoot(false, false);
SDOSequence aSequence = getSequence(root, PO_SEQUENCE_PATH, PO_SEQUENCE_SIZE);
int sequenceSizeBefore = aSequence.size();
DataObject itemDO1 = (DataObject) root.get(PO_SEQUENCE_PATH + "/item[1]");
// after removal the items list indexes on the dataObject will shift down, get item[2] for later comparison
DataObject itemDO2 = (DataObject) root.get(PO_SEQUENCE_PATH + "/item[2]");
assertNotNull(itemDO1);
assertNotNull(itemDO2);
assertFalse(itemDO1 == itemDO2);
DataObject po = (DataObject) root.get(PO_SEQUENCE_PATH);
ListWrapper existingList = (ListWrapper) po.get("item");
int listSizeBefore = existingList.size();
assertEquals(2, listSizeBefore);
// get item from sequence
int item2SequenceIndex = getNthSequenceIndexFor(aSequence, "item", 2);
assertTrue(item2SequenceIndex > -1);
DataObject itemObjectFromSetting = (DataObject) aSequence.getValue(item2SequenceIndex);
assertNotNull(itemObjectFromSetting);
assertTrue(itemObjectFromSetting == itemDO2);
// create a list of items to remove
List<DataObject> listToRemove = new ArrayList<DataObject>();
// for(Iterator<DataObject> i = existingList.iterator(); i.hasNext();) {
// listToRemove.add(i.next());
// }
int sizeListToRemove = listToRemove.size();
// remove entire list
existingList.removeAll(listToRemove);
assertEquals(sequenceSizeBefore - sizeListToRemove, aSequence.size());
assertEquals(listSizeBefore - sizeListToRemove, existingList.size());
// are we removed on the DataObject?
// DataObject item1ObjectFromAfterRemove = (DataObject)root.get(PO_SEQUENCE_PATH + "/item[1]");
// TODO: verify delete or dont delete after a sequence.remove
// assertTrue(item1ObjectFromAfterRemove == itemDO1);
// assertFalse(item1ObjectFromAfterRemove == itemDO2);
}
use of org.eclipse.persistence.sdo.SDOSequence in project eclipselink by eclipse-ee4j.
the class SDOSequenceTestXSD method test_voidReturnFrom_add_int_String.
/**
* @deprecated replaced by {@link #addText(int, String)} in 2.1.0
*/
@Deprecated
public void test_voidReturnFrom_add_int_String() {
defineAndLoadRoot(false, false);
SDOSequence aSequence = getSequence(root, PO_SEQUENCE_PATH, PO_SEQUENCE_SIZE);
DataObject po = (DataObject) root.get(PO_SEQUENCE_PATH);
int textIndexToPlaceAtEnd = aSequence.size();
int treeSizeBeforeAdd = preOrderTraversalDataObjectList(po).size();
assertEquals(PO_TREE_SIZE, treeSizeBeforeAdd);
aSequence.add(textIndexToPlaceAtEnd, "random text");
Object addText = aSequence.getValue(textIndexToPlaceAtEnd);
assertNotNull(addText);
assertNull(aSequence.getProperty(textIndexToPlaceAtEnd));
assertEquals(PO_SEQUENCE_TREE_SIZE + 1, aSequence.size());
// verify that DataObject has not changed
int treeSizeAfterAdd = preOrderTraversalDataObjectList(po).size();
assertEquals(treeSizeBeforeAdd, treeSizeAfterAdd);
}
Aggregations