Search in sources :

Example 41 with IonValue

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

the class BaseIonSequenceLiteSublistTestCase method sublistAdd.

@Test
public void sublistAdd() {
    final IonSequence sequence = newSequence();
    final List<IonValue> sublist = sequence.subList(2, 5);
    final IonInt value = SYSTEM.newInt(99);
    sublist.add(value);
    assertEquals(4, sublist.size());
    assertEquals(value, sublist.get(3));
}
Also used : IonValue(com.amazon.ion.IonValue) IonInt(com.amazon.ion.IonInt) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 42 with IonValue

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

the class BaseIonSequenceLiteSublistTestCase method sublistRetainAllConcurrentModification.

@Test(expected = ConcurrentModificationException.class)
public void sublistRetainAllConcurrentModification() {
    final IonSequence sequence = newSequence();
    final List<IonValue> sublist = sequence.subList(2, 5);
    sequence.remove(0);
    sublist.retainAll(Arrays.asList(SYSTEM.newInt(100), SYSTEM.newInt(101)));
}
Also used : IonValue(com.amazon.ion.IonValue) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 43 with IonValue

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

the class BaseIonSequenceLiteSublistTestCase method sublistAddWithIndex.

@Test
public void sublistAddWithIndex() {
    final IonSequence sequence = newSequence();
    final List<IonValue> sublist = sequence.subList(2, 5);
    final IonInt value = SYSTEM.newInt(99);
    sublist.add(0, value);
    assertEquals(4, sublist.size());
    assertEquals(value, sublist.get(0));
    assertEquals(2, ((IonInt) sublist.get(1)).intValue());
}
Also used : IonValue(com.amazon.ion.IonValue) IonInt(com.amazon.ion.IonInt) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 44 with IonValue

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

the class BaseIonSequenceLiteSublistTestCase method sublistGet.

@Test
public void sublistGet() {
    final IonSequence sequence = newSequence();
    final List<IonValue> sublist = sequence.subList(2, 5);
    final IonValue element = sublist.get(0);
    assertEquals(2, ((IonInt) element).intValue());
}
Also used : IonValue(com.amazon.ion.IonValue) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 45 with IonValue

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

the class BaseIonSequenceLiteSublistTestCase method sublistAddAll.

@Test
public void sublistAddAll() {
    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(values);
    assertEquals(5, sublist.size());
    assertEquals(values.get(0), sublist.get(3));
    assertEquals(values.get(1), sublist.get(4));
}
Also used : IonValue(com.amazon.ion.IonValue) IonInt(com.amazon.ion.IonInt) 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