use of org.ballerinalang.model.tree.PackageNode in project ballerina by ballerina-lang.
the class DocumentationTest method testDocStruct.
@Test(description = "Test doc struct.")
public void testDocStruct() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/struct.bal");
Assert.assertEquals(0, compileResult.getWarnCount());
PackageNode packageNode = compileResult.getAST();
List<BLangDocumentation> docNodes = ((BLangStruct) packageNode.getStructs().get(0)).docAttachments;
BLangDocumentation dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.documentationText, " Documentation for Test struct\n");
Assert.assertEquals(dNode.getAttributes().size(), 3);
Assert.assertEquals(dNode.getAttributes().get(0).documentationField.getValue(), "a");
Assert.assertEquals(dNode.getAttributes().get(0).documentationText, " struct `field a` documentation\n");
Assert.assertEquals(dNode.getAttributes().get(1).documentationField.getValue(), "b");
Assert.assertEquals(dNode.getAttributes().get(1).documentationText, " struct `field b` documentation\n");
Assert.assertEquals(dNode.getAttributes().get(2).documentationField.getValue(), "c");
Assert.assertEquals(dNode.getAttributes().get(2).documentationText, " struct `field c` documentation");
}
use of org.ballerinalang.model.tree.PackageNode in project ballerina by ballerina-lang.
the class DocumentationTest method testNestedInline.
@Test(description = "Test doc nested inline.")
public void testNestedInline() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/nested_inline.bal");
Assert.assertEquals(0, compileResult.getWarnCount());
PackageNode packageNode = compileResult.getAST();
BLangVariable constant = (BLangVariable) packageNode.getGlobalVariables().get(0);
List<BLangDocumentation> docNodes = constant.docAttachments;
BLangDocumentation dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.getAttributes().size(), 0);
Assert.assertEquals(dNode.documentationText, "\n" + " Example of a string template:\n" + " ``` This starts ends triple backtick ``string s = string `hello {{name}}`;`` " + "ends triple backtick```\n" + "\n" + " Example for an xml literal:\n" + " ``xml x = xml `<{{tagName}}>hello</{{tagName}}>`;``\n");
}
use of org.ballerinalang.model.tree.PackageNode in project ballerina by ballerina-lang.
the class DocumentationTest method testDocService.
@Test(description = "Test doc service.", enabled = false)
public void testDocService() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/service.bal");
Assert.assertEquals(0, compileResult.getWarnCount());
PackageNode packageNode = compileResult.getAST();
BLangService service = (BLangService) packageNode.getServices().get(0);
List<BLangDocumentation> docNodes = service.docAttachments;
BLangDocumentation dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.documentationText, "PizzaService HTTP Service");
dNode = service.getResources().get(0).docAttachments.get(0);
Assert.assertEquals(dNode.getAttributes().size(), 2);
Assert.assertEquals(dNode.documentationText, "Check orderPizza resource. ");
Assert.assertEquals(dNode.getAttributes().get(0).documentationField.getValue(), "conn");
Assert.assertEquals(dNode.getAttributes().get(0).documentationText, " HTTP connection. ");
Assert.assertEquals(dNode.getAttributes().get(1).documentationField.getValue(), "req");
Assert.assertEquals(dNode.getAttributes().get(1).documentationText, " In request.");
dNode = service.getResources().get(1).docAttachments.get(0);
Assert.assertEquals(dNode.documentationText, "Check status resource. ");
Assert.assertEquals(dNode.getAttributes().size(), 2);
Assert.assertEquals(dNode.getAttributes().get(0).documentationField.getValue(), "conn");
Assert.assertEquals(dNode.getAttributes().get(0).documentationText, " HTTP connection. ");
Assert.assertEquals(dNode.getAttributes().get(1).documentationField.getValue(), "req");
Assert.assertEquals(dNode.getAttributes().get(1).documentationText, " In request.");
}
use of org.ballerinalang.model.tree.PackageNode in project ballerina by ballerina-lang.
the class DocumentationTest method testDeprecatedTransformer.
@Test(description = "Test doc deprecated Transformer.")
public void testDeprecatedTransformer() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/deprecated_transformer.bal");
Assert.assertEquals(0, compileResult.getWarnCount());
PackageNode packageNode = compileResult.getAST();
List<BLangDeprecatedNode> dNodes = ((BLangTransformer) packageNode.getTransformers().get(0)).deprecatedAttachments;
BLangDeprecatedNode dNode = dNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.documentationText, "\n" + " This Transformer is deprecated use\n" + " `transformer <Person p, Employee e> Bar(any defaultAddress) { e.name = p.firstName; }\n" + " ` instead.\n");
List<BLangDocumentation> docNodes = ((BLangTransformer) packageNode.getTransformers().get(0)).docAttachments;
BLangDocumentation docNode = docNodes.get(0);
Assert.assertNotNull(docNode);
Assert.assertEquals(docNode.documentationText, "\n Transformer Foo Person -> Employee\n ");
Assert.assertEquals(docNode.getAttributes().size(), 3);
Assert.assertEquals(docNode.getAttributes().get(0).documentationField.getValue(), "p");
Assert.assertEquals(docNode.getAttributes().get(0).documentationText, " input struct Person source used for transformation\n ");
Assert.assertEquals(docNode.getAttributes().get(1).documentationField.getValue(), "e");
Assert.assertEquals(docNode.getAttributes().get(1).documentationText, " output struct Employee struct which Person transformed to\n ");
Assert.assertEquals(docNode.getAttributes().get(2).documentationField.getValue(), "defaultAddress");
Assert.assertEquals(docNode.getAttributes().get(2).documentationText, " address which serves Eg: `POSTCODE 112`\n");
}
use of org.ballerinalang.model.tree.PackageNode in project ballerina by ballerina-lang.
the class DocumentationTest method testDocEnum.
@Test(description = "Test doc annotation enum.")
public void testDocEnum() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/enum.bal");
Assert.assertEquals(0, compileResult.getWarnCount());
PackageNode packageNode = compileResult.getAST();
List<BLangDocumentation> docNodes = ((BLangEnum) packageNode.getEnums().get(0)).docAttachments;
BLangDocumentation dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.documentationText, " Documentation for state enum\n");
Assert.assertEquals(dNode.getAttributes().size(), 2);
Assert.assertEquals(dNode.getAttributes().get(0).documentationField.getValue(), "foo");
Assert.assertEquals(dNode.getAttributes().get(0).documentationText, " enum `field foo` documentation\n");
Assert.assertEquals(dNode.getAttributes().get(1).documentationField.getValue(), "bar");
Assert.assertEquals(dNode.getAttributes().get(1).documentationText, " enum `field bar` documentation");
}
Aggregations