use of com.linkedin.data.DataList in project rest.li by linkedin.
the class TestValidation method testIntegerNormalCoercionValidation.
@Test
public void testIntegerNormalCoercionValidation() throws IOException {
String schemaText = "{ \"type\" : \"record\", \"name\" : \"foo\", \"fields\" : " + "[ { \"name\" : \"bar\", \"type\" : \"int\" } ] }";
Object[][] input = { { new Integer(1), new Integer(1) }, { new Integer(-1), new Integer(-1) }, { Integer.MAX_VALUE, Integer.MAX_VALUE }, { Integer.MAX_VALUE - 1, Integer.MAX_VALUE - 1 }, { new Long(1), new Integer(1) }, { new Float(1), new Integer(1) }, { new Double(1), new Integer(1) } };
Object[] badObjects = { new Boolean(true), new String("abc"), ByteString.copyAvroString("bytes", false), new DataMap(), new DataList() };
testNormalCoercionValidation(schemaText, "bar", input, badObjects);
}
use of com.linkedin.data.DataList in project rest.li by linkedin.
the class TestValidation method testLongNormalCoercionValidation.
@Test
public void testLongNormalCoercionValidation() throws IOException {
String schemaText = "{ \"type\" : \"record\", \"name\" : \"foo\", \"fields\" : " + "[ { \"name\" : \"bar\", \"type\" : \"long\" } ] }";
Object[][] inputs = { { new Long(1), new Long(1) }, { new Long(-1), new Long(-1) }, { new Integer(1), new Long(1) }, { new Float(1), new Long(1) }, { new Double(1), new Long(1) } };
Object[] badObjects = { new Boolean(true), new String("abc"), ByteString.copyAvroString("bytes", false), new DataMap(), new DataList() };
testNormalCoercionValidation(schemaText, "bar", inputs, badObjects);
}
use of com.linkedin.data.DataList in project rest.li by linkedin.
the class TestValidation method testBytesValidation.
@Test
public void testBytesValidation() throws IOException {
String schemaText = "{ \"type\" : \"record\", \"name\" : \"foo\", \"fields\" : " + "[ { \"name\" : \"bar\", \"type\" : \"bytes\" } ] }";
Object[] goodObjects = { "abc", ByteString.copyAvroString("bytes", false), ByteString.empty() };
Object[] badObjects = { new Boolean(true), new Integer(1), new Long(1), new Float(1), new Double(1), new DataMap(), new DataList(), new String("Ā"), new String("abĀc"), new String("abĀcȀ") };
testCoercionValidation(schemaText, "bar", goodObjects, badObjects, noCoercionValidationOption());
Object[][] inputs = { { ByteString.copyAvroString("abc", false), ByteString.copyAvroString("abc", false) }, { "abc", ByteString.copyAvroString("abc", false) } };
testNormalCoercionValidation(schemaText, "bar", inputs, badObjects);
testStringToPrimitiveCoercionValidation(schemaText, "bar", inputs, badObjects);
}
use of com.linkedin.data.DataList in project rest.li by linkedin.
the class TestValidation method testDoubleNoCoercionValidation.
@Test
public void testDoubleNoCoercionValidation() throws IOException {
String schemaText = "{ \"type\" : \"record\", \"name\" : \"foo\", \"fields\" : " + "[ { \"name\" : \"bar\", \"type\" : \"double\" } ] }";
Object[] goodObjects = { new Double(1), new Double(-1) };
Object[] badObjects = { new Boolean(true), new Integer(1), new Long(1), new Float(1), new String("abc"), ByteString.copyAvroString("bytes", false), new DataMap(), new DataList() };
testCoercionValidation(schemaText, "bar", goodObjects, badObjects, noCoercionValidationOption());
}
use of com.linkedin.data.DataList in project rest.li by linkedin.
the class TestValidation method testIntegerNoCoercionValidation.
@Test
public void testIntegerNoCoercionValidation() throws IOException {
String schemaText = "{ \"type\" : \"record\", \"name\" : \"foo\", \"fields\" : " + "[ { \"name\" : \"bar\", \"type\" : \"int\" } ] }";
Object[] goodObjects = { new Integer(1), new Integer(-1), Integer.MAX_VALUE, Integer.MAX_VALUE - 1 };
Object[] badObjects = { new Boolean(true), new Long(1), new Float(1), new Double(1), new String("abc"), ByteString.copyAvroString("bytes", false), new DataMap(), new DataList() };
testCoercionValidation(schemaText, "bar", goodObjects, badObjects, noCoercionValidationOption());
}
Aggregations