use of org.wso2.siddhi.annotation.Example in project ballerina by ballerina-lang.
the class DocumentationTest method testDocFunction.
@Test(description = "Test doc function.")
public void testDocFunction() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/function.bal");
Assert.assertEquals(0, compileResult.getWarnCount());
PackageNode packageNode = compileResult.getAST();
List<BLangDocumentation> docNodes = ((BLangFunction) packageNode.getFunctions().get(0)).docAttachments;
BLangDocumentation dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.documentationText, "\n" + "Gets a access parameter value (`true` or `false`) for a given key. " + "Please note that #foo will always be bigger than #bar.\n" + "Example:\n" + "``SymbolEnv pkgEnv = symbolEnter.packageEnvs.get(pkgNode.symbol);``\n");
Assert.assertEquals(dNode.getAttributes().size(), 2);
Assert.assertEquals(dNode.getAttributes().get(0).documentationField.getValue(), "file");
Assert.assertEquals(dNode.getAttributes().get(0).documentationText, " file path ``C:\\users\\OddThinking\\Documents\\My Source\\Widget\\foo.src``\n");
Assert.assertEquals(dNode.getAttributes().get(1).documentationField.getValue(), "accessMode");
Assert.assertEquals(dNode.getAttributes().get(1).documentationText, " read or write mode\n");
docNodes = ((BLangStruct) packageNode.getStructs().get(0)).docAttachments;
dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.documentationText, " Documentation for File struct\n");
Assert.assertEquals(dNode.getAttributes().size(), 1);
Assert.assertEquals(dNode.getAttributes().get(0).documentationField.getValue(), "path");
Assert.assertEquals(dNode.getAttributes().get(0).documentationText, " struct `field path` documentation\n");
}
use of org.wso2.siddhi.annotation.Example in project ballerina by ballerina-lang.
the class DocumentationTest method testDocConnectorFunction.
@Test(description = "Test doc connector/function.", enabled = false)
public void testDocConnectorFunction() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/connector_function.bal");
Assert.assertEquals(0, compileResult.getWarnCount());
PackageNode packageNode = compileResult.getAST();
BLangConnector connector = (BLangConnector) packageNode.getConnectors().get(0);
List<BLangDocumentation> docNodes = connector.docAttachments;
BLangDocumentation dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.getAttributes().size(), 2);
Assert.assertEquals(dNode.documentationText, "Test Connector\n");
Assert.assertEquals(dNode.getAttributes().get(0).documentationField.getValue(), "url");
Assert.assertEquals(dNode.getAttributes().get(0).documentationText, " url for endpoint\n");
Assert.assertEquals(dNode.getAttributes().get(1).documentationField.getValue(), "path");
Assert.assertEquals(dNode.getAttributes().get(1).documentationText, " path for endpoint\n");
dNode = connector.getActions().get(0).docAttachments.get(0);
Assert.assertEquals(dNode.getAttributes().size(), 1);
Assert.assertEquals(dNode.documentationText, "Test Connector action testAction ");
Assert.assertEquals(dNode.getAttributes().get(0).documentationField.getValue(), "s");
Assert.assertEquals(dNode.getAttributes().get(0).documentationText, " which represent successful or not");
dNode = connector.getActions().get(1).docAttachments.get(0);
Assert.assertEquals(dNode.documentationText, "Test Connector action testSend ");
Assert.assertEquals(dNode.getAttributes().size(), 2);
Assert.assertEquals(dNode.getAttributes().get(0).documentationField.getValue(), "ep");
Assert.assertEquals(dNode.getAttributes().get(0).documentationText, " which represent successful or not ");
Assert.assertEquals(dNode.getAttributes().get(1).documentationField.getValue(), "s");
Assert.assertEquals(dNode.getAttributes().get(1).documentationText, " which represent successful or not");
docNodes = ((BLangFunction) packageNode.getFunctions().get(0)).docAttachments;
dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.documentationText, "\n" + "Gets a access parameter value (`true` or `false`) for a given key. " + "Please note that #foo will always be bigger than #bar.\n" + "Example:\n" + "``SymbolEnv pkgEnv = symbolEnter.packageEnvs.get(pkgNode.symbol);``\n");
Assert.assertEquals(dNode.getAttributes().size(), 3);
Assert.assertEquals(dNode.getAttributes().get(0).documentationField.getValue(), "file");
Assert.assertEquals(dNode.getAttributes().get(0).documentationText, " file path ``C:\\users\\OddThinking\\Documents\\My Source\\Widget\\foo.src``\n");
Assert.assertEquals(dNode.getAttributes().get(1).documentationField.getValue(), "accessMode");
Assert.assertEquals(dNode.getAttributes().get(1).documentationText, " read or write mode\n");
Assert.assertEquals(dNode.getAttributes().get(2).documentationField.getValue(), "successful");
Assert.assertEquals(dNode.getAttributes().get(2).documentationText, " boolean `true` or `false`\n");
docNodes = ((BLangStruct) packageNode.getStructs().get(0)).docAttachments;
dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.documentationText, " Documentation for File struct\n");
Assert.assertEquals(dNode.getAttributes().size(), 1);
Assert.assertEquals(dNode.getAttributes().get(0).documentationField.getValue(), "path");
Assert.assertEquals(dNode.getAttributes().get(0).documentationText, " struct `field path` documentation\n");
}
use of org.wso2.siddhi.annotation.Example in project ballerina by ballerina-lang.
the class DocumentationTest method testNestedInlineDeprecated.
@Test(description = "Test doc nested inline inside deprecated tag.")
public void testNestedInlineDeprecated() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/nested_inline_deprecated.bal");
Assert.assertEquals(0, compileResult.getWarnCount());
PackageNode packageNode = compileResult.getAST();
BLangVariable constant = (BLangVariable) packageNode.getGlobalVariables().get(0);
List<BLangDeprecatedNode> docNodes = constant.deprecatedAttachments;
BLangDeprecatedNode dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.documentationText, "\n" + " Example of a string templates:\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.wso2.siddhi.annotation.Example in project ballerina by ballerina-lang.
the class DocumentationTest method testDocNativeFunction.
@Test(description = "Test doc native function.")
public void testDocNativeFunction() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/native_function.bal", CompilerPhase.TYPE_CHECK);
Assert.assertEquals(1, compileResult.getWarnCount());
BAssertUtil.validateWarning(compileResult, 0, "no such documentable attribute 'successful' with doc prefix 'P'", 6, 1);
PackageNode packageNode = compileResult.getAST();
List<BLangDocumentation> docNodes = ((BLangFunction) packageNode.getFunctions().get(0)).docAttachments;
BLangDocumentation dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.documentationText, "\n" + "Gets a access parameter value (`true` or `false`) for a given key. " + "Please note that #foo will always be bigger than #bar.\n" + "Example:\n" + "``SymbolEnv pkgEnv = symbolEnter.packageEnvs.get(pkgNode.symbol);``\n");
Assert.assertEquals(dNode.getAttributes().size(), 2);
Assert.assertEquals(dNode.getAttributes().get(0).documentationField.getValue(), "accessMode");
Assert.assertEquals(dNode.getAttributes().get(0).documentationText, " read or write mode\n");
Assert.assertEquals(dNode.getAttributes().get(1).documentationField.getValue(), "successful");
Assert.assertEquals(dNode.getAttributes().get(1).documentationText, " boolean `true` or `false`\n");
}
Aggregations