Search in sources :

Example 1 with WithComplexTypes

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

the class RecordGeneratorTest method testWithComplexTypes.

@Test
public void testWithComplexTypes() throws Throwable {
    WithComplexTypes original = new WithComplexTypes();
    Simple simple = new Simple();
    simple.setMessage("message");
    original.setRecord(simple);
    original.setEnum(Fruits.APPLE);
    original.setUnion(WithComplexTypes.Union.create(1));
    IntegerArray intArray = new IntegerArray();
    intArray.add(1);
    original.setArray(intArray);
    IntegerMap intMap = new IntegerMap();
    intMap.put("a", 1);
    original.setMap(intMap);
    SimpleMap simpleMap = new SimpleMap();
    simpleMap.put("a", simple);
    original.setComplexMap(simpleMap);
    original.setCustom(new CustomInt(1));
    WithComplexTypes roundTripped = new WithComplexTypes(roundTrip(original.data()));
    assertEquals(roundTripped.getRecord(), simple);
    assertEquals(roundTripped.getEnum(), Fruits.APPLE);
}
Also used : IntegerMap(com.linkedin.data.template.IntegerMap) WithComplexTypes(com.linkedin.pegasus.generator.test.idl.records.WithComplexTypes) SimpleMap(com.linkedin.pegasus.generator.test.idl.records.SimpleMap) CustomInt(com.linkedin.pegasus.generator.test.pdl.fixtures.CustomInt) Simple(com.linkedin.pegasus.generator.test.idl.records.Simple) IntegerArray(com.linkedin.data.template.IntegerArray) Test(org.testng.annotations.Test)

Aggregations

IntegerArray (com.linkedin.data.template.IntegerArray)1 IntegerMap (com.linkedin.data.template.IntegerMap)1 Simple (com.linkedin.pegasus.generator.test.idl.records.Simple)1 SimpleMap (com.linkedin.pegasus.generator.test.idl.records.SimpleMap)1 WithComplexTypes (com.linkedin.pegasus.generator.test.idl.records.WithComplexTypes)1 CustomInt (com.linkedin.pegasus.generator.test.pdl.fixtures.CustomInt)1 Test (org.testng.annotations.Test)1