Search in sources :

Example 16 with Sequence

use of commonj.sdo.Sequence in project eclipselink by eclipse-ee4j.

the class ChangeSummaryGetOldSequenceTestCases method testGetOldSequenceNotLogging.

public void testGetOldSequenceNotLogging() {
    cs.endLogging();
    address1Object.set("city", "aaa");
    List oldValues = cs.getOldValues(address1Object);
    assertEquals(0, oldValues.size());
    address1Object.unset(address1Object.getInstanceProperty("city"));
    Sequence oldAddressSeq = cs.getOldSequence(address1Object);
    assertNotNull(oldAddressSeq);
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) Sequence(commonj.sdo.Sequence) SDOSequence(org.eclipse.persistence.sdo.SDOSequence)

Example 17 with Sequence

use of commonj.sdo.Sequence in project eclipselink by eclipse-ee4j.

the class ChangeSummaryGetOldSequenceTestCases method testGetOldSequenceNull.

public void testGetOldSequenceNull() {
    cs.beginLogging();
    Sequence oldSeq = cs.getOldSequence(null);
    assertNull(oldSeq);
}
Also used : Sequence(commonj.sdo.Sequence) SDOSequence(org.eclipse.persistence.sdo.SDOSequence)

Example 18 with Sequence

use of commonj.sdo.Sequence in project eclipselink by eclipse-ee4j.

the class ChangeSummaryGetOldSequenceTestCases method testGetOldSequenceAfterUnsetAllOnAddress.

public void testGetOldSequenceAfterUnsetAllOnAddress() {
    cs.beginLogging();
    address1Object.unset(3);
    address1Object.unset(2);
    address1Object.unset(1);
    address1Object.unset(0);
    assertEquals(0, ((SDOSequence) address1Object.getSequence()).getSettings().size());
    boolean exception = false;
    try {
        address1Object.getSequence().getProperty(0);
    } catch (SDOException e) {
        // do nothing
        assertEquals(SDOException.INVALID_INDEX, e.getErrorCode());
        exception = true;
    } finally {
        assertTrue(exception);
        exception = false;
    }
    try {
        address1Object.getSequence().getValue(0);
    } catch (SDOException e) {
        // do nothing
        assertEquals(SDOException.INVALID_INDEX, e.getErrorCode());
        exception = true;
    } finally {
        assertTrue(exception);
        exception = false;
    }
    Property cityProp = address1Object.getInstanceProperty("city");
    ChangeSummary.Setting cityOldSetting = cs.getOldValue(address1Object, cityProp);
    assertNotNull(cityOldSetting);
    Object oldCityValue = cityOldSetting.getValue();
    assertNotNull(oldCityValue);
    Sequence address1OldSeq = cs.getOldSequence(address1Object);
    assertNotNull(address1OldSeq);
    assertEquals(4, address1OldSeq.size());
}
Also used : SDOException(org.eclipse.persistence.exceptions.SDOException) DataObject(commonj.sdo.DataObject) Sequence(commonj.sdo.Sequence) SDOSequence(org.eclipse.persistence.sdo.SDOSequence) ChangeSummary(commonj.sdo.ChangeSummary) Property(commonj.sdo.Property) SDOSequence(org.eclipse.persistence.sdo.SDOSequence)

Example 19 with Sequence

use of commonj.sdo.Sequence in project eclipselink by eclipse-ee4j.

the class SDOSequenceTestCS 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
}
Also used : SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) SDOType(org.eclipse.persistence.sdo.SDOType) Sequence(commonj.sdo.Sequence) SDOSequence(org.eclipse.persistence.sdo.SDOSequence) SDOSequence(org.eclipse.persistence.sdo.SDOSequence)

Example 20 with Sequence

use of commonj.sdo.Sequence in project eclipselink by eclipse-ee4j.

the class SDOSequenceTestCS method testEqualDeepTrueAfterIsSequencedSetToFalseAfterDefineViaNonSpecMethod.

/*
//  variant test cases that should cause equality failure
    testSequenceOnCopyHasDifferentOrder
    testSequenceOnCopyIsEmpty
    testSequenceOnCopyIsLarger
    testSequenceOnCopyIsSmaller
    testSequenceOnCopyHasDifferentPropertyAtIndex
    testSequenceOnCopyHasDifferentValueAtIndex
    testSequenceOnOriginalHasDifferentOrder
    testSequenceOnOriginalIsEmpty
    testSequenceOnOriginalIsLarger
    testSequenceOnOriginalIsSmaller
    testSequenceOnOriginalHasDifferentPropertyAtIndex
    testSequenceOnOriginalHasDifferentValueAtIndex
*/
public void testEqualDeepTrueAfterIsSequencedSetToFalseAfterDefineViaNonSpecMethod() {
    defineAndLoadRoot(false, false);
    Sequence 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
    Sequence aSequenceCopy = getSequence(rootCopy, PO_SEQUENCE_PATH, PO_SEQUENCE_SIZE);
    assertNotNull(aSequenceCopy);
    // compareSequences((SDOSequence)aSequence, (SDOSequence)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);
}
Also used : SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) SDOType(org.eclipse.persistence.sdo.SDOType) Sequence(commonj.sdo.Sequence) SDOSequence(org.eclipse.persistence.sdo.SDOSequence)

Aggregations

Sequence (commonj.sdo.Sequence)32 SDOSequence (org.eclipse.persistence.sdo.SDOSequence)29 DataObject (commonj.sdo.DataObject)18 SDODataObject (org.eclipse.persistence.sdo.SDODataObject)12 List (java.util.List)10 ArrayList (java.util.ArrayList)8 ChangeSummary (commonj.sdo.ChangeSummary)7 SDOChangeSummary (org.eclipse.persistence.sdo.SDOChangeSummary)6 SDOType (org.eclipse.persistence.sdo.SDOType)4 Property (commonj.sdo.Property)3 DataHelper (commonj.sdo.helper.DataHelper)1 TypeHelper (commonj.sdo.helper.TypeHelper)1 Iterator (java.util.Iterator)1 SDOException (org.eclipse.persistence.exceptions.SDOException)1 XMLConversionManager (org.eclipse.persistence.internal.oxm.XMLConversionManager)1 XMLRoot (org.eclipse.persistence.oxm.XMLRoot)1 XMLUnmarshaller (org.eclipse.persistence.oxm.XMLUnmarshaller)1 SequencedObject (org.eclipse.persistence.oxm.sequenced.SequencedObject)1 SDOProperty (org.eclipse.persistence.sdo.SDOProperty)1 ListWrapper (org.eclipse.persistence.sdo.helper.ListWrapper)1