Search in sources :

Example 46 with DataList

use of com.linkedin.data.DataList in project rest.li by linkedin.

the class TestCheckedUtil method testAddCycleWithAssertChecking.

@Test(expectedExceptions = AssertionError.class)
public void testAddCycleWithAssertChecking() {
    final DataList list = new DataList();
    CheckedUtil.addWithoutChecking(list, list);
}
Also used : DataList(com.linkedin.data.DataList) Test(org.testng.annotations.Test)

Example 47 with DataList

use of com.linkedin.data.DataList in project rest.li by linkedin.

the class TestCheckedUtil method testSetCycleWithAssertChecking.

@Test(expectedExceptions = AssertionError.class)
public void testSetCycleWithAssertChecking() {
    final DataList list = new DataList();
    CheckedUtil.addWithoutChecking(list, "not cycle");
    CheckedUtil.setWithoutChecking(list, 0, list);
}
Also used : DataList(com.linkedin.data.DataList) Test(org.testng.annotations.Test)

Example 48 with DataList

use of com.linkedin.data.DataList in project rest.li by linkedin.

the class TestValidation method testBooleanStringToPrimitiveFixupValidation.

@Test
public void testBooleanStringToPrimitiveFixupValidation() throws IOException {
    String schemaText = "{ \"type\" : \"record\", \"name\" : \"foo\", \"fields\" : " + "[ { \"name\" : \"bar\", \"type\" : \"boolean\" } ] }";
    Object[][] input = { { new String("true"), Boolean.TRUE }, { new String("false"), Boolean.FALSE } };
    Object[] badObjects = { new Integer(1), new Long(1), new Float(1), new Double(1), new String("abc"), new DataMap(), new DataList() };
    testStringToPrimitiveCoercionValidation(schemaText, "bar", input, badObjects);
}
Also used : DataList(com.linkedin.data.DataList) TestUtil.dataMapFromString(com.linkedin.data.TestUtil.dataMapFromString) ByteString(com.linkedin.data.ByteString) TestUtil.dataSchemaFromString(com.linkedin.data.TestUtil.dataSchemaFromString) DataMap(com.linkedin.data.DataMap) Test(org.testng.annotations.Test)

Example 49 with DataList

use of com.linkedin.data.DataList in project rest.li by linkedin.

the class TestArrayTemplate method testLegacyConstructor.

@Test
public void testLegacyConstructor() {
    Map<String, Class<?>> primitiveStringToClassMap = asMap("int", Integer.class, "long", Long.class, "float", Float.class, "double", Double.class, "boolean", Boolean.class, "string", String.class);
    for (Map.Entry<String, Class<?>> e : primitiveStringToClassMap.entrySet()) {
        ArrayDataSchema schema = (ArrayDataSchema) DataTemplateUtil.parseSchema("{ \"type\" : \"array\", \"items\" : \"" + e.getKey() + "\" }");
        @SuppressWarnings("unchecked") PrimitiveLegacyArray<?> array = new PrimitiveLegacyArray<Object>(new DataList(), schema, (Class) e.getValue());
    }
    EnumLegacyArray enumArray = new EnumLegacyArray(new DataList());
}
Also used : ArrayDataSchema(com.linkedin.data.schema.ArrayDataSchema) DataList(com.linkedin.data.DataList) ByteString(com.linkedin.data.ByteString) DataMap(com.linkedin.data.DataMap) Map(java.util.Map) TestUtil.asMap(com.linkedin.data.TestUtil.asMap) Test(org.testng.annotations.Test)

Example 50 with DataList

use of com.linkedin.data.DataList in project rest.li by linkedin.

the class TestArrayTemplate method testEnumArray.

@Test
public void testEnumArray() {
    // must be unique
    List<Fruits> input = Arrays.asList(Fruits.APPLE, Fruits.ORANGE, Fruits.BANANA);
    List<Fruits> adds = Arrays.asList(Fruits.GRAPES, Fruits.PINEAPPLE);
    List<Object> badInput = asList(true, 1, 2L, 3.0f, 4.0, "orange", ByteString.empty(), new StringMap(), new StringArray(), null);
    List<Object> badOutput = asList(true, 1, 2L, 3.0f, 4.0, "orange", ByteString.empty(), new DataMap(), new DataList());
    testArray(EnumArrayTemplate.class, TestArrayTemplate.EnumArrayTemplate.SCHEMA, input, adds);
    testArrayBadInput(EnumArrayTemplate.class, TestArrayTemplate.EnumArrayTemplate.SCHEMA, input, badInput, badOutput);
}
Also used : DataList(com.linkedin.data.DataList) DataMap(com.linkedin.data.DataMap) Test(org.testng.annotations.Test)

Aggregations

DataList (com.linkedin.data.DataList)160 DataMap (com.linkedin.data.DataMap)126 Test (org.testng.annotations.Test)102 ByteString (com.linkedin.data.ByteString)64 TestUtil.dataMapFromString (com.linkedin.data.TestUtil.dataMapFromString)34 TestUtil.dataSchemaFromString (com.linkedin.data.TestUtil.dataSchemaFromString)33 ArrayList (java.util.ArrayList)22 ArrayDataSchema (com.linkedin.data.schema.ArrayDataSchema)17 DataSchema (com.linkedin.data.schema.DataSchema)10 RecordDataSchema (com.linkedin.data.schema.RecordDataSchema)10 HashMap (java.util.HashMap)10 MapDataSchema (com.linkedin.data.schema.MapDataSchema)9 RecordTemplate (com.linkedin.data.template.RecordTemplate)9 Map (java.util.Map)8 DataProvider (org.testng.annotations.DataProvider)8 List (java.util.List)7 PathSpec (com.linkedin.data.schema.PathSpec)6 PatchTree (com.linkedin.data.transform.patch.request.PatchTree)5 DataComplex (com.linkedin.data.DataComplex)4 CustomPoint (com.linkedin.data.template.TestCustom.CustomPoint)4