summaryrefslogtreecommitdiffstats
path: root/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyBase.java
diff options
context:
space:
mode:
Diffstat (limited to 'sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyBase.java')
-rw-r--r--sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyBase.java907
1 files changed, 907 insertions, 0 deletions
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyBase.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyBase.java
new file mode 100644
index 0000000000..2e554e31c3
--- /dev/null
+++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/tests/api/Sequence/SequenceConsistencyBase.java
@@ -0,0 +1,907 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * $Rev: 536535 $ $Date: 2007-05-09 15:04:49 +0100 (Wed, 09 May 2007) $
+ */
+package test.sdo21.tests.api.Sequence;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.junit.Before;
+
+import test.sdo21.tests.TestData.StandardFactory;
+import test.sdo21.tests.api.CTSConsistencyBase;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Sequence;
+
+public abstract class SequenceConsistencyBase extends CTSConsistencyBase {
+ private DataObject sequenceDO;
+
+ /**
+ * getIndex is a private method used by the SequenceConsistencyBase class to accept as
+ * input a Property and return the index of that Property within the
+ * 'Sequenced' Type
+ */
+ private int getIndex(Property property) {
+ List properties = sequenceDO.getType().getProperties();
+ int propertyIndex = -1;
+ int i = 0;
+
+ while (i < properties.size() && propertyIndex < 0) {
+ if (((Property)properties.get(i)).equals(property))
+ propertyIndex = i;
+ i++;
+ }
+
+ return propertyIndex;
+ }
+
+ /**
+ * populateSequence is called before each test. It provides a set of
+ * consistent data for the tests to work with. The expected outcome of
+ * populateSequence is a Sequence as follows: {<Letters, "A">, <Letters,
+ * "B">, <Numbers, 5>, <Letters, "C">, <Numbers, 16>}
+ * @throws Exception
+ */
+ @Before
+ public void populateSequence() throws Exception {
+ sequenceDO = factory.createTestData(getScope(), StandardFactory.SEQ_TYPE);
+
+ if (sequenceDO.getType().isSequenced()) {
+ Sequence sequence = sequenceDO.getSequence();
+
+ // Add elements to the Sequence by updating the DataObject
+
+ List letterList = sequenceDO.getList("Letters");
+ List numberList = sequenceDO.getList("Numbers");
+
+ letterList.add("A");
+ letterList.add("B");
+ numberList.add(Integer.valueOf(5));
+ letterList.add("C");
+ numberList.add(Integer.valueOf(16));
+ }
+ }
+
+ /**
+ * Verify that Sequence.getProperty(index) throws an Exception for an
+ * invalid index.
+ */
+ @Test
+ public void getPropertyInvalidIndexException() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.getProperty(5);
+ fail("Sequence.getProperty(int) should throw an Exception when an invalid index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Verify that Sequence.getValue() throws an Exception for an invalid index.
+ */
+ @Test
+ public void getValueInvalidIndexException() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.getValue(5);
+ fail("Sequence.getValue(int) should throw an Exception when an invalid index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Verify that Sequence.remove() throws an Exception for an invalid index.
+ */
+ @Test
+ public void removeInvalidIndexException() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.remove(-1);
+ fail("Sequence.remove(int) should throw an Exception when an invalid index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Verify that Sequence.setValue() throws an Exception for an invalid index.
+ */
+ @Test
+ public void setValueInvalidIndexException() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.setValue(5, "attempt");
+ fail("Sequence.setValue(int, Object) should throw an Exception when an invalid index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Verify that Sequence.size() returns the expected value.
+ */
+ @Test
+ public void testSize() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ assertEquals("Sequence.size() returned an unexpected value.", sequence.size(), 5);
+ }
+
+ /**
+ * Verify that Sequence.getProperty() returns the expected values.
+ */
+ @Test
+ public void testGetProperty() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ assertEquals("Sequence.getProperty() returned an unexpected Property.",
+ sequenceDO.getInstanceProperty("Letters"),
+ sequence.getProperty(1));
+ assertEquals("Sequence.getProperty() returned an unexpected Property.",
+ sequenceDO.getInstanceProperty("Numbers"),
+ sequence.getProperty(4));
+ }
+
+ /**
+ * Verify that Sequence.getValue() returns the expected values.
+ */
+ @Test
+ public void testGetValue() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ assertEquals("Sequence.getValue() returned an unexpected value.", "A", sequence.getValue(0));
+ assertEquals("Sequence.getValue() returned an unexpected value.", 5, sequence.getValue(2));
+ }
+
+ /**
+ * Use Sequence.setValue() to modify the Sequence, then verify the outcome
+ */
+ @Test
+ public void testSetValue() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ sequence.setValue(1, "F");
+
+ // {<Letters, "A">, <Letters, "F">, <Numbers, 5>, <Letters, "C">,
+ // <Numbers, 16>}
+
+ assertEquals("Sequence.setValue() did not have the intended effect.", sequence.getValue(1), "F");
+
+ List letters = sequenceDO.getList("Letters");
+ assertEquals("Sequence.setValue() had an unexpected effect on the size of the List in the underlying DataObject.",
+ 3,
+ letters.size());
+ assertEquals("Sequence.setValue() did not have the expected effect on the underlying DataObject.",
+ "F",
+ (String)letters.get(1));
+ }
+
+ /**
+ * Use Sequence.remove() to modify the Sequence, then verify the outcome
+ */
+ @Test
+ public void testRemove() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ sequence.remove(1);
+
+ // {<Letters, "A">, <Numbers, 5>, <Letters, "C">, <Numbers, 16>}
+
+ assertEquals("Sequence.remove() did not decrement the size of the Sequence.", 4, sequence.size());
+ assertEquals("Sequence.remove() did not shift the elements as expected.", 5, sequence.getValue(1));
+
+ List letters = sequenceDO.getList("Letters");
+ assertEquals("Sequence.remove() did not have the expected effect on the size of the List in the underlying DataObject.",
+ 2,
+ letters.size());
+ assertEquals("Sequence.remove() did not have the expected effect on the underlying DataObject.",
+ "C",
+ (String)letters.get(1));
+ }
+
+ /**
+ * Use Sequence.addText(String) to modify the Sequence, then verify the
+ * outcome
+ */
+ @Test
+ public void testAddText() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ String addString = new String("Structured text at the end.");
+ sequence.addText(addString);
+
+ // {<Letters, "A">, <Letters, "B">, <Numbers, 5>, <Letters, "C">,
+ // <Numbers, 16>, "Structured text at the end."}
+
+ assertEquals("Sequence.add(String) did not increment the size of the Sequence.", 6, sequence.size());
+ assertEquals("Sequence.add(String) did not place the correct value at the correct index.",
+ addString,
+ sequence.getValue(5));
+ assertNull("Sequence.add(String) should result in a null Property in the final index.", sequence.getProperty(5));
+ }
+
+ /**
+ * Use Sequence.addText(int, String) to modify the Sequence, then verify the
+ * outcome
+ */
+ @Test
+ public void testAddTextWithIndex() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ String addString = new String("Structured text in the middle.");
+ sequence.addText(2, addString);
+
+ // {<Letters, "A">, <Letters, "B">, "Structured text in the middle.",
+ // <Numbers, 5>, <Letters, "C">, <Numbers, 16>}
+
+ assertEquals("Sequence.addText(int, String) did not increment the size of the Sequence.", 6, sequence
+ .size());
+ assertEquals("Sequence.addText(int, String) did not place the correct value at the correct index.",
+ addString,
+ sequence.getValue(2));
+ assertNull("Sequence.addText(int, String) should result in a null Property in the specified index.",
+ sequence.getProperty(2));
+ }
+
+ /**
+ * Use Sequence.move() to modify the Sequence, then verify the outcome
+ */
+ @Test
+ public void testMove() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ sequence.move(1, 3);
+
+ // {<Letters, "A">, <Letters, "C">, <Letters, "B">, <Numbers, 5>,
+ // <Numbers, 16>}
+
+ assertEquals("Sequence.move() had an unexpected effect on the size of the Sequence.", 5, sequence.size());
+ assertEquals("Sequence.move() did not place the expected value at the expected location.", "C", sequence
+ .getValue(1));
+ assertEquals("Sequence.move() had an unexpected effect on the index following the move-to index.",
+ "B",
+ sequence.getValue(2));
+
+ List letters = sequenceDO.getList("Letters");
+ assertEquals("Sequence.remove() did not have the expected effect on the size of the List in the underlying DataObject.",
+ 3,
+ letters.size());
+ assertEquals("Sequence.remove() did not have the expected effect on the underlying DataObject.",
+ "A",
+ (String)letters.get(0));
+ assertEquals("Sequence.remove() did not have the expected effect on the underlying DataObject.",
+ "C",
+ (String)letters.get(1));
+ assertEquals("Sequence.remove() did not have the expected effect on the underlying DataObject.",
+ "B",
+ (String)letters.get(2));
+ }
+
+ /**
+ * Verify that Sequence.move() throws an Exception for an invalid to index.
+ */
+ @Test
+ public void moveInvalidToIndexException() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.move(5, 0);
+ fail("Sequence.move(int, int) should throw an Exception when an invalid 'to' index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Verify that Sequence.move() throws an Exception for an invalid from
+ * index.
+ */
+ @Test
+ public void moveInvalidFromIndexException() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.move(0, -1);
+ fail("Sequence.move(int, int) should throw an Exception when an invalid 'from' index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Use Sequence.add(Property, Object) to modify the Sequence, then verify
+ * the outcome
+ */
+ @Test
+ public void testAddPropertyObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+ Property numberProp = sequenceDO.getInstanceProperty("Numbers");
+
+ sequence.add(numberProp, Integer.valueOf(8));
+
+ // {<Letters, "A">, <Letters, "B">, <Numbers, 5>, <Letters, "C">,
+ // <Numbers, 16>, <Numbers, 8>}
+
+ assertEquals("Sequence.add(Property, Object) did not increment the size of the Sequence.", 6, sequence
+ .size());
+ assertEquals("Sequence.add(Property, Object) did not place the expected value at the expected index.",
+ 8,
+ sequence.getValue(5));
+ assertEquals("Sequence.add(Property, Object) did not place the expected Property at the expected index.",
+ numberProp,
+ sequence.getProperty(5));
+
+ List numbers = sequenceDO.getList("Numbers");
+
+ assertEquals("Sequence.add(Property, Object) did not have the expected effect on the size of the List in the underlying DataObject.",
+ 3,
+ numbers.size());
+ assertEquals("Sequence.add(Property, Object) did not have the expected effect on the underlying DataObject.",
+ 5,
+ numbers.get(0));
+ assertEquals("Sequence.add(Property, Object) did not have the expected effect on the underlying DataObject.",
+ 16,
+ numbers.get(1));
+ assertEquals("Sequence.add(Property, Object) did not have the expected effect on the underlying DataObject.",
+ 8,
+ numbers.get(2));
+ }
+
+ /**
+ * Attempt add(Property, Object) with an invalid Property and verify the
+ * error handling
+ * @throws Exception
+ */
+ @Test
+ public void addPropertyObjectInvalidProperty() throws Exception {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+ DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
+ try {
+ sequence.add(testDO.getInstanceProperty("dateVal"), "A");
+ fail("Sequence.add(Property, Object) should throw an Exception when an invalid Property is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Attempt add(Property, Object) with an invalid Object and verify the error
+ * handling
+ */
+ @Test
+ public void addPropertyObjectInvalidObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add(sequenceDO.getInstanceProperty("Numbers"), "A");
+ fail("Sequence.add(Property, Object) should throw an Exception when an invalid Object is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Use Sequence.add(String, Object) to modify the Sequence, then verify the
+ * outcome
+ */
+ @Test
+ public void testAddStringObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ sequence.add("Letters", "K");
+
+ // {<Letters, "A">, <Letters, "B">, <Numbers, 5>, <Letters, "C">,
+ // <Numbers, 16>, <Letters, "K">}
+
+ assertEquals("Sequence.add(String, Object) did not increment the size of the Sequence.", 6, sequence
+ .size());
+ assertEquals("Sequence.add(String, Object) did not place the expected value at the expected index.",
+ "K",
+ sequence.getValue(5));
+ assertEquals("Sequence.add(String, Object) did not place the expected Property at the expected index.",
+ sequenceDO.getInstanceProperty("Letters"),
+ sequence.getProperty(5));
+
+ List letters = sequenceDO.getList("Letters");
+ assertEquals("Sequence.add(String, Object) did not have the expected effect on the size of the List in the underlying DataObject.",
+ 4,
+ letters.size());
+ assertEquals("Sequence.add(String, Object) did not have the expected effect on the underlying DataObject.",
+ "A",
+ (String)letters.get(0));
+ assertEquals("Sequence.add(String, Object) did not have the expected effect on the underlying DataObject.",
+ "B",
+ (String)letters.get(1));
+ assertEquals("Sequence.add(String, Object) did not have the expected effect on the underlying DataObject.",
+ "C",
+ (String)letters.get(2));
+ assertEquals("Sequence.add(String, Object) did not have the expected effect on the underlying DataObject.",
+ "K",
+ (String)letters.get(3));
+ }
+
+ /**
+ * Attempt add(String, Object) with an invalid String and verify the error
+ * handling
+ */
+ @Test
+ public void addStringObjectInvalidString() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add("NoSuchProperty", "A");
+ fail("Sequence.add(String, Object) should throw an Exception when an invalid String is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Attempt add(String, Object) with an invalid Object and verify the error
+ * handling
+ */
+ @Test
+ public void addStringObjectInvalidObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add("Numbers", "A");
+ fail("Sequence.add(String, Object) should throw an Exception when an invalid Object is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Use Sequence.add(int, Object) to modify the Sequence, then verify the
+ * outcome
+ */
+ @Test
+ public void testAddIntObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ sequence.add(getIndex(sequenceDO.getInstanceProperty("Numbers")), Integer.valueOf(10));
+
+ // {<Letters, "A">, <Letters, "B">, <Numbers, 5>, <Letters, "C">,
+ // <Numbers, 16>, <Numbers, 10>}
+
+ assertEquals("Sequence.add(Property, Object) did not increment the size of the Sequence.", 6, sequence
+ .size());
+ assertEquals("Sequence.add(Property, Object) did not place the expected value at the expected index.",
+ 10,
+ sequence.getValue(5));
+ assertEquals("Sequence.add(Property, Object) did not place the expected Property at the expected index.",
+ sequenceDO.getInstanceProperty("Numbers"),
+ sequence.getProperty(5));
+
+ List numbers = sequenceDO.getList("Numbers");
+
+ assertEquals("Sequence.add(Property, Object) did not have the expected effect on the size of the List in the underlying DataObject.",
+ 3,
+ numbers.size());
+ assertEquals("Sequence.add(Property, Object) did not have the expected effect on the underlying DataObject.",
+ 5,
+ numbers.get(0));
+ assertEquals("Sequence.add(Property, Object) did not have the expected effect on the underlying DataObject.",
+ 16,
+ numbers.get(1));
+ assertEquals("Sequence.add(Property, Object) did not have the expected effect on the underlying DataObject.",
+ 10,
+ numbers.get(2));
+ }
+
+ /**
+ * Attempt add(int, Object) with an invalid int and verify the error
+ * handling
+ */
+ @Test
+ public void addIntObjectInvalidInt() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ List properties = sequenceDO.getType().getProperties();
+ int invalidIndex = properties.size();
+
+ try {
+ sequence.add(invalidIndex, Integer.valueOf(16));
+ fail("Sequence.add(int, Object) should throw an Exception when an invalid index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Attempt add(int, Object) with an invalid Object and verify the error
+ * handling
+ */
+ @Test
+ public void addIntObjectInvalidObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add(getIndex(sequenceDO.getInstanceProperty("Letters")), 7);
+ fail("Sequence.add(int, Object) should throw an Exception when an invalid Object is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Use Sequence.add(int, String, Object) to modify the Sequence, then verify
+ * the outcome
+ */
+ @Test
+ public void testAddIntStringObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ int sequenceIndex = 0;
+
+ sequence.add(sequenceIndex, "Numbers", Integer.valueOf(10));
+
+ // {<Numbers, 10>, <Letters, "A">, <Letters, "B">, <Numbers, 5>,
+ // <Letters, "C">, <Numbers, 16>}
+
+ assertEquals("Sequence.add(int, String, Object) did not increment the size of the Sequence.", 6, sequence
+ .size());
+ assertEquals("Sequence.add(int, String, Object) did not place the expected value at the expected index.",
+ 10,
+ sequence.getValue(sequenceIndex));
+ assertEquals("Sequence.add(int, String, Object) did not place the expected Property at the expected index.",
+ sequenceDO.getInstanceProperty("Numbers"),
+ sequence.getProperty(sequenceIndex));
+
+ List numbers = sequenceDO.getList("Numbers");
+ assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the size of the List in the underlying DataObject.",
+ 3,
+ numbers.size());
+ assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the underlying DataObject.",
+ 10,
+ (String)numbers.get(0));
+ assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the underlying DataObject.",
+ 5,
+ (String)numbers.get(1));
+ assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the underlying DataObject.",
+ 16,
+ (String)numbers.get(2));
+ }
+
+ /**
+ * Attempt add(int, String, Object) with an invalid int and verify the error
+ * handling
+ */
+ @Test
+ public void addIntStringObjectInvalidInt() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add(-1, "Letters", "A");
+ fail("Sequence.add(int, String, Object) should throw an Exception when an invalid Sequence index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Attempt add(int, String, Object) with an invalid String and verify the
+ * error handling
+ */
+ @Test
+ public void addIntStringObjectInvalidString() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add(0, "Does Not Exist", "A");
+ fail("Sequence.add(int, String, Object) should throw an Exception when an invalid String is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Attempt add(int, String, Object) with an invalid Object and verify the
+ * error handling
+ */
+ @Test
+ public void addIntStringObjectInvalidObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add(0, "Numbers", "A");
+ fail("Sequence.add(int, String, Object) should throw an Exception when an invalid Object is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Use Sequence.add(int, Property, Object) to modify the Sequence, then
+ * verify the outcome
+ */
+ @Test
+ public void testAddIntPropertyObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ int sequenceIndex = 3;
+ sequence.add(sequenceIndex, "Letters", "K");
+
+ // {<Letters, "A">, <Letters, "B">, <Numbers, 5>, <Letters, "K">,
+ // <Letters, "C">, <Numbers, 16>}
+
+ assertEquals("Sequence.add(int, Property, Object) did not increment the size of the Sequence.",
+ 6,
+ sequence.size());
+ assertEquals("Sequence.add(int, Property, Object) did not place the expected value at the expected index.",
+ "K",
+ sequence.getValue(sequenceIndex));
+ assertEquals("Sequence.add(int, Property, Object) did not place the expected Property at the expected index.",
+ sequenceDO.getInstanceProperty("Letters"),
+ sequence.getProperty(sequenceIndex));
+
+ List letters = sequenceDO.getList("Letters");
+ assertEquals("Sequence.add(int, Property, Object) did not have the expected effect on the size of the List in the underlying DataObject.",
+ 4,
+ letters.size());
+ assertEquals("Sequence.add(int, Property, Object) did not have the expected effect on the underlying DataObject.",
+ "A",
+ (String)letters.get(0));
+ assertEquals("Sequence.add(int, Property, Object) did not have the expected effect on the underlying DataObject.",
+ "B",
+ (String)letters.get(1));
+ assertEquals("Sequence.add(int, Property, Object) did not have the expected effect on the underlying DataObject.",
+ "K",
+ (String)letters.get(2));
+ assertEquals("Sequence.add(int, Property, Object) did not have the expected effect on the underlying DataObject.",
+ "C",
+ (String)letters.get(3));
+ }
+
+ /**
+ * Attempt add(int, Property, Object) with an invalid int and verify the
+ * error handling
+ */
+ @Test
+ public void addIntPropertyObjectInvalidInt() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add(-1, sequenceDO.getInstanceProperty("Letters"), "A");
+ fail("Sequence.add(int, Property, Object) should throw an Exception when an invalid Sequence index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Attempt add(int, Property, Object) with an invalid Property and verify
+ * the error handling
+ * @throws Exception
+ */
+ @Test
+ public void addIntPropertyObjectInvalidProperty() throws Exception {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+ DataObject testDO = factory.createTestData(getScope(), StandardFactory.API_TYPE);
+
+ try {
+ sequence.add(0, testDO.getInstanceProperty("dateVal"), "A");
+ fail("Sequence.add(int, Property, Object) should throw an Exception when an invalid Property is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Attempt add(int, Property, Object) with an invalid Object and verify the
+ * error handling
+ */
+ @Test
+ public void addIntPropertyObjectInvalidObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add(0, sequenceDO.getInstanceProperty("Numbers"), "A");
+ fail("Sequence.add(int, Property, Object) should throw an Exception when an invalid Object is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Use Sequence.add(int, int, Object) to modify the Sequence, then verify
+ * the outcome
+ */
+ @Test
+ public void testAddIntIntObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ int sequenceIndex = 5;
+
+ sequence.add(sequenceIndex, "Numbers", Integer.valueOf(10));
+
+ // {<Letters, "A">, <Letters, "B">, <Numbers, 5>, <Letters, "C">,
+ // <Numbers, 16>, <Numbers, 10>}
+
+ assertEquals("Sequence.add(int, String, Object) did not increment the size of the Sequence.", 6, sequence
+ .size());
+ assertEquals("Sequence.add(int, String, Object) did not place the expected value at the expected index.",
+ 10,
+ sequence.getValue(sequenceIndex));
+ assertEquals("Sequence.add(int, String, Object) did not place the expected Property at the expected index.",
+ sequenceDO.getInstanceProperty("Numbers"),
+ sequence.getProperty(sequenceIndex));
+
+ List numbers = sequenceDO.getList("Numbers");
+ assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the size of the List in the underlying DataObject.",
+ 3,
+ numbers.size());
+ assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the underlying DataObject.",
+ 5,
+ (String)numbers.get(0));
+ assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the underlying DataObject.",
+ 16,
+ (String)numbers.get(1));
+ assertEquals("Sequence.add(int, String, Object) did not have the expected effect on the underlying DataObject.",
+ 10,
+ (String)numbers.get(2));
+ }
+
+ /**
+ * Attempt add(int, int, Object) with an invalid Sequence index and verify
+ * the error handling
+ */
+ @Test
+ public void addIntIntObjectInvalidSequenceIndex() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add(6, getIndex(sequenceDO.getInstanceProperty("Letters")), "A");
+ fail("Sequence.add(int, int, Object) should throw an Exception when an invalid Sequence index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Attempt add(int, int, Object) with an invalid Property index and verify
+ * the error handling
+ */
+ @Test
+ public void addIntIntObjectInvalidPropertyIndex() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add(0, -1, "A");
+ fail("Sequence.add(int, int, Object) should throw an Exception when an invalid Property index is provided.");
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Attempt add(int, int, Object) with an invalid Object and verify the error
+ * handling
+ */
+ @Test
+ public void addIntIntObjectInvalidObject() {
+ assertTrue("The created Type 'Sequenced' has Type.isSequenced() == false. The test cases may not proceed.",
+ sequenceDO.getType().isSequenced());
+
+ Sequence sequence = sequenceDO.getSequence();
+
+ try {
+ sequence.add(0, getIndex(sequenceDO.getInstanceProperty("Letters")), 8);
+ fail("Sequence.add(int, int, Object) should throw an Exception when an invalid Object is provided.");
+ } catch (Exception e) {
+ }
+ }
+}