Search in sources :

Example 76 with BLangPackage

use of org.wso2.ballerinalang.compiler.tree.BLangPackage in project ballerina by ballerina-lang.

the class HtmlDocTest method testGlobalVariablePropertiesExtracted.

@Test(description = "Global variables should be available via construct")
public void testGlobalVariablePropertiesExtracted() throws Exception {
    BLangPackage bLangPackage = createPackage("package x.y; " + "@Description { value:\"The Read Append access mode\"}\n" + "public const string RA = \"RA\";");
    GlobalVariableDoc globalVariableDoc = Generator.createDocForNode(bLangPackage.getGlobalVariables().get(0));
    Assert.assertEquals(globalVariableDoc.name, "RA", "Global variable name should be extracted");
    Assert.assertEquals(globalVariableDoc.dataType, "string", "Global variable type should be extracted");
    Assert.assertEquals(globalVariableDoc.description, "The Read Append access mode", "Description of the " + "global variable should be extracted");
}
Also used : BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) GlobalVariableDoc(org.ballerinalang.docgen.model.GlobalVariableDoc) Test(org.testng.annotations.Test)

Example 77 with BLangPackage

use of org.wso2.ballerinalang.compiler.tree.BLangPackage in project ballerina by ballerina-lang.

the class HtmlDocTest method testStructPropertiesExtracted.

@Test(description = "Struct properties should be available via construct")
public void testStructPropertiesExtracted() throws Exception {
    BLangPackage bLangPackage = createPackage("package x.y; " + "@Description { value:\"Message sent by the client\"}" + "@Field {value:\"count: Number of retries\"}\n" + "@Field {value:\"interval: Retry interval in millisecond\"}" + "struct Message {int interval;int count;}");
    StructDoc structDoc = Generator.createDocForNode(bLangPackage.getStructs().get(0));
    Assert.assertEquals(structDoc.name, "Message", "Struct name should be extracted");
    Assert.assertEquals(structDoc.description, "Message sent by the client", "Description of the " + "struct should be extracted");
    // Struct fields
    Assert.assertEquals(structDoc.fields.get(0).name, "interval", "Struct field name should be extracted");
    Assert.assertEquals(structDoc.fields.get(0).dataType, "int", "Struct field type should be extracted");
    Assert.assertEquals(structDoc.fields.get(0).description, "Retry interval in millisecond", "Description of the struct field should be extracted");
}
Also used : BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) StructDoc(org.ballerinalang.docgen.model.StructDoc) Test(org.testng.annotations.Test)

Example 78 with BLangPackage

use of org.wso2.ballerinalang.compiler.tree.BLangPackage in project ballerina by ballerina-lang.

the class HtmlDocTest method testAnnotations.

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

Example 79 with BLangPackage

use of org.wso2.ballerinalang.compiler.tree.BLangPackage in project ballerina by ballerina-lang.

the class HtmlDocTest method testFunctionsWithWithoutStructBindings.

@Test(description = "Functions with struct bindings in a package should be grouped together and functions" + "without struct bindings should be isolated as shown in the constructs")
public void testFunctionsWithWithoutStructBindings() throws Exception {
    BLangPackage bLangPackage = createPackage("package x.y; " + "public function <Message m>hello(){} " + "public struct Message { string message; int id;} " + "public function sayBye(){}");
    Page page = generatePage(bLangPackage);
    Assert.assertEquals(page.constructs.size(), 2);
    Assert.assertEquals(page.constructs.get(0).name, "Message");
    Assert.assertEquals(page.constructs.get(0).children.get(0).name, "hello");
    Assert.assertEquals(page.constructs.get(1).name, "sayBye");
}
Also used : BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) Page(org.ballerinalang.docgen.model.Page) Test(org.testng.annotations.Test)

Example 80 with BLangPackage

use of org.wso2.ballerinalang.compiler.tree.BLangPackage in project ballerina by ballerina-lang.

the class HtmlDocTest method testEmptyPackage.

@Test(description = "Empty package should give an empty page")
public void testEmptyPackage() throws Exception {
    BLangPackage bLangPackage = createPackage("package x.y;");
    Page page = generatePage(bLangPackage);
    Assert.assertTrue(page.constructs.isEmpty());
}
Also used : BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) Page(org.ballerinalang.docgen.model.Page) Test(org.testng.annotations.Test)

Aggregations

BLangPackage (org.wso2.ballerinalang.compiler.tree.BLangPackage)78 Test (org.testng.annotations.Test)29 ArrayList (java.util.ArrayList)28 CompilerContext (org.wso2.ballerinalang.compiler.util.CompilerContext)19 Page (org.ballerinalang.docgen.model.Page)18 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)16 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)15 DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)15 BLangNode (org.wso2.ballerinalang.compiler.tree.BLangNode)14 IOException (java.io.IOException)13 List (java.util.List)13 Path (java.nio.file.Path)12 Compiler (org.wso2.ballerinalang.compiler.Compiler)12 BLangStruct (org.wso2.ballerinalang.compiler.tree.BLangStruct)12 BLangService (org.wso2.ballerinalang.compiler.tree.BLangService)11 TopLevelNode (org.ballerinalang.model.tree.TopLevelNode)10 BLangConnector (org.wso2.ballerinalang.compiler.tree.BLangConnector)10 BPackageSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol)9 BLangAction (org.wso2.ballerinalang.compiler.tree.BLangAction)9 BLangEnum (org.wso2.ballerinalang.compiler.tree.BLangEnum)9