// Path: raml-converter/src/main/java/raml/tools/html/Raml2HtmlConverter.java
// public class Raml2HtmlConverter {
// 
//   String ramlBasePath = null;
//   String mainTemplate = null;
// 
//   public void convert(String ramlFilePath, String outputFilePath) {
//     try {
//       convert(new FileInputStream(new File(ramlFilePath)), new FileOutputStream(new File(outputFilePath)));
//     } catch (FileNotFoundException e) {
//       throw new RuntimeException(e);
//     }
//   }
// 
//   public <T extends OutputStream> T convert(InputStream ramlFilePath, T outputStream) {
//     try {
//       String ramlHtml = new Raml2HtmlRenderer(new RamlContext(new RamlParser().parseRaml(ramlBasePath, ramlFilePath)), HandlebarsFactory.defaultHandlebars())
//         .renderFull(mainTemplate);
//       outputStream.write(ramlHtml.getBytes());
//       return outputStream;
//     } catch (IOException e) {
//       throw new RuntimeException(e);
//     } finally {
//       if (outputStream != null) {
//         try {
//           outputStream.flush();
//           outputStream.close();
//         } catch (IOException e) {
//           throw new RuntimeException(e);
//         }
//       }
//     }
//   }
// 
//   public Raml2HtmlConverter withMainTemplate(String mainTemplate) {
//     this.mainTemplate = mainTemplate;
//     return this;
//   }
// 
//   public Raml2HtmlConverter withRamlBasePath(String ramlBasePath) {
//     this.ramlBasePath = ramlBasePath;
//     return this;
//   }
// 
// }
// 
// Path: raml-converter/src/main/java/raml/tools/util/IoUtil.java
// public class IoUtil {
//   public static String contentFromFile(String fileName) {
//     return convertStreamToString(IoUtil.class.getClassLoader().getResourceAsStream(fileName));
//   }
// 
//   public static String convertStreamToString(java.io.InputStream is) {
//     java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
//     return s.hasNext() ? s.next() : "";
//   }
// 
//   public static void writeToFile(String content, String outputFilePath) {
//     FileOutputStream fileOutput = null;
//     try {
//       fileOutput = new FileOutputStream(new File(outputFilePath));
//       fileOutput.write(content.getBytes("UTF-8"));
//     } catch (FileNotFoundException | UnsupportedEncodingException e) {
//       throw new RuntimeException(e);
//     } catch (IOException e) {
//       throw new RuntimeException();
//     } finally {
//       if (fileOutput != null) {
//         try {
//           fileOutput.flush();
//           fileOutput.close();
//         } catch (IOException e) {
//           throw new RuntimeException(e);
//         }
//       }
//     }
//   }
// }


import jodd.jerry.Jerry;
import org.junit.Test;
import raml.tools.html.Raml2HtmlConverter;
import raml.tools.util.IoUtil;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import static jodd.jerry.Jerry.jerry;
import static org.assertj.core.api.Assertions.assertThat;
package raml.tools;





public class Raml2HtmlConverterTest {
  @Test
  public void shouldProcessExampleWithOutErrors() {
    String generatedHtml = generateHtml("example.raml");

    assertThat(generatedHtml).isNotNull();
    assertThat(generatedHtml).startsWith("<!DOCTYPE HTML>");
  }

  @Test
  public void generatedHtmlContainsBaseUri() {
    String generatedHtml = generateHtml("music.raml");

    assertThat(generatedHtml).isNotNull();
    assertThat(generatedHtml).contains("http://example.api.com/{version}");
  }

  @Test
  public void requiredAttributesAreParsedCorrectly() {
    String generatedHtml = generateHtml("json_schema_required_properties.raml");
    Jerry doc = jerry(generatedHtml);

    String topLevelRequiredText = doc.$("div[data-property=\"toplevel\"]").$(".property-required .required-text").text();
    assertThat(topLevelRequiredText).isEqualTo("required");

    String draft3RequiredText = doc.$("div[data-property=\"draft3-required\"]").$(".property-required .required-text").text();
    assertThat(draft3RequiredText).isEqualTo("required");
  }

  String generateHtml(String ramlFile) {
    InputStream ramlInput = getClass().getClassLoader().getResourceAsStream(ramlFile);
    String ramlHtml = new Raml2HtmlConverter().convert(ramlInput, new ByteArrayOutputStream()).toString();
    IoUtil.writeToFile(ramlHtml, "target/test.html");
// Path: raml-converter/src/main/java/raml/tools/html/Raml2HtmlConverter.java
// public class Raml2HtmlConverter {
// 
//   String ramlBasePath = null;
//   String mainTemplate = null;
// 
//   public void convert(String ramlFilePath, String outputFilePath) {
//     try {
//       convert(new FileInputStream(new File(ramlFilePath)), new FileOutputStream(new File(outputFilePath)));
//     } catch (FileNotFoundException e) {
//       throw new RuntimeException(e);
//     }
//   }
// 
//   public <T extends OutputStream> T convert(InputStream ramlFilePath, T outputStream) {
//     try {
//       String ramlHtml = new Raml2HtmlRenderer(new RamlContext(new RamlParser().parseRaml(ramlBasePath, ramlFilePath)), HandlebarsFactory.defaultHandlebars())
//         .renderFull(mainTemplate);
//       outputStream.write(ramlHtml.getBytes());
//       return outputStream;
//     } catch (IOException e) {
//       throw new RuntimeException(e);
//     } finally {
//       if (outputStream != null) {
//         try {
//           outputStream.flush();
//           outputStream.close();
//         } catch (IOException e) {
//           throw new RuntimeException(e);
//         }
//       }
//     }
//   }
// 
//   public Raml2HtmlConverter withMainTemplate(String mainTemplate) {
//     this.mainTemplate = mainTemplate;
//     return this;
//   }
// 
//   public Raml2HtmlConverter withRamlBasePath(String ramlBasePath) {
//     this.ramlBasePath = ramlBasePath;
//     return this;
//   }
// 
// }
// 
// Path: raml-converter/src/main/java/raml/tools/util/IoUtil.java
// public class IoUtil {
//   public static String contentFromFile(String fileName) {
//     return convertStreamToString(IoUtil.class.getClassLoader().getResourceAsStream(fileName));
//   }
// 
//   public static String convertStreamToString(java.io.InputStream is) {
//     java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
//     return s.hasNext() ? s.next() : "";
//   }
// 
//   public static void writeToFile(String content, String outputFilePath) {
//     FileOutputStream fileOutput = null;
//     try {
//       fileOutput = new FileOutputStream(new File(outputFilePath));
//       fileOutput.write(content.getBytes("UTF-8"));
//     } catch (FileNotFoundException | UnsupportedEncodingException e) {
//       throw new RuntimeException(e);
//     } catch (IOException e) {
//       throw new RuntimeException();
//     } finally {
//       if (fileOutput != null) {
//         try {
//           fileOutput.flush();
//           fileOutput.close();
//         } catch (IOException e) {
//           throw new RuntimeException(e);
//         }
//       }
//     }
//   }
// }


// Path: raml-converter/src/test/java/raml/tools/Raml2HtmlConverterTest.java
import jodd.jerry.Jerry;
import org.junit.Test;
import raml.tools.html.Raml2HtmlConverter;
import raml.tools.util.IoUtil;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import static jodd.jerry.Jerry.jerry;
import static org.assertj.core.api.Assertions.assertThat;

package raml.tools;





public class Raml2HtmlConverterTest {
  @Test
  public void shouldProcessExampleWithOutErrors() {
    String generatedHtml = generateHtml("example.raml");

    assertThat(generatedHtml).isNotNull();
    assertThat(generatedHtml).startsWith("<!DOCTYPE HTML>");
  }

  @Test
  public void generatedHtmlContainsBaseUri() {
    String generatedHtml = generateHtml("music.raml");

    assertThat(generatedHtml).isNotNull();
    assertThat(generatedHtml).contains("http://example.api.com/{version}");
  }

  @Test
  public void requiredAttributesAreParsedCorrectly() {
    String generatedHtml = generateHtml("json_schema_required_properties.raml");
    Jerry doc = jerry(generatedHtml);

    String topLevelRequiredText = doc.$("div[data-property=\"toplevel\"]").$(".property-required .required-text").text();
    assertThat(topLevelRequiredText).isEqualTo("required");

    String draft3RequiredText = doc.$("div[data-property=\"draft3-required\"]").$(".property-required .required-text").text();
    assertThat(draft3RequiredText).isEqualTo("required");
  }

  String generateHtml(String ramlFile) {
    InputStream ramlInput = getClass().getClassLoader().getResourceAsStream(ramlFile);
    String ramlHtml = new Raml2HtmlConverter().convert(ramlInput, new ByteArrayOutputStream()).toString();
    IoUtil.writeToFile(ramlHtml, "target/test.html");
    return ramlHtml;