Search in sources :

Example 6 with Sequence

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
}
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 7 with Sequence

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);
}
Also used : DataObject(commonj.sdo.DataObject) DataObject(commonj.sdo.DataObject) List(java.util.List) ArrayList(java.util.ArrayList) Sequence(commonj.sdo.Sequence) SDOSequence(org.eclipse.persistence.sdo.SDOSequence) ChangeSummary(commonj.sdo.ChangeSummary) Property(commonj.sdo.Property)

Example 8 with Sequence

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));
}
Also used : Sequence(commonj.sdo.Sequence) SDOSequence(org.eclipse.persistence.sdo.SDOSequence)

Example 9 with Sequence

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);
}
Also used : Sequence(commonj.sdo.Sequence) SDOSequence(org.eclipse.persistence.sdo.SDOSequence)

Example 10 with Sequence

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));
}
Also used : DataObject(commonj.sdo.DataObject) Sequence(commonj.sdo.Sequence) SDOSequence(org.eclipse.persistence.sdo.SDOSequence) 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