Search in sources :

Example 36 with IonValue

use of com.amazon.ion.IonValue in project ion-java by amzn.

the class BaseIonSequenceLiteSublistTestCase method sublistAddAllWithIndexOutOfRange.

@Test(expected = IndexOutOfBoundsException.class)
public void sublistAddAllWithIndexOutOfRange() {
    final IonSequence sequence = newSequence();
    final List<IonValue> sublist = sequence.subList(2, 5);
    final List<IonInt> values = Arrays.asList(SYSTEM.newInt(100), SYSTEM.newInt(101));
    sublist.addAll(3, values);
}
Also used : IonValue(com.amazon.ion.IonValue) IonInt(com.amazon.ion.IonInt) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 37 with IonValue

use of com.amazon.ion.IonValue in project ion-java by amzn.

the class BaseIonSequenceLiteSublistTestCase method sublistClearConcurrentModification.

@Test(expected = ConcurrentModificationException.class)
public void sublistClearConcurrentModification() {
    final IonSequence sequence = newSequence();
    final List<IonValue> sublist = sequence.subList(2, 5);
    sequence.retainAll(Collections.emptyList());
    sublist.clear();
}
Also used : IonValue(com.amazon.ion.IonValue) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 38 with IonValue

use of com.amazon.ion.IonValue in project ion-java by amzn.

the class BaseIonSequenceLiteSublistTestCase method sublistRemoveObject.

@Test
public void sublistRemoveObject() {
    final IonSequence sequence = newSequence();
    final List<IonValue> sublist = sequence.subList(2, 5);
    final IonInt ionValue = (IonInt) sequence.get(2);
    assertTrue(sublist.remove(ionValue));
    assertEquals(2, sublist.size());
}
Also used : IonValue(com.amazon.ion.IonValue) IonInt(com.amazon.ion.IonInt) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 39 with IonValue

use of com.amazon.ion.IonValue in project ion-java by amzn.

the class BaseIonSequenceLiteSublistTestCase method sublistToArray.

@Test
public void sublistToArray() {
    final IonSequence sequence = newSequence();
    final List<IonValue> sublist = sequence.subList(2, 5);
    final Object[] array = sublist.toArray();
    assertEquals(3, array.length);
    assertEquals(2, ((IonInt) array[0]).intValue());
    assertEquals(3, ((IonInt) array[1]).intValue());
    assertEquals(4, ((IonInt) array[2]).intValue());
}
Also used : IonValue(com.amazon.ion.IonValue) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 40 with IonValue

use of com.amazon.ion.IonValue in project ion-java by amzn.

the class BaseIonSequenceLiteSublistTestCase method sublistGetOutOfRange.

@Test(expected = IndexOutOfBoundsException.class)
public void sublistGetOutOfRange() {
    final IonSequence sequence = newSequence();
    final List<IonValue> sublist = sequence.subList(2, 5);
    sublist.get(4);
}
Also used : IonValue(com.amazon.ion.IonValue) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Aggregations

IonValue (com.amazon.ion.IonValue)185 Test (org.junit.Test)115 IonSequence (com.amazon.ion.IonSequence)61 SymbolTable (com.amazon.ion.SymbolTable)21 IonDatagram (com.amazon.ion.IonDatagram)20 IonStruct (com.amazon.ion.IonStruct)18 IonInt (com.amazon.ion.IonInt)16 IOException (java.io.IOException)14 IonReader (com.amazon.ion.IonReader)13 IonSystem (com.amazon.ion.IonSystem)12 Result (software.amazon.qldb.Result)11 SymbolToken (com.amazon.ion.SymbolToken)10 ArrayList (java.util.ArrayList)10 IonString (com.amazon.ion.IonString)9 IonException (com.amazon.ion.IonException)7 IonType (com.amazon.ion.IonType)6 IonObjectMapper (com.fasterxml.jackson.dataformat.ion.IonObjectMapper)6 Event (com.amazon.tools.events.Event)5 com.amazon.ion.impl._Private_IonValue (com.amazon.ion.impl._Private_IonValue)4 EventType (com.amazon.tools.events.EventType)4