public void description(List<DocumentationItem> docs) { if (has(Validation.DESCRIPTION)) { if (isNullOrEmpty(docs)) { violation("documentation.missing", locator); } else { for (final DocumentationItem doc : docs) { if (isNullOrEmpty(doc.getTitle())) { violation("documentation.missing.title", locator); } else if (isNullOrEmpty(doc.getContent())) { violation("documentation.missing.content", locator); } } } } }
@Test public void apiLevelDocs() { processResource("ApiLevelDocs.java", "raml", "all"); AssertJUnit.assertEquals("ApiLevelDocs should have produced exactly 1 results document", 1, output.size()); Map.Entry<String,String> entry = output.entrySet().iterator().next(); AssertJUnit.assertTrue("expected file named ApiLevelDocs-UltimateApi.raml", entry.getKey().endsWith("ApiLevelDocs-UltimateApi.raml")); Raml raml = new RamlDocumentBuilder().build(entry.getValue(), "http://example.com"); AssertJUnit.assertNotNull("RAML not parseable", raml); AssertJUnit.assertEquals("RAML title is incorrect", "The Ultimate REST API", raml.getTitle()); AssertJUnit.assertEquals("RAML version is incorrect", "v1", raml.getVersion()); AssertJUnit.assertEquals("RAML baseUri is incorrect", "/ultimate/api/v1", raml.getBaseUri()); List<DocumentationItem> documentation = raml.getDocumentation(); AssertJUnit.assertNotNull("RAML has no documentation items", documentation); AssertJUnit.assertEquals("RAML has too many documentation items", 1, documentation.size()); AssertJUnit.assertEquals("RAML documentation item has wrong title", "Overview", documentation.get(0).getTitle()); AssertJUnit.assertEquals("RAML documentation item has wrong content", "Some documentation of the API itself.", documentation.get(0).getContent().trim()); }
AssertJUnit.assertNotNull("RAML has no documentation items", documentation); AssertJUnit.assertEquals("RAML has too many documentation items", 1, documentation.size()); AssertJUnit.assertEquals("RAML documentation item has wrong title", "Overview", documentation.get(0).getTitle()); AssertJUnit.assertEquals("RAML documentation item has wrong content", "This is the header documentation text for RestApi1.", documentation.get(0).getContent().trim()); AssertJUnit.assertNotNull("RAML has no documentation items", documentation); AssertJUnit.assertEquals("RAML has too many documentation items", 1, documentation.size()); AssertJUnit.assertEquals("RAML documentation item has wrong title", "Overview", documentation.get(0).getTitle()); AssertJUnit.assertTrue("RAML documentation item has wrong content", documentation.get(0).getContent().trim().startsWith("This is the header documentation text for RestApi2."));