Search in sources :

Example 6 with CustomInt

use of com.linkedin.pegasus.generator.test.pdl.fixtures.CustomInt in project rest.li by linkedin.

the class RecordGeneratorTest method testWithComplexTypesDefaults.

@Test
public void testWithComplexTypesDefaults() {
    WithComplexTypeDefaults withDefaults = new WithComplexTypeDefaults();
    Simple simple = new Simple();
    simple.setMessage("defaults!");
    assertEquals(withDefaults.getRecord(), simple);
    assertEquals(withDefaults.getEnum(), Fruits.APPLE);
    assertEquals(withDefaults.getUnion(), WithComplexTypeDefaults.Union.create(1));
    IntegerArray intArray = new IntegerArray(Collections.singletonList(1));
    assertEquals(withDefaults.getArray(), intArray);
    IntegerMap intMap = new IntegerMap();
    intMap.put("a", 1);
    assertEquals(withDefaults.getMap(), intMap);
    assertEquals(withDefaults.getCustom(), new CustomInt(1));
}
Also used : IntegerMap(com.linkedin.data.template.IntegerMap) WithComplexTypeDefaults(com.linkedin.pegasus.generator.test.idl.records.WithComplexTypeDefaults) 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)

Example 7 with CustomInt

use of com.linkedin.pegasus.generator.test.pdl.fixtures.CustomInt in project rest.li by linkedin.

the class RecordGeneratorTest method testWithOptionalComplexTypesDefaults.

@Test
public void testWithOptionalComplexTypesDefaults() {
    WithOptionalComplexTypeDefaults withDefaults = new WithOptionalComplexTypeDefaults();
    Simple simple = new Simple();
    simple.setMessage("defaults!");
    assertEquals(withDefaults.getRecord(), simple);
    assertEquals(withDefaults.getEnum(), Fruits.APPLE);
    assertEquals(withDefaults.getUnion(), WithComplexTypeDefaults.Union.create(1));
    IntegerArray intArray = new IntegerArray(Collections.singletonList(1));
    assertEquals(withDefaults.getArray(), intArray);
    IntegerMap intMap = new IntegerMap();
    intMap.put("a", 1);
    assertEquals(withDefaults.getMap(), intMap);
    assertEquals(withDefaults.getCustom(), new CustomInt(1));
}
Also used : IntegerMap(com.linkedin.data.template.IntegerMap) WithOptionalComplexTypeDefaults(com.linkedin.pegasus.generator.test.idl.records.WithOptionalComplexTypeDefaults) 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)

Example 8 with CustomInt

use of com.linkedin.pegasus.generator.test.pdl.fixtures.CustomInt in project rest.li by linkedin.

the class UnionGeneratorTest method testWithPrimitiveCustomTypesUnion.

@Test
public void testWithPrimitiveCustomTypesUnion() throws Throwable {
    String json = load("WithPrimitiveCustomTypesUnion_int.json");
    WithPrimitiveCustomTypesUnion original = new WithPrimitiveCustomTypesUnion();
    original.setUnion(WithPrimitiveCustomTypesUnion.Union.create(new CustomInt(1)));
    assertJson(original, json);
    WithPrimitiveCustomTypesUnion roundTripped = new WithPrimitiveCustomTypesUnion(roundTrip(original.data()));
    assertJson(roundTripped, json);
}
Also used : WithPrimitiveCustomTypesUnion(com.linkedin.pegasus.generator.test.idl.unions.WithPrimitiveCustomTypesUnion) CustomInt(com.linkedin.pegasus.generator.test.pdl.fixtures.CustomInt) Test(org.testng.annotations.Test)

Aggregations

CustomInt (com.linkedin.pegasus.generator.test.pdl.fixtures.CustomInt)8 Test (org.testng.annotations.Test)8 Simple (com.linkedin.pegasus.generator.test.idl.records.Simple)4 IntegerArray (com.linkedin.data.template.IntegerArray)3 IntegerMap (com.linkedin.data.template.IntegerMap)3 SimpleMap (com.linkedin.pegasus.generator.test.idl.records.SimpleMap)2 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 CustomIntMap (com.linkedin.pegasus.generator.test.idl.customtypes.CustomIntMap)1 Fixed8 (com.linkedin.pegasus.generator.test.idl.fixed.Fixed8)1 Fixed8Array (com.linkedin.pegasus.generator.test.idl.fixed.Fixed8Array)1 WithCustomTypesMap (com.linkedin.pegasus.generator.test.idl.maps.WithCustomTypesMap)1 SimpleArray (com.linkedin.pegasus.generator.test.idl.records.SimpleArray)1 SimpleArrayArray (com.linkedin.pegasus.generator.test.idl.records.SimpleArrayArray)1 SimpleMapArray (com.linkedin.pegasus.generator.test.idl.records.SimpleMapArray)1 WithComplexTypeDefaults (com.linkedin.pegasus.generator.test.idl.records.WithComplexTypeDefaults)1 WithComplexTypes (com.linkedin.pegasus.generator.test.idl.records.WithComplexTypes)1 WithOptionalComplexTypeDefaults (com.linkedin.pegasus.generator.test.idl.records.WithOptionalComplexTypeDefaults)1 WithOptionalPrimitiveCustomTypes (com.linkedin.pegasus.generator.test.idl.records.WithOptionalPrimitiveCustomTypes)1