Search in sources :

Example 1 with SimpleMapArray

use of com.linkedin.pegasus.generator.test.idl.records.SimpleMapArray in project rest.li by linkedin.

the class ArrayGeneratorTest method testWithCustomTypesArray.

@Test
public void testWithCustomTypesArray() throws Throwable {
    String json = load("WithCustomTypesArray.json");
    WithCustomTypesArray original = new WithCustomTypesArray();
    CustomIntArray ints = new CustomIntArray();
    ints.add(new CustomInt(1));
    ints.add(new CustomInt(2));
    ints.add(new CustomInt(3));
    original.setInts(ints);
    SimpleArrayArray arrays = new SimpleArrayArray();
    SimpleArray simpleArray = new SimpleArray();
    Simple simple = new Simple();
    simple.setMessage("a1");
    simpleArray.add(simple);
    arrays.add(simpleArray);
    original.setArrays(arrays);
    SimpleMapArray maps = new SimpleMapArray();
    SimpleMap map = new SimpleMap();
    Simple simplem1 = new Simple();
    simplem1.setMessage("m1");
    map.put("a", simplem1);
    maps.add(map);
    original.setMaps(maps);
    Simple simpleu1 = new Simple();
    simpleu1.setMessage("u1");
    WithCustomTypesArrayUnionArray unions = new WithCustomTypesArrayUnionArray();
    unions.add(WithCustomTypesArrayUnion.create(1));
    unions.add(WithCustomTypesArrayUnion.create("str"));
    unions.add(WithCustomTypesArrayUnion.create(simpleu1));
    original.setUnions(unions);
    Fixed8 fixed8 = new Fixed8(SchemaFixtures.bytesFixed8);
    Fixed8Array fixed8Array = new Fixed8Array();
    fixed8Array.add(fixed8);
    original.setFixed(fixed8Array);
    assertJson(original, json);
    WithCustomTypesArray roundTripped = new WithCustomTypesArray(roundTrip(original.data()));
    assertJson(roundTripped, json);
}
Also used : Fixed8(com.linkedin.pegasus.generator.test.idl.fixed.Fixed8) SimpleArray(com.linkedin.pegasus.generator.test.idl.records.SimpleArray) SimpleMap(com.linkedin.pegasus.generator.test.idl.records.SimpleMap) WithCustomTypesArrayUnionArray(com.linkedin.pegasus.generator.test.idl.arrays.WithCustomTypesArrayUnionArray) WithCustomTypesArray(com.linkedin.pegasus.generator.test.idl.arrays.WithCustomTypesArray) CustomIntArray(com.linkedin.pegasus.generator.test.idl.customtypes.CustomIntArray) SimpleMapArray(com.linkedin.pegasus.generator.test.idl.records.SimpleMapArray) CustomInt(com.linkedin.pegasus.generator.test.pdl.fixtures.CustomInt) SimpleArrayArray(com.linkedin.pegasus.generator.test.idl.records.SimpleArrayArray) Fixed8Array(com.linkedin.pegasus.generator.test.idl.fixed.Fixed8Array) Simple(com.linkedin.pegasus.generator.test.idl.records.Simple) Test(org.testng.annotations.Test)

Aggregations

WithCustomTypesArray (com.linkedin.pegasus.generator.test.idl.arrays.WithCustomTypesArray)1 WithCustomTypesArrayUnionArray (com.linkedin.pegasus.generator.test.idl.arrays.WithCustomTypesArrayUnionArray)1 CustomIntArray (com.linkedin.pegasus.generator.test.idl.customtypes.CustomIntArray)1 Fixed8 (com.linkedin.pegasus.generator.test.idl.fixed.Fixed8)1 Fixed8Array (com.linkedin.pegasus.generator.test.idl.fixed.Fixed8Array)1 Simple (com.linkedin.pegasus.generator.test.idl.records.Simple)1 SimpleArray (com.linkedin.pegasus.generator.test.idl.records.SimpleArray)1 SimpleArrayArray (com.linkedin.pegasus.generator.test.idl.records.SimpleArrayArray)1 SimpleMap (com.linkedin.pegasus.generator.test.idl.records.SimpleMap)1 SimpleMapArray (com.linkedin.pegasus.generator.test.idl.records.SimpleMapArray)1 CustomInt (com.linkedin.pegasus.generator.test.pdl.fixtures.CustomInt)1 Test (org.testng.annotations.Test)1