Search in sources :

Example 1 with WithPrimitivesMap

use of com.linkedin.pegasus.generator.test.idl.maps.WithPrimitivesMap in project rest.li by linkedin.

the class MapGeneratorTest method testWithPrimitivesMap.

@Test
public void testWithPrimitivesMap() throws Throwable {
    String json = load("WithPrimitivesMap.json");
    WithPrimitivesMap original = new WithPrimitivesMap();
    IntegerMap ints = new IntegerMap();
    ints.put("a", 1);
    ints.put("b", 2);
    ints.put("c", 3);
    original.setInts(ints);
    LongMap longs = new LongMap();
    longs.put("a", 10L);
    longs.put("b", 20L);
    longs.put("c", 30L);
    original.setLongs(longs);
    FloatMap floats = new FloatMap();
    floats.put("a", 1.1f);
    floats.put("b", 2.2f);
    floats.put("c", 3.3f);
    original.setFloats(floats);
    DoubleMap doubles = new DoubleMap();
    doubles.put("a", 11.1d);
    doubles.put("b", 22.2d);
    doubles.put("c", 33.3d);
    original.setDoubles(doubles);
    BooleanMap booleans = new BooleanMap();
    booleans.put("a", true);
    booleans.put("b", false);
    booleans.put("c", true);
    original.setBooleans(booleans);
    StringMap strings = new StringMap();
    strings.put("a", "string1");
    strings.put("b", "string2");
    strings.put("c", "string3");
    original.setStrings(strings);
    BytesMap bytes = new BytesMap();
    bytes.put("a", SchemaFixtures.bytes1);
    bytes.put("b", SchemaFixtures.bytes2);
    bytes.put("c", SchemaFixtures.bytes3);
    original.setBytes(bytes);
    assertJson(original, json);
    WithPrimitivesMap roundTripped = new WithPrimitivesMap(roundTrip(original.data()));
    assertJson(roundTripped, json);
}
Also used : IntegerMap(com.linkedin.data.template.IntegerMap) LongMap(com.linkedin.data.template.LongMap) StringMap(com.linkedin.data.template.StringMap) BooleanMap(com.linkedin.data.template.BooleanMap) WithPrimitivesMap(com.linkedin.pegasus.generator.test.idl.maps.WithPrimitivesMap) BytesMap(com.linkedin.data.template.BytesMap) FloatMap(com.linkedin.data.template.FloatMap) DoubleMap(com.linkedin.data.template.DoubleMap) Test(org.testng.annotations.Test)

Aggregations

BooleanMap (com.linkedin.data.template.BooleanMap)1 BytesMap (com.linkedin.data.template.BytesMap)1 DoubleMap (com.linkedin.data.template.DoubleMap)1 FloatMap (com.linkedin.data.template.FloatMap)1 IntegerMap (com.linkedin.data.template.IntegerMap)1 LongMap (com.linkedin.data.template.LongMap)1 StringMap (com.linkedin.data.template.StringMap)1 WithPrimitivesMap (com.linkedin.pegasus.generator.test.idl.maps.WithPrimitivesMap)1 Test (org.testng.annotations.Test)1