Search in sources :

Example 1 with WithPrimitivesArray

use of com.linkedin.pegasus.generator.test.idl.arrays.WithPrimitivesArray in project rest.li by linkedin.

the class ArrayGeneratorTest method testWithPrimitivesArray.

@Test
public void testWithPrimitivesArray() throws Throwable {
    String json = load("WithPrimitivesArray.json");
    WithPrimitivesArray original = new WithPrimitivesArray();
    IntegerArray ints = new IntegerArray();
    ints.add(1);
    ints.add(2);
    ints.add(3);
    original.setInts(ints);
    LongArray longs = new LongArray();
    longs.add(10L);
    longs.add(20L);
    longs.add(30L);
    original.setLongs(longs);
    FloatArray floats = new FloatArray();
    floats.add(1.1f);
    floats.add(2.2f);
    floats.add(3.3f);
    original.setFloats(floats);
    DoubleArray doubles = new DoubleArray();
    doubles.add(11.1d);
    doubles.add(22.2d);
    doubles.add(33.3d);
    original.setDoubles(doubles);
    BooleanArray booleans = new BooleanArray();
    booleans.add(false);
    booleans.add(true);
    original.setBooleans(booleans);
    StringArray strings = new StringArray();
    strings.add("a");
    strings.add("b");
    strings.add("c");
    original.setStrings(strings);
    BytesArray bytes = new BytesArray();
    bytes.add(SchemaFixtures.bytes1);
    bytes.add(SchemaFixtures.bytes2);
    original.setBytes(bytes);
    assertJson(original, json);
    WithPrimitivesArray roundTripped = new WithPrimitivesArray(roundTrip(original.data()));
    assertJson(roundTripped, json);
}
Also used : LongArray(com.linkedin.data.template.LongArray) BytesArray(com.linkedin.data.template.BytesArray) FloatArray(com.linkedin.data.template.FloatArray) StringArray(com.linkedin.data.template.StringArray) WithPrimitivesArray(com.linkedin.pegasus.generator.test.idl.arrays.WithPrimitivesArray) DoubleArray(com.linkedin.data.template.DoubleArray) IntegerArray(com.linkedin.data.template.IntegerArray) BooleanArray(com.linkedin.data.template.BooleanArray) Test(org.testng.annotations.Test)

Aggregations

BooleanArray (com.linkedin.data.template.BooleanArray)1 BytesArray (com.linkedin.data.template.BytesArray)1 DoubleArray (com.linkedin.data.template.DoubleArray)1 FloatArray (com.linkedin.data.template.FloatArray)1 IntegerArray (com.linkedin.data.template.IntegerArray)1 LongArray (com.linkedin.data.template.LongArray)1 StringArray (com.linkedin.data.template.StringArray)1 WithPrimitivesArray (com.linkedin.pegasus.generator.test.idl.arrays.WithPrimitivesArray)1 Test (org.testng.annotations.Test)1