public static String schemaToPdl(DataSchema schema, EncodingStyle encodingStyle)
  {
    StringWriter writer = new StringWriter();

    SchemaToPdlEncoder encoder = new SchemaToPdlEncoder(writer);
    encoder.setEncodingStyle(encodingStyle);

    try
    {
      encoder.encode(schema);
    }
    catch (IOException e)
    {
      throw new IllegalStateException(e);
    }

    return writer.toString();
  }
@Test
  public void testNamespaceAndCommentsOnNestedSchemas() throws IOException
  {
    String inputSchema = String.join("\n",
        "namespace com.linkedin.test.RecordDataSchema",
        "/**",
        "* some schema doc string",
        "*/",
        "record A {",
        "",
        "  b:",
        "  {",
        "    namespace com.linkedin.test.RecordDataSchema.A",
        "    /**",
        "    * some inner schema doc string",
        "    */",
        "    record B {",
        "    b1: string",
        "",
        "    }",
        "  }",
        "}");

    DataSchema schema = TestUtil.dataSchemaFromPdlString(inputSchema);

    String indentedSchema = SchemaToPdlEncoder.schemaToPdl(schema, SchemaToPdlEncoder.EncodingStyle.INDENTED);

    assertEquals(String.join("\n",
        "namespace com.linkedin.test.RecordDataSchema",
        "",
        "/**",
        " * some schema doc string",
        " */",
        "record A {",
        "",
        "  b: ",
        "    {",
        "      namespace com.linkedin.test.RecordDataSchema.A",
        "      /**",
        "       * some inner schema doc string",
        "       */",
        "      record B {",
        "        b1: string",
        "      }",
        "    }",
        "}"), indentedSchema);
  }