Search in sources :

Example 1 with DirectArrayTemplate

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

the class TestSchemaSampleDataGenerator method testArraySchema.

@Test
public void testArraySchema() {
    for (Map.Entry<DataSchema.Type, Class<? extends DirectArrayTemplate<?>>> entry : _dataSchemaTypeToprimitiveArrayMap.entrySet()) {
        final PrimitiveDataSchema itemsSchema = DataSchemaUtil.dataSchemaTypeToPrimitiveDataSchema(entry.getKey());
        final ArrayDataSchema arraySchema = new ArrayDataSchema(itemsSchema);
        final DataList value = (DataList) SchemaSampleDataGenerator.buildData(arraySchema, _spec);
        final ParameterizedType arrayType = (ParameterizedType) entry.getValue().getGenericSuperclass();
        assert (arrayType.getRawType() == DirectArrayTemplate.class);
        Assert.assertSame(value.get(0).getClass(), arrayType.getActualTypeArguments()[0]);
    }
}
Also used : ParameterizedType(java.lang.reflect.ParameterizedType) DirectArrayTemplate(com.linkedin.data.template.DirectArrayTemplate) ArrayDataSchema(com.linkedin.data.schema.ArrayDataSchema) DataList(com.linkedin.data.DataList) ParameterizedType(java.lang.reflect.ParameterizedType) PrimitiveDataSchema(com.linkedin.data.schema.PrimitiveDataSchema) 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) UnionTest(com.linkedin.pegasus.generator.test.UnionTest) Test(org.testng.annotations.Test) TyperefTest(com.linkedin.pegasus.generator.test.TyperefTest)

Aggregations

DataList (com.linkedin.data.DataList)1 DataMap (com.linkedin.data.DataMap)1 ArrayDataSchema (com.linkedin.data.schema.ArrayDataSchema)1 PrimitiveDataSchema (com.linkedin.data.schema.PrimitiveDataSchema)1 BooleanMap (com.linkedin.data.template.BooleanMap)1 BytesMap (com.linkedin.data.template.BytesMap)1 DirectArrayTemplate (com.linkedin.data.template.DirectArrayTemplate)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