class HtmlGenerator {

    public void generate() throws IOException {
        ApiModel apiModel = new ApiModelBuilder().buildApiModel(config.getSourceFile());
        TemplateEngine engine = new TemplateEngine();
        engine.setTemplateDir(config.getTemplateDir());
        String result = engine.renderTemplate("api", apiModel);

        File targetDir = new File(config.getTargetDir());
        createDirectoryIfNeeded(targetDir);
        Files.write(targetDir.toPath()
            .resolve("index.html"), result.getBytes(StandardCharsets.UTF_8));

        writeWebResources(targetDir);
    }

}

class HtmlGeneratorTest {

    @Test
    public void shouldRenderApi() throws IOException {

        HtmlConfiguration config = new HtmlConfiguration();
        config.setSourceFile("src/test/resources/raml/simpleobject.raml");
        config.setTargetDir("target/html/simpleobject");
        HtmlGenerator generator = new HtmlGenerator(config);
        generator.generate();

        verifyTargetDir(config);
    }

}