use of com.linkedin.data.schema.RecordDataSchema in project rest.li by linkedin.
the class TestSchemaSampleDataGenerator method testInvalidRecursivelyReferencedSchema.
@Test
public void testInvalidRecursivelyReferencedSchema() {
try {
// this schema is invalid because it contains a non-optional reference to itself
final RecordDataSchema schema = (RecordDataSchema) DataTemplateUtil.getSchema(InvalidSelfReference.class);
SchemaSampleDataGenerator.buildRecordData(schema, _spec);
Assert.fail("IllegalArgumentException should be thrown because schema contains schema that references itself and is not optional, or in a list, map or union.");
} catch (IllegalArgumentException e) {
}
}
use of com.linkedin.data.schema.RecordDataSchema in project rest.li by linkedin.
the class TestCustomAnyRecord method testCustomAnyRecordSchema.
@Test
public void testCustomAnyRecordSchema() {
RecordDataSchema schemaFromInstance = (new AnyRecord()).schema();
DataSchema schemaFromClass = DataTemplateUtil.getSchema(AnyRecord.class);
assertSame(schemaFromClass, schemaFromInstance);
CustomAnyRecord custom = new CustomAnyRecord();
RecordDataSchema customSchemaFromInstance = custom.schema();
DataSchema customSchemaFromClass = DataTemplateUtil.getSchema(CustomAnyRecord.class);
assertSame(customSchemaFromClass, customSchemaFromInstance);
assertEquals(customSchemaFromClass, schemaFromClass);
}
use of com.linkedin.data.schema.RecordDataSchema 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());
}
use of com.linkedin.data.schema.RecordDataSchema 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());
}
use of com.linkedin.data.schema.RecordDataSchema in project rest.li by linkedin.
the class TestLongStringLiteral method testSchema.
@Test
public void testSchema() {
DataSchema schema = DataTemplateUtil.getSchema(LongStringLiteral.class);
String schemaText = schema.toString();
assertTrue(schemaText.length() > 65536);
RecordDataSchema recordDataSchema = (RecordDataSchema) schema;
RecordDataSchema.Field field = recordDataSchema.getField("text");
DataList defaultValue = (DataList) field.getDefault();
assertEquals(defaultValue.size(), 400);
for (Object s : defaultValue) {
assertEquals(s, LOREM);
}
}
Aggregations