Search in sources :

Example 1 with WithComplexTypesUnion

use of com.linkedin.pegasus.generator.test.idl.unions.WithComplexTypesUnion in project rest.li by linkedin.

the class UnionGeneratorTest method testWithComplexTypesUnion.

@Test
public void testWithComplexTypesUnion() throws Throwable {
    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)

Aggregations

Empty (com.linkedin.pegasus.generator.test.idl.records.Empty)1 Simple (com.linkedin.pegasus.generator.test.idl.records.Simple)1 SimpleArray (com.linkedin.pegasus.generator.test.idl.records.SimpleArray)1 SimpleMap (com.linkedin.pegasus.generator.test.idl.records.SimpleMap)1 WithComplexTypesUnion (com.linkedin.pegasus.generator.test.idl.unions.WithComplexTypesUnion)1 Test (org.testng.annotations.Test)1