Search in sources :

Example 1 with DirectMapTemplate

use of com.linkedin.data.template.DirectMapTemplate in project rest.li by linkedin.

the class TestSchemaSampleDataGenerator method testMapSchema.

@Test
public void testMapSchema() {
    for (Map.Entry<DataSchema.Type, Class<? extends DirectMapTemplate<?>>> entry : _dataSchemaTypeToprimitiveMapMap.entrySet()) {
        final PrimitiveDataSchema valueSchema = DataSchemaUtil.dataSchemaTypeToPrimitiveDataSchema(entry.getKey());
        final MapDataSchema mapSchema = new MapDataSchema(valueSchema);
        final DataMap value = (DataMap) SchemaSampleDataGenerator.buildData(mapSchema, _spec);
        final ParameterizedType mapType = (ParameterizedType) entry.getValue().getGenericSuperclass();
        assert (mapType.getRawType() == DirectMapTemplate.class);
        Assert.assertSame(value.values().iterator().next().getClass(), mapType.getActualTypeArguments()[0]);
    }
}
Also used : ParameterizedType(java.lang.reflect.ParameterizedType) ParameterizedType(java.lang.reflect.ParameterizedType) PrimitiveDataSchema(com.linkedin.data.schema.PrimitiveDataSchema) MapDataSchema(com.linkedin.data.schema.MapDataSchema) DirectMapTemplate(com.linkedin.data.template.DirectMapTemplate) BooleanMap(com.linkedin.data.template.BooleanMap) Map(java.util.Map) IdentityHashMap(java.util.IdentityHashMap) DoubleMap(com.linkedin.data.template.DoubleMap) BytesMap(com.linkedin.data.template.BytesMap) FloatMap(com.linkedin.data.template.FloatMap) IntegerMap(com.linkedin.data.template.IntegerMap) DataMap(com.linkedin.data.DataMap) StringMap(com.linkedin.data.template.StringMap) LongMap(com.linkedin.data.template.LongMap) DataMap(com.linkedin.data.DataMap) UnionTest(com.linkedin.pegasus.generator.test.UnionTest) Test(org.testng.annotations.Test) TyperefTest(com.linkedin.pegasus.generator.test.TyperefTest)

Aggregations

DataMap (com.linkedin.data.DataMap)1 MapDataSchema (com.linkedin.data.schema.MapDataSchema)1 PrimitiveDataSchema (com.linkedin.data.schema.PrimitiveDataSchema)1 BooleanMap (com.linkedin.data.template.BooleanMap)1 BytesMap (com.linkedin.data.template.BytesMap)1 DirectMapTemplate (com.linkedin.data.template.DirectMapTemplate)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 TyperefTest (com.linkedin.pegasus.generator.test.TyperefTest)1 UnionTest (com.linkedin.pegasus.generator.test.UnionTest)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 IdentityHashMap (java.util.IdentityHashMap)1 Map (java.util.Map)1 Test (org.testng.annotations.Test)1