use of com.linkedin.data.schema.resolver.DefaultDataSchemaResolver in project rest.li by linkedin.
the class TestUtil method pdlSchemaParserFromString.
public static PdlSchemaParser pdlSchemaParserFromString(String s) throws UnsupportedEncodingException {
PdlSchemaParser parser = new PdlSchemaParser(new DefaultDataSchemaResolver());
parser.parse(inputStreamFromString(s));
return parser;
}
use of com.linkedin.data.schema.resolver.DefaultDataSchemaResolver in project rest.li by linkedin.
the class TestPdlSchemaParser method testEnumParserLocations.
@Test
public void testEnumParserLocations() {
PdlSchemaParser parser = new PdlSchemaParser(new DefaultDataSchemaResolver(), true);
parser.parse(getClass().getResourceAsStream("TestEnumForParserContextLocations.pdl"));
List<DataSchema> topLevelSchemas = parser.topLevelDataSchemas();
Assert.assertEquals(topLevelSchemas.size(), 1, "Expected 1 top-level schema to be parsed.");
EnumDataSchema topSchema = (EnumDataSchema) topLevelSchemas.get(0);
Map<Object, PdlSchemaParser.ParseLocation> locations = parser.getParseLocations();
checkParseLocationForEnum(locations, topSchema);
}
use of com.linkedin.data.schema.resolver.DefaultDataSchemaResolver in project rest.li by linkedin.
the class TestPdlSchemaParser method testTyperefParserLocations.
@Test
public void testTyperefParserLocations() {
PdlSchemaParser parser = new PdlSchemaParser(new DefaultDataSchemaResolver(), true);
parser.parse(getClass().getResourceAsStream("TestTyperefForParserContextLocations.pdl"));
List<DataSchema> topLevelSchemas = parser.topLevelDataSchemas();
Assert.assertEquals(topLevelSchemas.size(), 1, "Expected 1 top-level schema to be parsed.");
TyperefDataSchema topSchema = (TyperefDataSchema) topLevelSchemas.get(0);
Map<Object, PdlSchemaParser.ParseLocation> locations = parser.getParseLocations();
checkParseLocationForTyperef(locations, topSchema);
}
use of com.linkedin.data.schema.resolver.DefaultDataSchemaResolver in project rest.li by linkedin.
the class TestPdlSchemaParser method testRecordParserLocations.
@Test
public void testRecordParserLocations() {
PdlSchemaParser parser = new PdlSchemaParser(new DefaultDataSchemaResolver(), true);
parser.parse(getClass().getResourceAsStream("TestRecordForParserContextLocations.pdl"));
List<DataSchema> topLevelSchemas = parser.topLevelDataSchemas();
Assert.assertEquals(topLevelSchemas.size(), 1, "Expected 1 top-level schema to be parsed.");
RecordDataSchema mainRecordSchema = (RecordDataSchema) topLevelSchemas.get(0);
Map<Object, PdlSchemaParser.ParseLocation> locations = parser.getParseLocations();
checkParseLocationForRecord(locations, mainRecordSchema);
// Checks for namespace locations.
// Top-level namespace
PdlSchemaParser.ParseLocation topNamespaceLoc = locations.get(mainRecordSchema.getNamespace());
assertLocation(topNamespaceLoc, 1, 1, 1, 42, "namespace: " + mainRecordSchema.getNamespace());
// Inline namespace
String inlineNamespace = ((RecordDataSchema) mainRecordSchema.getField("inlineNamespacedField").getType()).getNamespace();
PdlSchemaParser.ParseLocation inlineNamespaceLoc = locations.get(inlineNamespace);
assertLocation(inlineNamespaceLoc, 48, 5, 48, 38, "namespace: " + inlineNamespace);
}
use of com.linkedin.data.schema.resolver.DefaultDataSchemaResolver in project rest.li by linkedin.
the class TestPdlSchemaParser method parsePdlSchema.
/**
* Parses a .pdl file found at a given filename in the resource directory for this class.
* @param filename file name pointing to a .pdl file
* @return parsed data schema
*/
private DataSchema parsePdlSchema(String filename) {
PdlSchemaParser parser = new PdlSchemaParser(new DefaultDataSchemaResolver());
parser.parse(getClass().getResourceAsStream(filename));
List<DataSchema> topLevelSchemas = parser.topLevelDataSchemas();
Assert.assertEquals(topLevelSchemas.size(), 1, "Expected 1 top-level schema to be parsed.");
return topLevelSchemas.get(0);
}
Aggregations