Search in sources :

Example 1 with SchemaToPdlEncoder

use of com.linkedin.data.schema.SchemaToPdlEncoder in project rest.li by linkedin.

the class PdlEncoderTest method assertRoundTrip.

private void assertRoundTrip(String relativeName) throws IOException {
    String fullName = "com.linkedin.pegasus.generator.test.idl." + relativeName;
    String path = "/" + fullName.replace('.', '/') + ".pdl";
    NamedDataSchema parsed = parseSchema(fullName);
    String original = loadSchema(path);
    assertNotNull(parsed, "Failed to resolve: " + fullName + "resolver path: " + pegasusSrcDir.getAbsolutePath());
    StringWriter writer = new StringWriter();
    SchemaToPdlEncoder encoder = new SchemaToPdlEncoder(writer);
    encoder.setTypeReferenceFormat(SchemaToPdlEncoder.TypeReferenceFormat.PRESERVE);
    encoder.encode(parsed);
    String encoded = writer.toString();
    assertEqualsIgnoringSpacing(original, encoded);
}
Also used : NamedDataSchema(com.linkedin.data.schema.NamedDataSchema) SchemaToPdlEncoder(com.linkedin.data.schema.SchemaToPdlEncoder) StringWriter(java.io.StringWriter)

Aggregations

NamedDataSchema (com.linkedin.data.schema.NamedDataSchema)1 SchemaToPdlEncoder (com.linkedin.data.schema.SchemaToPdlEncoder)1 StringWriter (java.io.StringWriter)1