Search in sources :

Example 51 with ArrayDataSchema

use of com.linkedin.data.schema.ArrayDataSchema in project rest.li by linkedin.

the class TestArray method testStringArrayArray.

@Test
public void testStringArrayArray() {
    TestDataTemplateUtil.FieldInfo fieldInfo = TestDataTemplateUtil.fieldInfo(new ArrayTest(), "stringArrayArray");
    @SuppressWarnings("unchecked") Class<StringArrayArray> templateClass = (Class<StringArrayArray>) fieldInfo.getFieldClass();
    ArrayDataSchema schema = (ArrayDataSchema) fieldInfo.getField().getType();
    List<StringArray> input = new ArrayList<>();
    for (int i = 0; i < 5; ++i) {
        input.add(new StringArray("input" + i));
    }
    List<StringArray> adds = new ArrayList<>();
    for (int i = 0; i < 5; ++i) {
        adds.add(new StringArray("add" + i));
    }
    TestArrayTemplate.testArray(templateClass, schema, input, adds);
}
Also used : ArrayDataSchema(com.linkedin.data.schema.ArrayDataSchema) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test)

Example 52 with ArrayDataSchema

use of com.linkedin.data.schema.ArrayDataSchema in project rest.li by linkedin.

the class TestArray method testEnumFruitsArray.

@Test
public void testEnumFruitsArray() {
    TestDataTemplateUtil.FieldInfo fieldInfo = TestDataTemplateUtil.fieldInfo(new ArrayTest(), "enumFruitsArray");
    @SuppressWarnings("unchecked") Class<EnumFruitsArray> templateClass = (Class<EnumFruitsArray>) fieldInfo.getFieldClass();
    ArrayDataSchema schema = (ArrayDataSchema) fieldInfo.getField().getType();
    // must be unique
    List<EnumFruits> input = Arrays.asList(EnumFruits.APPLE, EnumFruits.ORANGE, EnumFruits.BANANA);
    List<EnumFruits> adds = Arrays.asList(EnumFruits.GRAPES, EnumFruits.PINEAPPLE);
    TestArrayTemplate.testArray(templateClass, schema, input, adds);
}
Also used : ArrayDataSchema(com.linkedin.data.schema.ArrayDataSchema) Test(org.testng.annotations.Test)

Example 53 with ArrayDataSchema

use of com.linkedin.data.schema.ArrayDataSchema in project rest.li by linkedin.

the class TestArray method testIntegerArray.

@Test
public void testIntegerArray() {
    TestDataTemplateUtil.FieldInfo fieldInfo = TestDataTemplateUtil.fieldInfo(new ArrayTest(), "intArray");
    @SuppressWarnings("unchecked") Class<IntegerArray> templateClass = (Class<IntegerArray>) fieldInfo.getFieldClass();
    ArrayDataSchema schema = (ArrayDataSchema) fieldInfo.getField().getType();
    // must be unique
    List<Integer> input = Arrays.asList(1, 3, 5, 7, 9);
    List<Integer> adds = Arrays.asList(11, 13);
    TestArrayTemplate.testArray(templateClass, schema, input, adds);
}
Also used : ArrayDataSchema(com.linkedin.data.schema.ArrayDataSchema) TestDataTemplateUtil(com.linkedin.data.template.TestDataTemplateUtil) IntegerArray(com.linkedin.data.template.IntegerArray) Test(org.testng.annotations.Test)

Example 54 with ArrayDataSchema

use of com.linkedin.data.schema.ArrayDataSchema in project rest.li by linkedin.

the class TestArray method testStringMapArray.

@Test
public void testStringMapArray() {
    TestDataTemplateUtil.FieldInfo fieldInfo = TestDataTemplateUtil.fieldInfo(new ArrayTest(), "stringMapArray");
    @SuppressWarnings("unchecked") Class<StringMapArray> templateClass = (Class<StringMapArray>) fieldInfo.getFieldClass();
    ArrayDataSchema schema = (ArrayDataSchema) fieldInfo.getField().getType();
    List<StringMap> input = new ArrayList<>();
    for (int i = 0; i < 5; ++i) {
        input.add(new StringMap());
        input.get(i).put("input key " + i, "value " + i);
    }
    List<StringMap> adds = new ArrayList<>();
    for (int i = 0; i < 5; ++i) {
        adds.add(new StringMap());
        input.get(i).put("add key " + i, "value " + i);
    }
    TestArrayTemplate.testArray(templateClass, schema, input, adds);
}
Also used : ArrayDataSchema(com.linkedin.data.schema.ArrayDataSchema) TestDataTemplateUtil(com.linkedin.data.template.TestDataTemplateUtil) StringMap(com.linkedin.data.template.StringMap) StringMapArray(com.linkedin.data.template.StringMapArray) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test)

Example 55 with ArrayDataSchema

use of com.linkedin.data.schema.ArrayDataSchema in project rest.li by linkedin.

the class TestArray method testStringArrayArray.

@Test
public void testStringArrayArray() {
    TestDataTemplateUtil.FieldInfo fieldInfo = TestDataTemplateUtil.fieldInfo(new ArrayTest(), "stringArrayArray");
    @SuppressWarnings("unchecked") Class<StringArrayArray> templateClass = (Class<StringArrayArray>) fieldInfo.getFieldClass();
    ArrayDataSchema schema = (ArrayDataSchema) fieldInfo.getField().getType();
    List<StringArray> input = new ArrayList<>();
    for (int i = 0; i < 5; ++i) {
        input.add(new StringArray("input" + i));
    }
    List<StringArray> adds = new ArrayList<>();
    for (int i = 0; i < 5; ++i) {
        adds.add(new StringArray("add" + i));
    }
    TestArrayTemplate.testArray(templateClass, schema, input, adds);
}
Also used : ArrayDataSchema(com.linkedin.data.schema.ArrayDataSchema) TestDataTemplateUtil(com.linkedin.data.template.TestDataTemplateUtil) StringArray(com.linkedin.data.template.StringArray) StringArrayArray(com.linkedin.data.template.StringArrayArray) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test)

Aggregations

ArrayDataSchema (com.linkedin.data.schema.ArrayDataSchema)57 RecordDataSchema (com.linkedin.data.schema.RecordDataSchema)27 DataSchema (com.linkedin.data.schema.DataSchema)24 Test (org.testng.annotations.Test)22 MapDataSchema (com.linkedin.data.schema.MapDataSchema)21 DataList (com.linkedin.data.DataList)20 TyperefDataSchema (com.linkedin.data.schema.TyperefDataSchema)20 UnionDataSchema (com.linkedin.data.schema.UnionDataSchema)19 DataMap (com.linkedin.data.DataMap)17 EnumDataSchema (com.linkedin.data.schema.EnumDataSchema)11 NamedDataSchema (com.linkedin.data.schema.NamedDataSchema)8 PrimitiveDataSchema (com.linkedin.data.schema.PrimitiveDataSchema)8 ArrayList (java.util.ArrayList)8 FixedDataSchema (com.linkedin.data.schema.FixedDataSchema)7 ByteString (com.linkedin.data.ByteString)5 Name (com.linkedin.data.schema.Name)4 TestDataTemplateUtil (com.linkedin.data.template.TestDataTemplateUtil)4 ParameterSchema (com.linkedin.restli.restspec.ParameterSchema)4 DataTemplate (com.linkedin.data.template.DataTemplate)3 TemplateRuntimeException (com.linkedin.data.template.TemplateRuntimeException)3