X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=restconf%2Fsal-rest-docgen%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frest%2Fdoc%2Fimpl%2FSwaggerObjectTest.java;h=45287530e403dfd9196d21bb3391d6e50275978f;hb=4e117e0cce9f9ac1b53ace1d9659412dddc1afa2;hp=6de33841206ca864fdbe399787d9febfb85dea97;hpb=d98190dabb7426b0fb484170e0058a42ea1ef981;p=netconf.git diff --git a/restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/SwaggerObjectTest.java b/restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/SwaggerObjectTest.java index 6de3384120..45287530e4 100644 --- a/restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/SwaggerObjectTest.java +++ b/restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/SwaggerObjectTest.java @@ -5,67 +5,43 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.sal.rest.doc.impl; +import static org.junit.Assert.assertNotNull; + import com.fasterxml.jackson.databind.node.ObjectNode; -import com.google.common.base.Preconditions; -import java.sql.Date; -import org.junit.Assert; -import org.junit.Before; +import java.io.IOException; import org.junit.Test; import org.opendaylight.netconf.sal.rest.doc.impl.ApiDocServiceImpl; import org.opendaylight.netconf.sal.rest.doc.impl.DefinitionGenerator; import org.opendaylight.netconf.sal.rest.doc.impl.DefinitionNames; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - - -public class SwaggerObjectTest { +import org.opendaylight.yangtools.yang.common.Revision; - private static final String NAMESPACE = "urn:opendaylight:groupbasedpolicy:opflex"; - private static final String STRING_DATE = "2014-05-28"; - private static final Date REVISION = Date.valueOf(STRING_DATE); - private DocGenTestHelper helper; - private SchemaContext schemaContext; - - @Before - public void setUp() throws Exception { - this.helper = new DocGenTestHelper(); - this.helper.setUp(); - this.schemaContext = this.helper.getSchemaContext(); +public final class SwaggerObjectTest extends AbstractApiDocTest { + @Test + public void testConvertToJsonSchema() throws IOException { + final var module = CONTEXT.findModule("opflex", Revision.of("2014-05-28")).orElseThrow(); + final DefinitionGenerator generator = new DefinitionGenerator(); + final ObjectNode jsonObject = generator.convertToJsonSchema(module, CONTEXT, new DefinitionNames(), + ApiDocServiceImpl.OAversion.V2_0, true); + assertNotNull(jsonObject); } @Test - public void testConvertToJsonSchema() throws Exception { - - Preconditions.checkArgument(this.helper.getModules() != null, "No modules found"); - + public void testActionTypes() throws IOException { + final var module = CONTEXT.findModule("action-types").orElseThrow(); final DefinitionGenerator generator = new DefinitionGenerator(); - - for (final Module m : this.helper.getModules()) { - if (m.getQNameModule().getNamespace().toString().equals(NAMESPACE) - && m.getQNameModule().getRevision().equals(REVISION)) { - - final ObjectNode jsonObject = generator.convertToJsonSchema(m, this.schemaContext, - new DefinitionNames(), ApiDocServiceImpl.OAversion.V2_0, true); - Assert.assertNotNull(jsonObject); - } - } + final ObjectNode jsonObject = generator.convertToJsonSchema(module, CONTEXT, new DefinitionNames(), + ApiDocServiceImpl.OAversion.V2_0, true); + assertNotNull(jsonObject); } @Test - public void testStringTypes() throws Exception { - Preconditions.checkArgument(this.helper.getModules() != null, "No modules found"); - Module strTypes = this.helper.getModules().stream() - .filter(module -> module.getName().equals("string-types")) - .findFirst() - .orElseThrow(() -> new IllegalArgumentException("String types module not found")); - + public void testStringTypes() throws IOException { + final var module = CONTEXT.findModule("string-types").orElseThrow(); final DefinitionGenerator generator = new DefinitionGenerator(); - final ObjectNode jsonObject = generator.convertToJsonSchema(strTypes, this.schemaContext, new DefinitionNames(), - ApiDocServiceImpl.OAversion.V2_0, true); - - Assert.assertNotNull(jsonObject); + final ObjectNode jsonObject = generator.convertToJsonSchema(module, CONTEXT, new DefinitionNames(), + ApiDocServiceImpl.OAversion.V2_0, true); + assertNotNull(jsonObject); } }