X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-docgen%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frest%2Fdoc%2Fimpl%2FApiDocGeneratorTest.java;h=07c9378439d2f66551672d8a08ec20785a0a074b;hb=0e7b83c0739ac579ca6dbf6a3f7992f70eb3000f;hp=8390a385e6a136a29d79e64376a0fadf8fa03757;hpb=0d342104d5d08b4f9d65c1d845134e7ee1bb1f80;p=controller.git diff --git a/opendaylight/md-sal/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/ApiDocGeneratorTest.java b/opendaylight/md-sal/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/ApiDocGeneratorTest.java index 8390a385e6..07c9378439 100644 --- a/opendaylight/md-sal/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/ApiDocGeneratorTest.java +++ b/opendaylight/md-sal/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/ApiDocGeneratorTest.java @@ -2,6 +2,7 @@ package org.opendaylight.controller.sal.rest.doc.impl; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.File; @@ -65,6 +66,24 @@ public class ApiDocGeneratorTest { } } + @Test + public void testEdgeCases() throws Exception { + Preconditions.checkArgument(helper.getModules() != null, "No modules found"); + + for (Entry m : helper.getModules().entrySet()) { + if (m.getKey().getAbsolutePath().endsWith("toaster.yang")) { + ApiDeclaration doc = generator.getSwaggerDocSpec(m.getValue(), + "http://localhost:8080/restconf", ""); + Assert.assertNotNull(doc); + + //testing bugs.opendaylight.org bug 1290. UnionType model type. + String jsonString = doc.getModels().toString(); + assertTrue( + jsonString.contains( "testUnion\":{\"type\":\"integer or string\",\"required\":false}" ) ); + } + } + } + private void validateToaster(ApiDeclaration doc) throws Exception { Set expectedUrls = new TreeSet<>(Arrays.asList(new String[] { "/config/toaster2:toaster/", "/operational/toaster2:toaster/", @@ -99,6 +118,7 @@ public class ApiDocGeneratorTest { expectedConfigMethods.removeAll(actualConfigMethods); fail("Missing expected method on config API: " + expectedConfigMethods); } + // TODO: we should really do some more validation of the // documentation... /**