use of org.eclipse.persistence.sdo.SDOSequence in project eclipselink by eclipse-ee4j.
the class SDOSequenceTestXSD method testEqualDeepComplexManySequence.
public void testEqualDeepComplexManySequence() {
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);
// test equalityHelper
DataObject poCopy = (DataObject) rootCopy.get(PO_SEQUENCE_PATH);
boolean bEqual = equalityHelper.equal(po, poCopy);
assertTrue(bEqual);
}
use of org.eclipse.persistence.sdo.SDOSequence in project eclipselink by eclipse-ee4j.
the class SDOSequenceTestXSD method testMoveIndexFromOutOfBoundsHigh.
public void testMoveIndexFromOutOfBoundsHigh() {
defineAndLoadRoot(false, false);
DataObject po = (DataObject) root.get(PO_SEQUENCE_PATH);
assertNotNull(po);
assertTrue(po.getType().isSequenced());
SDOSequence aSequence = (SDOSequence) po.getSequence();
// move 2 sequenced objects
Property beforeMoveProp1 = aSequence.getProperty(1);
assertNotNull(beforeMoveProp1);
boolean exceptionThrown = false;
try {
aSequence.move(99, 1);
} catch (SDOException e) {
// catch error
assertEquals(SDOException.INVALID_INDEX, e.getErrorCode());
exceptionThrown = true;
}
Property afterMoveProp1 = aSequence.getProperty(1);
// verify the move did not take place
assertTrue(beforeMoveProp1 == afterMoveProp1);
assertTrue(exceptionThrown);
}
use of org.eclipse.persistence.sdo.SDOSequence in project eclipselink by eclipse-ee4j.
the class SDOSequenceTestXSD method testRemoveDoesDeleteDataObjectPropertyValue.
// TODO: Issue resolution 20070403-1: is remove local to Sequence - no
public void testRemoveDoesDeleteDataObjectPropertyValue() {
defineAndLoadRoot(false, false);
SDOSequence aSequence = getSequence(root, PO_SEQUENCE_PATH, PO_SEQUENCE_SIZE);
DataObject shipToDO = (DataObject) root.get(PO_SEQUENCE_PATH + "/shipTo");
assertNotNull(shipToDO);
// get shipTo sequence
int shipToSequenceIndex = getNthSequenceIndexFor(aSequence, "shipTo");
assertTrue(shipToSequenceIndex > -1);
DataObject shipToObjectFromSetting = (DataObject) aSequence.getValue(shipToSequenceIndex);
assertNotNull(shipToObjectFromSetting);
assertTrue(shipToObjectFromSetting == shipToDO);
// delete po[1]/shipTo from setting
aSequence.remove(shipToSequenceIndex);
// are we removed on the DataObject?
DataObject shipToObjectFromAfterRemove = (DataObject) root.get(PO_SEQUENCE_PATH + "/shipTo");
assertNull(shipToObjectFromAfterRemove);
}
use of org.eclipse.persistence.sdo.SDOSequence in project eclipselink by eclipse-ee4j.
the class SDOSequenceTestXSD method testAddOpenContentPropertyViaDataObject.
public void testAddOpenContentPropertyViaDataObject() {
// 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
root.set(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(sequenceSizeBefore);
assertNotNull(openSequenceContent);
assertEquals(openSequenceContent, openDOContent);
}
use of org.eclipse.persistence.sdo.SDOSequence in project eclipselink by eclipse-ee4j.
the class SDOSequenceTestXSD method test_booleanReturnFrom_add_Property_Object_WhereValuePassedIsSingleItemInEmptyList.
/**
* Test setting a many property using a single item of a list instead of passing a
* ListWrapper as usual.
* The existing list will need to be null (not an empty ListWrapper)
*/
public void test_booleanReturnFrom_add_Property_Object_WhereValuePassedIsSingleItemInEmptyList() {
// Property property, Object value) {
defineAndLoadRoot(false, false);
SDOSequence aSequence = getSequence(root, PO_SEQUENCE_PATH, PO_SEQUENCE_SIZE);
DataObject po = (DataObject) root.get(PO_SEQUENCE_PATH);
int treeSizeBeforeAdd = preOrderTraversalDataObjectList(po).size();
assertEquals(PO_TREE_SIZE, treeSizeBeforeAdd);
assertEquals(PO_SEQUENCE_SIZE, aSequence.size());
int listSizeBefore = ((ListWrapper) po.get("item")).size();
assertEquals(2, listSizeBefore);
int indexToPlaceAtEnd = aSequence.size();
// object to add
DataObject item2 = (DataObject) root.get("item[2]");
assertNotNull(item2);
Property itemProperty = po.getInstanceProperty("item");
// add to sequence
aSequence.add(itemProperty, item2);
// get back new Setting value
// ListWrapper item2Value = (ListWrapper)aSequence.getValue(indexToPlaceAtEnd);
SDODataObject item2Value = (SDODataObject) aSequence.getValue(indexToPlaceAtEnd);
assertNotNull(item2Value);
assertNotNull(aSequence.getProperty(indexToPlaceAtEnd));
// check increased size of sequence
assertEquals(PO_SEQUENCE_TREE_SIZE + 1, aSequence.size());
// verify that the list has increased
int listSizeAfter = ((ListWrapper) po.get("item")).size();
assertEquals(listSizeBefore + 1, listSizeAfter);
// verify that DataObject has changed
int treeSizeAfterAdd = preOrderTraversalDataObjectList(po).size();
assertEquals(treeSizeBeforeAdd + 1, treeSizeAfterAdd);
}
Aggregations