use of org.eclipse.persistence.sdo.SDOSequence in project eclipselink by eclipse-ee4j.
the class SDOSequenceTestCS method testDetachAlsoRemovesSequenceSetting.
public void testDetachAlsoRemovesSequenceSetting() {
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
shipToDO.detach();
// are we removed on the sequence?
int shipToSequenceIndexAfterDelete = getNthSequenceIndexFor(aSequence, "shipTo");
assertEquals(NO_MATCH_INDEX, shipToSequenceIndexAfterDelete);
}
use of org.eclipse.persistence.sdo.SDOSequence in project eclipselink by eclipse-ee4j.
the class SDOSequenceTestCS method test_SequenceReturnFrom_SDODataObject_getSequence_index_type_complex_many.
/**
* Returns the value of a <code>Sequence</code> property identified by the specified property index.
* @param propertyIndex the index of the property.
* @see #get(int)
* @deprecated in 2.1.0.
*/
@Deprecated
public void test_SequenceReturnFrom_SDODataObject_getSequence_index_type_complex_many() {
defineAndLoadRoot(false, false);
assertNotNull(root);
// get property index of porder
int propertyIndex = ((SDOProperty) root.getInstanceProperty(PO_PATH)).getIndexInType();
// Expect a failure for a complex many property
boolean exceptionThrown = false;
int errorCode = -1;
SDOSequence aSequence = null;
try {
aSequence = (SDOSequence) root.getSequence(propertyIndex);
} catch (SDOException e) {
exceptionThrown = true;
errorCode = e.getErrorCode();
} finally {
assertTrue(exceptionThrown);
assertNull(aSequence);
assertEquals(45022, errorCode);
}
}
use of org.eclipse.persistence.sdo.SDOSequence in project eclipselink by eclipse-ee4j.
the class SDOSequenceTestCS method testEqualDeepSameSequence.
public void testEqualDeepSameSequence() {
defineAndLoadRoot(false, false);
SDOSequence aSequence = getSequence(root, PO_SEQUENCE_PATH, PO_SEQUENCE_SIZE);
// compareSequences(aSequence, aSequence, PO_SEQUENCE_SIZE, true);
// get sequence po
DataObject po = (DataObject) root.get(PO_SEQUENCE_PATH);
assertNotNull(po);
assertTrue(po.getType().isSequenced());
// test equalityHelper
boolean bEqual = equalityHelper.equal(po, po);
assertTrue(bEqual);
}
use of org.eclipse.persistence.sdo.SDOSequence in project eclipselink by eclipse-ee4j.
the class SDOSequenceTestCS method testClearComplexManyReferenceByListWrapper.
public void testClearComplexManyReferenceByListWrapper() {
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());
ListWrapper existingList = (ListWrapper) po.get("item");
int listSizeBefore = existingList.size();
assertEquals(2, listSizeBefore);
int indexToPlaceAtEnd = aSequence.size();
// object to add
DataObject item3 = (DataObject) root.get("item[1]");
assertNotNull(item3);
Property itemProperty = po.getInstanceProperty("item");
// add list of items to existing list
List<DataObject> aListToAdd = new ArrayList<DataObject>();
aListToAdd.add(item3);
aListToAdd.add(item3);
existingList.clear();
// verify that the list has decreased on the do
int listSizeAfter = ((ListWrapper) po.get("item")).size();
assertEquals(listSizeBefore - aListToAdd.size(), listSizeAfter);
// verify that the sequence size has decreased
assertEquals(indexToPlaceAtEnd - aListToAdd.size(), aSequence.size());
// check decreased size of sequence
assertEquals(PO_SEQUENCE_TREE_SIZE - aListToAdd.size(), aSequence.size());
// verify that DataObject has changed
int treeSizeAfterAdd = preOrderTraversalDataObjectList(po).size();
assertEquals(treeSizeBeforeAdd - aListToAdd.size(), treeSizeAfterAdd);
}
use of org.eclipse.persistence.sdo.SDOSequence in project eclipselink by eclipse-ee4j.
the class SDOSequenceTestCS method test_PropertyReturnFrom_getProperty.
/**
* Returns the property for the given entry index.
* Returns <code>null</code> for mixed text entries.
* @param index the index of the entry.
*/
public void test_PropertyReturnFrom_getProperty() {
// int index) {
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() - 1;
// object to replace
DataObject item2 = (DataObject) root.get("item[2]");
assertNotNull(item2);
/* // add the item to the current list
ListWrapper existingList = (ListWrapper)aSequence.getValue(indexToPlaceAtEnd);
assertNotNull(existingList);
existingList.add(item2);
boolean exceptionThrown = false;
Property property1 = po.getInstanceProperty("item");
Object property1Return = null;
try {
property1Return = aSequence.getProperty(indexToPlaceAtEnd);
} catch (IndexOutOfBoundsException e) {
exceptionThrown = true;
} finally {
assertFalse(exceptionThrown);
}
// verify property
assertNotNull(property1Return);
assertEquals(property1, property1Return);
*/
}
Aggregations