Search in sources :

Example 1 with CustomInt

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

the class ArrayGeneratorTest method testWithCustomTypesArray.

@Test
public void testWithCustomTypesArray() throws Throwable {
    String json = load("WithCustomTypesArray.json");
    SimpleMap map = new SimpleMap();
    map.put("a", new Simple().setMessage("m1"));
    WithCustomTypesArray original = new WithCustomTypesArray().setInts(new CustomIntArray(new CustomInt(1), new CustomInt(2), new CustomInt(3))).setArrays(new SimpleArrayArray(new SimpleArray(new Simple().setMessage("a1")))).setMaps(new SimpleMapArray(map)).setUnions(new WithCustomTypesArrayUnionArray(WithCustomTypesArrayUnion.create(1), WithCustomTypesArrayUnion.create("str"), WithCustomTypesArrayUnion.create(new Simple().setMessage("u1")))).setFixed(new Fixed8Array(new Fixed8(SchemaFixtures.bytesFixed8)));
    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)

Example 2 with CustomInt

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

the class RecordGeneratorTest method testWithComplexTypes.

@Test
public void testWithComplexTypes() throws Throwable {
    Simple simple = new Simple();
    simple.setMessage("message");
    IntegerMap intMap = new IntegerMap();
    intMap.put("a", 1);
    SimpleMap simpleMap = new SimpleMap();
    simpleMap.put("a", simple);
    WithComplexTypes original = new WithComplexTypes().setRecord(simple).setEnum(Fruits.APPLE).setUnion(WithComplexTypes.Union.create(1)).setArray(new IntegerArray(Collections.singletonList(1))).setMap(intMap).setComplexMap(simpleMap).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)

Example 3 with CustomInt

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

the class RecordGeneratorTest method testWithPrimitiveCustomTypes.

@Test
public void testWithPrimitiveCustomTypes() throws Throwable {
    WithPrimitiveCustomTypes original = new WithPrimitiveCustomTypes();
    original.setIntField(new CustomInt(1));
    assertJson(original, load("WithPrimitiveCustomTypes.json"));
    WithPrimitiveCustomTypes roundTripped = new WithPrimitiveCustomTypes(roundTrip(original.data()));
    assertEquals(roundTripped.getIntField(), new CustomInt(1));
    assertJson(roundTripped, load("WithPrimitiveCustomTypes.json"));
}
Also used : CustomInt(com.linkedin.pegasus.generator.test.pdl.fixtures.CustomInt) WithPrimitiveCustomTypes(com.linkedin.pegasus.generator.test.idl.records.WithPrimitiveCustomTypes) Test(org.testng.annotations.Test)

Example 4 with CustomInt

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

the class MapGeneratorTest method testWithCustomTypesMap.

@Test
public void testWithCustomTypesMap() throws Throwable {
    String json = load("WithCustomTypesMap.json");
    WithCustomTypesMap original = new WithCustomTypesMap();
    CustomIntMap ints = new CustomIntMap();
    ints.put("a", new CustomInt(1));
    ints.put("b", new CustomInt(2));
    ints.put("c", new CustomInt(3));
    original.setInts(ints);
    assertJson(original, json);
    WithCustomTypesMap roundTripped = new WithCustomTypesMap(roundTrip(original.data()));
    assertJson(roundTripped, json);
}
Also used : WithCustomTypesMap(com.linkedin.pegasus.generator.test.idl.maps.WithCustomTypesMap) CustomIntMap(com.linkedin.pegasus.generator.test.idl.customtypes.CustomIntMap) CustomInt(com.linkedin.pegasus.generator.test.pdl.fixtures.CustomInt) Test(org.testng.annotations.Test)

Example 5 with CustomInt

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

the class RecordGeneratorTest method testWithOptionalPrimitiveCustomTypes.

@Test
public void testWithOptionalPrimitiveCustomTypes() throws Throwable {
    WithOptionalPrimitiveCustomTypes original = new WithOptionalPrimitiveCustomTypes();
    original.setIntField(new CustomInt(1));
    WithOptionalPrimitiveCustomTypes roundTripped = new WithOptionalPrimitiveCustomTypes(roundTrip(original.data()));
    assertEquals(roundTripped.getIntField(), new CustomInt(1));
}
Also used : WithOptionalPrimitiveCustomTypes(com.linkedin.pegasus.generator.test.idl.records.WithOptionalPrimitiveCustomTypes) 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