Search in sources :

Example 1 with Empty

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

the class ArrayGeneratorTest method testWithRecordArray.

@Test
public void testWithRecordArray() throws Throwable {
    String json = load("WithRecordArray.json");
    WithRecordArray original = new WithRecordArray().setEmpties(new EmptyArray(new Empty(), new Empty(), new Empty())).setFruits(new FruitsArray(Fruits.APPLE, Fruits.BANANA, Fruits.ORANGE));
    assertJson(original, json);
    WithRecordArray roundTripped = new WithRecordArray(roundTrip(original.data()));
    assertJson(roundTripped, json);
}
Also used : Empty(com.linkedin.pegasus.generator.test.idl.records.Empty) FruitsArray(com.linkedin.pegasus.generator.test.idl.enums.FruitsArray) EmptyArray(com.linkedin.pegasus.generator.test.idl.records.EmptyArray) WithRecordArray(com.linkedin.pegasus.generator.test.idl.arrays.WithRecordArray) Test(org.testng.annotations.Test)

Example 2 with Empty

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

the class UnionGeneratorTest method testWithComplexTypesUnion.

@Test
public void testWithComplexTypesUnion() throws Throwable {
    assertEquals(WithComplexTypesUnion.Union.MEMBERKEY_Empty, "com.linkedin.pegasus.generator.test.idl.records.Empty");
    assertEquals(WithComplexTypesUnion.Union.MEMBERKEY_Fruits, "com.linkedin.pegasus.generator.test.idl.enums.Fruits");
    assertEquals(WithComplexTypesUnion.Union.MEMBERKEY_Array, "array");
    assertEquals(WithComplexTypesUnion.Union.MEMBERKEY_Map, "map");
    WithComplexTypesUnion.Union recordMember = WithComplexTypesUnion.Union.create(new Empty());
    WithComplexTypesUnion.Union enumMember = WithComplexTypesUnion.Union.create(Fruits.APPLE);
    SimpleMap simpleMap = new SimpleMap();
    Simple m1 = new Simple();
    m1.setMessage("m1");
    simpleMap.put("a", m1);
    WithComplexTypesUnion.Union mapMember = WithComplexTypesUnion.Union.create(simpleMap);
    SimpleArray simpleArray = new SimpleArray();
    Simple a1 = new Simple();
    a1.setMessage("a1");
    simpleArray.add(a1);
    WithComplexTypesUnion.Union arrayMember = WithComplexTypesUnion.Union.create(simpleArray);
    WithComplexTypesUnion withRecord = new WithComplexTypesUnion();
    withRecord.setUnion(recordMember);
    assertJson(withRecord, load("WithComplexTypesUnion_Empty.json"));
    WithComplexTypesUnion withEnum = new WithComplexTypesUnion();
    withEnum.setUnion(enumMember);
    assertJson(withEnum, load("WithComplexTypesUnion_Enum.json"));
    WithComplexTypesUnion withArray = new WithComplexTypesUnion();
    withArray.setUnion(arrayMember);
    assertJson(withArray, load("WithComplexTypesUnion_Array.json"));
    WithComplexTypesUnion withMap = new WithComplexTypesUnion();
    withMap.setUnion(mapMember);
    assertJson(withMap, load("WithComplexTypesUnion_Map.json"));
}
Also used : Empty(com.linkedin.pegasus.generator.test.idl.records.Empty) WithComplexTypesUnion(com.linkedin.pegasus.generator.test.idl.unions.WithComplexTypesUnion) SimpleArray(com.linkedin.pegasus.generator.test.idl.records.SimpleArray) SimpleMap(com.linkedin.pegasus.generator.test.idl.records.SimpleMap) Simple(com.linkedin.pegasus.generator.test.idl.records.Simple) Test(org.testng.annotations.Test)

Example 3 with Empty

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

the class MapGeneratorTest method testWithComplexTypesMap.

@Test
public void testWithComplexTypesMap() throws Throwable {
    String json = load("WithComplexTypesMap.json");
    WithComplexTypesMap original = new WithComplexTypesMap();
    EmptyMap empties = new EmptyMap();
    empties.put("a", new Empty());
    empties.put("b", new Empty());
    empties.put("c", new Empty());
    original.setEmpties(empties);
    FruitsMap fruits = new FruitsMap();
    fruits.put("a", Fruits.APPLE);
    fruits.put("b", Fruits.BANANA);
    fruits.put("c", Fruits.ORANGE);
    original.setFruits(fruits);
    SimpleArrayMap simpleArrays = new SimpleArrayMap();
    Simple simplev1 = new Simple();
    simplev1.setMessage("v1");
    Simple simplev2 = new Simple();
    simplev2.setMessage("v2");
    SimpleArray simpleArray = new SimpleArray();
    simpleArray.add(simplev1);
    simpleArray.add(simplev2);
    simpleArrays.put("a", simpleArray);
    original.setArrays(simpleArrays);
    SimpleMap simpleMapi1 = new SimpleMap();
    Simple simpleo1i1 = new Simple();
    simpleo1i1.setMessage("o1i1");
    simpleMapi1.put("i1", simpleo1i1);
    Simple simpleo1i2 = new Simple();
    simpleo1i2.setMessage("o1i2");
    simpleMapi1.put("i2", simpleo1i2);
    SimpleMapMap maps = new SimpleMapMap();
    maps.put("o1", simpleMapi1);
    original.setMaps(maps);
    WithComplexTypesMapUnionMap unions = new WithComplexTypesMapUnionMap();
    unions.put("a", WithComplexTypesMapUnion.create(1));
    unions.put("b", WithComplexTypesMapUnion.create("u1"));
    original.setUnions(unions);
    Fixed8Map fixed = new Fixed8Map();
    fixed.put("a", new Fixed8(SchemaFixtures.bytesFixed8));
    original.setFixed(fixed);
    assertJson(original, json);
    WithComplexTypesMap roundTripped = new WithComplexTypesMap(roundTrip(original.data()));
    assertJson(roundTripped, json);
}
Also used : WithComplexTypesMapUnionMap(com.linkedin.pegasus.generator.test.idl.maps.WithComplexTypesMapUnionMap) FruitsMap(com.linkedin.pegasus.generator.test.idl.enums.FruitsMap) SimpleArrayMap(com.linkedin.pegasus.generator.test.idl.records.SimpleArrayMap) Fixed8Map(com.linkedin.pegasus.generator.test.idl.fixed.Fixed8Map) Simple(com.linkedin.pegasus.generator.test.idl.records.Simple) Empty(com.linkedin.pegasus.generator.test.idl.records.Empty) SimpleMapMap(com.linkedin.pegasus.generator.test.idl.records.SimpleMapMap) 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) EmptyMap(com.linkedin.pegasus.generator.test.idl.records.EmptyMap) WithComplexTypesMap(com.linkedin.pegasus.generator.test.idl.maps.WithComplexTypesMap) Test(org.testng.annotations.Test)

Example 4 with Empty

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

the class TyperefGeneratorTest method testWithComplexTyperefs.

@Test
public void testWithComplexTyperefs() throws Throwable {
    WithComplexTyperefs original = new WithComplexTyperefs();
    original.setEnum(Fruits.APPLE);
    original.setRecord(new Empty());
    EmptyMap emptyMap = new EmptyMap();
    emptyMap.put("a", new Empty());
    original.setMap(emptyMap);
    EmptyArray emptyArray = new EmptyArray();
    emptyArray.add(new Empty());
    original.setArray(emptyArray);
    original.setUnion(UnionTyperef.create(1));
    WithComplexTyperefs roundTripped = new WithComplexTyperefs(roundTrip(original.data()));
    assertEquals(original.data(), roundTripped.data());
}
Also used : Empty(com.linkedin.pegasus.generator.test.idl.records.Empty) EmptyArray(com.linkedin.pegasus.generator.test.idl.records.EmptyArray) WithComplexTyperefs(com.linkedin.pegasus.generator.test.idl.records.WithComplexTyperefs) EmptyMap(com.linkedin.pegasus.generator.test.idl.records.EmptyMap) Test(org.testng.annotations.Test)

Aggregations

Empty (com.linkedin.pegasus.generator.test.idl.records.Empty)4 Test (org.testng.annotations.Test)4 EmptyArray (com.linkedin.pegasus.generator.test.idl.records.EmptyArray)2 EmptyMap (com.linkedin.pegasus.generator.test.idl.records.EmptyMap)2 Simple (com.linkedin.pegasus.generator.test.idl.records.Simple)2 SimpleArray (com.linkedin.pegasus.generator.test.idl.records.SimpleArray)2 SimpleMap (com.linkedin.pegasus.generator.test.idl.records.SimpleMap)2 WithRecordArray (com.linkedin.pegasus.generator.test.idl.arrays.WithRecordArray)1 FruitsArray (com.linkedin.pegasus.generator.test.idl.enums.FruitsArray)1 FruitsMap (com.linkedin.pegasus.generator.test.idl.enums.FruitsMap)1 Fixed8 (com.linkedin.pegasus.generator.test.idl.fixed.Fixed8)1 Fixed8Map (com.linkedin.pegasus.generator.test.idl.fixed.Fixed8Map)1 WithComplexTypesMap (com.linkedin.pegasus.generator.test.idl.maps.WithComplexTypesMap)1 WithComplexTypesMapUnionMap (com.linkedin.pegasus.generator.test.idl.maps.WithComplexTypesMapUnionMap)1 SimpleArrayMap (com.linkedin.pegasus.generator.test.idl.records.SimpleArrayMap)1 SimpleMapMap (com.linkedin.pegasus.generator.test.idl.records.SimpleMapMap)1 WithComplexTyperefs (com.linkedin.pegasus.generator.test.idl.records.WithComplexTyperefs)1 WithComplexTypesUnion (com.linkedin.pegasus.generator.test.idl.unions.WithComplexTypesUnion)1