use of com.linkedin.data.template.IntegerArray in project rest.li by linkedin.
the class TestRecord method testRecordTest.
@Test
public void testRecordTest() throws IOException {
Object[][] inputs = { { "intField", 8 }, { "intOptionalField", 9 }, { "intDefaultField", 10 }, { "intDefaultOptionalField", 11 }, { "longField", 12L }, { "floatField", 13.0f }, { "doubleField", 14.0 }, { "booleanField", true }, { "stringField", "abc" }, { "bytesField", ByteString.copyAvroString("abcdef", true) }, { "enumField", EnumFruits.BANANA }, { "fixedField", new FixedMD5("0123456789abcdef") }, { "recordField", new RecordBar().setLocation("far") }, { "arrayField", new IntegerArray(Arrays.asList(1, 2, 3, 4, 5)) }, { "mapField", new StringMap(TestUtil.asMap("k1", "v1", "k2", "v2", "k3", "v3")) }, { "unionField", new RecordTest.UnionField(TestUtil.dataMapFromString("{ \"int\" : 3 }")) } };
RecordTest record = new RecordTest();
testRecord(record.getClass());
for (Object[] row : inputs) {
String fieldName = (String) row[0];
Object value = row[1];
testField(record, fieldName, value);
}
}
use of com.linkedin.data.template.IntegerArray 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);
}
use of com.linkedin.data.template.IntegerArray in project rest.li by linkedin.
the class RecordGeneratorTest method testWithComplexTypesDefaults.
@Test
public void testWithComplexTypesDefaults() {
WithComplexTypeDefaults withDefaults = new WithComplexTypeDefaults();
Simple simple = new Simple();
simple.setMessage("defaults!");
assertEquals(withDefaults.getRecord(), simple);
assertEquals(withDefaults.getEnum(), Fruits.APPLE);
assertEquals(withDefaults.getUnion(), WithComplexTypeDefaults.Union.create(1));
IntegerArray intArray = new IntegerArray(Collections.singletonList(1));
assertEquals(withDefaults.getArray(), intArray);
IntegerMap intMap = new IntegerMap();
intMap.put("a", 1);
assertEquals(withDefaults.getMap(), intMap);
assertEquals(withDefaults.getCustom(), new CustomInt(1));
}
use of com.linkedin.data.template.IntegerArray in project rest.li by linkedin.
the class RecordGeneratorTest method testWithOptionalComplexTypesDefaults.
@Test
public void testWithOptionalComplexTypesDefaults() {
WithOptionalComplexTypeDefaults withDefaults = new WithOptionalComplexTypeDefaults();
Simple simple = new Simple();
simple.setMessage("defaults!");
assertEquals(withDefaults.getRecord(), simple);
assertEquals(withDefaults.getEnum(), Fruits.APPLE);
assertEquals(withDefaults.getUnion(), WithComplexTypeDefaults.Union.create(1));
IntegerArray intArray = new IntegerArray(Collections.singletonList(1));
assertEquals(withDefaults.getArray(), intArray);
IntegerMap intMap = new IntegerMap();
intMap.put("a", 1);
assertEquals(withDefaults.getMap(), intMap);
assertEquals(withDefaults.getCustom(), new CustomInt(1));
}
use of com.linkedin.data.template.IntegerArray in project rest.li by linkedin.
the class TestTypeRefRecordTemplate method testArraySchema.
@Test
public void testArraySchema() {
TyperefTest record = new TyperefTest();
RecordDataSchema recordDataSchema = record.schema();
record.setDoubleRefArray(new DoubleArray());
DoubleArray doubleArray = record.getDoubleRefArray();
assertEquals(doubleArray.schema(), DataTemplateUtil.getSchema(DoubleArray.class));
assertNotEquals(recordDataSchema.getField("doubleRefArray").getType(), doubleArray.schema());
record.setIntArray(new IntegerArray());
IntegerArray intArray = record.getIntArray();
assertEquals(intArray.schema(), DataTemplateUtil.getSchema(IntegerArray.class));
assertNotEquals(recordDataSchema.getField("intArray").getType(), intArray.schema());
record.setIntRefArray(intArray);
intArray = record.getIntRefArray();
assertEquals(intArray.schema(), DataTemplateUtil.getSchema(IntegerArray.class));
assertNotEquals(recordDataSchema.getField("intRefArray").getType(), intArray.schema());
assertNotEquals(recordDataSchema.getField("intArray").getType(), recordDataSchema.getField("intRefArray").getType());
}
Aggregations