@Test public void testLinkToStaticMethod() throws Exception { assertEquals( "`link:method[TheClass.m]`", assertDoc("io.vertx.test.linktostaticmethod")); }
@Test public void testDocFile() throws Exception { assertEquals("the_content", assertDocFile("docs/simple.adoc")); }
private Map<String, String> failDoc(String pkg) throws Exception { Compiler<TestGenProcessor> compiler = buildCompiler(new TestGenProcessor(), pkg); compiler.failCompile(); return compiler.processor.failures; }
private String assertDocFile(String relativeName) throws Exception { File src = docFile(relativeName); Compiler<TestGenProcessor> compiler = buildCompiler(new TestGenProcessor(), "io.vertx.test.file"); compiler.setOption("docgen.source", src.getAbsolutePath()); compiler.assertCompile(); return compiler.processor.getDoc(src.getName()); }
String doc = assertDoc("io.vertx.test.source"); doc = assertDocWithCustomGenerator("io.vertx.test.source"); assertTrue("#1", doc.contains("# 1\n" + "[source, custom]\n" +
@Test public void testLinkUnresolvedTypeWithSignature() throws Exception { failDoc("io.vertx.test.linkunresolvedtypewithsignature"); }
@Test public void testDocFileWithLinkToUnresolvableType() throws Exception { Compiler<TestGenProcessor> compiler = buildCompiler(new TestGenProcessor(), "io.vertx.test.file"); compiler.setOption("docgen.source", docFile("docs/linktounresolvabletype.adoc").getAbsolutePath()); compiler.failCompile(); }
@Test public void testLinkToMethodWithUnresolvableType() throws Exception { assertTrue(failDoc("io.vertx.test.linktomethodwithunresolvabletype").containsKey("io.vertx.test.linktomethodwithunresolvabletype")); }
@Test public void testIncludeMethodFromAnnotatedMethod() throws Exception { assertEquals( "int a = 0;", assertDoc("io.vertx.test.includemethodfromannotatedmethod")); }
@Test public void testDocFileNotFound() throws Exception { Compiler<TestGenProcessor> compiler = buildCompiler(new TestGenProcessor(), "io.vertx.test.file"); compiler.setOption("docgen.source", new File(new File("."), "does_not_exists").getAbsolutePath()); compiler.failCompile(); }
@Test public void testIncludeCircular() throws Exception { assertTrue(failDoc("io.vertx.test.includecircular").containsKey("io.vertx.test.includecircular.sub1")); }
@Test public void testDocFileLink() throws Exception { assertEquals("<before>`link:type[TheClass]`<after>", assertDocFile("docs/link.adoc")); }
@Test public void testIncludeAnnotatedEnum() throws Exception { assertEquals( "before_include@Source\n" + "public enum TheExample {\n" + "\n" + " A,\n" + " B,\n" + " C\n" + "\n" + "}after_include", assertDoc("io.vertx.test.includeannotatedenum")); }
@Test public void testDocFileNotFile() throws Exception { Compiler<TestGenProcessor> compiler = buildCompiler(new TestGenProcessor(), "io.vertx.test.file"); compiler.setOption("docgen.source", new File(".").getAbsolutePath()); compiler.failCompile(); }
@Test public void testIncludeNonExisting() throws Exception { assertTrue(failDoc("io.vertx.test.includenonexisting").containsKey("io.vertx.test.includenonexisting")); }
@Test public void testDocFileLinkWithLabel() throws Exception { assertEquals("<before>`link:type[the label value]`<after>", assertDocFile("docs/linkwithlabel.adoc")); }
@Test public void testLinkToMethodWithSimpleTypeName() throws Exception { assertEquals( "`link:method[m1]`\n" + "`link:method[m2]`\n" + "`link:method[m3]`\n" + "`link:method[m4]`" + "", assertDoc("io.vertx.test.linktomethodwithsimpletypename")); }
@Test public void testLinkGenerationWithAnnotation() throws Exception { String pkg = "io.vertx.test.linktomethod"; Compiler<DocGenProcessor> compiler = BaseProcessorTest.buildCompiler(new DocGenProcessor(new JavaDocGenerator()), pkg); File dir = Files.createTempDirectory("docgen").toFile(); dir.deleteOnExit(); compiler.setOption("docgen.output", dir.getAbsolutePath()); compiler.assertCompile(); File file = new File(dir, pkg + ".adoc"); List<String> lines = Files.readAllLines(file.toPath()); for (String line : lines) { // The :: is used when the annotated type is used. assertFalse(line.contains("::")); } }
@Test public void testDocFileInclude() throws Exception { assertEquals("<before>Map<String, String> map = new HashMap<>();\n" + "// Some comment\n" + "\n" + "if (true) {\n" + " // Indented 1\n" + " if (false) {\n" + " // Indented 2\n" + " }\n" + "}\n" + "map.put(\"abc\", \"def\");\n" + "map.get(\"abc\"); // Beyond last statement<after>", assertDocFile("docs/include.adoc")); }
@Test public void testIncludeAnnotatedInterface() throws Exception { assertEquals( "before_include@Source\n" + "public interface TheExample {\n" + "\n" + " void someMethod();\n" + "\n" + "}after_include", assertDoc("io.vertx.test.includeannotatedinterface")); }