Search in sources :

Example 6 with Page

use of org.ballerinalang.docgen.model.Page in project ballerina by ballerina-lang.

the class HtmlDocTest method testConnectors.

@Test(description = "Connectors in a package should be shown in the constructs", enabled = false)
public void testConnectors() throws Exception {
    BLangPackage bLangPackage = createPackage("package x.y; " + "public connector HttpClient (string uri, int n){}" + "public connector Http2Client (string uri, int n){}");
    Page page = generatePage(bLangPackage);
    Assert.assertEquals(page.constructs.size(), 2);
    Assert.assertEquals(page.constructs.get(0).name, "HttpClient");
    Assert.assertEquals(page.constructs.get(1).name, "Http2Client");
}
Also used : BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) Page(org.ballerinalang.docgen.model.Page) Test(org.testng.annotations.Test)

Example 7 with Page

use of org.ballerinalang.docgen.model.Page in project ballerina by ballerina-lang.

the class HtmlDocTest method testStructs.

@Test(description = "Structs in a package should be shown in the constructs")
public void testStructs() throws Exception {
    BLangPackage bLangPackage = createPackage("package x.y; public struct Message {}");
    Page page = generatePage(bLangPackage);
    Assert.assertEquals(page.constructs.size(), 1);
    Assert.assertEquals(page.constructs.get(0).name, "Message");
}
Also used : BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) Page(org.ballerinalang.docgen.model.Page) Test(org.testng.annotations.Test)

Example 8 with Page

use of org.ballerinalang.docgen.model.Page in project ballerina by ballerina-lang.

the class HtmlDocTest method testEnums.

@Test(description = "Enums in a package should be shown in the constructs")
public void testEnums() throws Exception {
    BLangPackage bLangPackage = createPackage("package x.y; " + "public enum Direction {IN,OUT}" + "public enum Money {USD,LKR}");
    Page page = generatePage(bLangPackage);
    Assert.assertEquals(page.constructs.size(), 2);
    Assert.assertEquals(page.constructs.get(0).name, "Direction");
    Assert.assertTrue(page.constructs.get(0) instanceof EnumDoc, "Invalid documentable type.");
    Assert.assertEquals(((EnumDoc) page.constructs.get(0)).enumerators.get(0).toString(), "IN", "Invalid enum val");
    Assert.assertEquals(((EnumDoc) page.constructs.get(0)).enumerators.get(1).toString(), "OUT", "Invalid enum val");
    Assert.assertEquals(page.constructs.get(1).name, "Money");
}
Also used : EnumDoc(org.ballerinalang.docgen.model.EnumDoc) BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) Page(org.ballerinalang.docgen.model.Page) Test(org.testng.annotations.Test)

Example 9 with Page

use of org.ballerinalang.docgen.model.Page in project ballerina by ballerina-lang.

the class WriterTest method testWriterWithInvalidPath.

@Test(description = "Test writer with invalid output path.")
public void testWriterWithInvalidPath() {
    URL location = Writer.class.getProtectionDomain().getCodeSource().getLocation();
    String outputPath = location.getPath();
    Writer.writeHtmlDocument(new Page(new StaticCaption(""), new ArrayList<>(), new ArrayList<>()), "page", outputPath);
    Assert.assertTrue(outContent.toString().contains("docerina: could not write HTML file"), "An error was expected");
}
Also used : ArrayList(java.util.ArrayList) Page(org.ballerinalang.docgen.model.Page) URL(java.net.URL) StaticCaption(org.ballerinalang.docgen.model.StaticCaption) Test(org.testng.annotations.Test)

Example 10 with Page

use of org.ballerinalang.docgen.model.Page in project ballerina by ballerina-lang.

the class WriterTest method testWriter.

@Test(description = "Test if writer class is working.")
public void testWriter() {
    URL location = Writer.class.getProtectionDomain().getCodeSource().getLocation();
    String outputPath = location.getPath() + File.separator + "sample.html";
    Writer.writeHtmlDocument(new Page(new StaticCaption(""), new ArrayList<>(), new ArrayList<>()), "page", outputPath);
}
Also used : ArrayList(java.util.ArrayList) Page(org.ballerinalang.docgen.model.Page) URL(java.net.URL) StaticCaption(org.ballerinalang.docgen.model.StaticCaption) Test(org.testng.annotations.Test)

Aggregations

Page (org.ballerinalang.docgen.model.Page)20 Test (org.testng.annotations.Test)17 BLangPackage (org.wso2.ballerinalang.compiler.tree.BLangPackage)17 ArrayList (java.util.ArrayList)7 Link (org.ballerinalang.docgen.model.Link)5 PackageName (org.ballerinalang.docgen.model.PackageName)5 StaticCaption (org.ballerinalang.docgen.model.StaticCaption)5 StructDoc (org.ballerinalang.docgen.model.StructDoc)3 URL (java.net.URL)2 List (java.util.List)2 Documentable (org.ballerinalang.docgen.model.Documentable)2 FunctionDoc (org.ballerinalang.docgen.model.FunctionDoc)2 EnumNode (org.ballerinalang.model.tree.EnumNode)2 TypeNode (org.ballerinalang.model.tree.types.TypeNode)2 BLangAnnotation (org.wso2.ballerinalang.compiler.tree.BLangAnnotation)2 BLangConnector (org.wso2.ballerinalang.compiler.tree.BLangConnector)2 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)2 BLangStruct (org.wso2.ballerinalang.compiler.tree.BLangStruct)2 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)2 BLangUserDefinedType (org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType)2