use of org.ballerinalang.docgen.model.Page in project ballerina by ballerina-lang.
the class HtmlDocTest method testAnonymousStructs.
@Test(description = "Tests whether anonymous structs are documented.")
public void testAnonymousStructs() {
BLangPackage bLangPackage = createPackage("package x.y; " + "@Description { value:\"Represents a person\"}" + "@Field {value:\"id: The identification number\"}\n" + "@Field {value:\"address: The address of the person.\"}" + "public struct Person {" + " string id;" + " struct {" + " string address1;" + " string address2;" + " string state = \"MN\";" + " } address;" + "}");
Page page = generatePage(bLangPackage);
Assert.assertEquals(page.constructs.size(), 1);
Assert.assertTrue(page.constructs.get(0) instanceof StructDoc, "Documentable of type StructDoc expected.");
StructDoc personStructDoc = (StructDoc) page.constructs.get(0);
Assert.assertEquals(personStructDoc.fields.size(), 2, "2 fields are expected.");
Assert.assertEquals(personStructDoc.fields.get(0).name, "id", "Field \"id\" expected.");
Assert.assertEquals(personStructDoc.fields.get(1).name, "address", "Field \"address\" expected.");
Assert.assertEquals(personStructDoc.fields.get(1).description, "The address of the person.");
Assert.assertEquals(personStructDoc.fields.get(1).dataType, "struct {string address1, string address2, string state}");
}
use of org.ballerinalang.docgen.model.Page in project ballerina by ballerina-lang.
the class HtmlDocTest method testGlobalVariables.
@Test(description = "Annotation in a package should be shown in the constructs")
public void testGlobalVariables() throws Exception {
BLangPackage bLangPackage = createPackage("package x.y; " + "public int total = 98;" + "public string content = \"Name\";");
Page page = generatePage(bLangPackage);
Assert.assertEquals(page.constructs.size(), 2);
Assert.assertEquals(page.constructs.get(0).name, "total");
Assert.assertEquals(page.constructs.get(1).name, "content");
}
use of org.ballerinalang.docgen.model.Page in project ballerina by ballerina-lang.
the class HtmlDocTest method testMultiPackage.
@Test(description = "Multiple packages should be shown even when one page is generated")
public void testMultiPackage() throws Exception {
List<Link> packages = new ArrayList<>();
packages.add(new Link(new PackageName("a.b.c", ""), "", false));
packages.add(new Link(new PackageName("x.y", ""), "", false));
packages.add(new Link(new PackageName("x.y.z", ""), "", false));
BLangPackage bLangPackage = createPackage("package x.y;");
Page page = Generator.generatePage(bLangPackage, packages);
Assert.assertEquals(page.links.size(), 3);
Assert.assertFalse(page.links.get(0).active);
Assert.assertTrue(page.links.get(1).active);
}
use of org.ballerinalang.docgen.model.Page in project ballerina by ballerina-lang.
the class HtmlDocTest method testFunctionsWithoutStructBindings.
@Test(description = "One function without a struct bindings in a package should not be grouped together with the" + "structs shown in the constructs")
public void testFunctionsWithoutStructBindings() throws Exception {
BLangPackage bLangPackage = createPackage("package x.y; " + "public function hello(){} " + "public struct Message { string message; int id;}");
Page page = generatePage(bLangPackage);
Assert.assertEquals(page.constructs.size(), 2);
Assert.assertEquals(page.constructs.get(0).name, "Message");
Assert.assertEquals(page.constructs.get(1).name, "hello");
}
use of org.ballerinalang.docgen.model.Page in project ballerina by ballerina-lang.
the class HtmlDocTest method testFunctionsWithStructBindings.
@Test(description = "One function with a struct bindings in a package should be grouped together shown in the " + "constructs")
public void testFunctionsWithStructBindings() throws Exception {
BLangPackage bLangPackage = createPackage("package x.y; " + "public function <Message m>hello(){} " + "public struct Message { string message; int id;}");
Page page = generatePage(bLangPackage);
Assert.assertEquals(page.constructs.size(), 1);
Assert.assertEquals(page.constructs.get(0).name, "Message");
Assert.assertEquals(page.constructs.get(0).children.get(0).name, "hello");
}
Aggregations