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);
}
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);
}
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);
}
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());
}
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);
}
Aggregations