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%2FMountPointSwaggerTest.java;h=6342d1a780e00eed410c0803e40ce80e914b0fb7;hb=666449136de312558cee27e847f101c0463b5ceb;hp=7b3344348ae96f38ba2ecca2df7d87157974d44a;hpb=4c0c091813aea131d32dc70c5121a450eb9b7291;p=netconf.git diff --git a/restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/MountPointSwaggerTest.java b/restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/MountPointSwaggerTest.java index 7b3344348a..6342d1a780 100644 --- a/restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/MountPointSwaggerTest.java +++ b/restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/MountPointSwaggerTest.java @@ -15,7 +15,6 @@ import static org.mockito.Mockito.when; import com.google.common.base.Optional; import java.net.URISyntaxException; import java.util.Arrays; -import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.TreeSet; @@ -33,15 +32,14 @@ import org.opendaylight.netconf.sal.rest.doc.swagger.Resource; import org.opendaylight.netconf.sal.rest.doc.swagger.ResourceList; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; public class MountPointSwaggerTest { private static final String HTTP_URL = "http://localhost/path"; private static final YangInstanceIdentifier instanceId = YangInstanceIdentifier.builder() .node(QName.create("nodes")) + .node(QName.create("node")) .nodeWithKey(QName.create("node"), QName.create("id"), "123").build(); private static final String INSTANCE_URL = "nodes/node/123/"; private MountPointSwagger swagger; @@ -50,45 +48,45 @@ public class MountPointSwaggerTest { @Before public void setUp() throws Exception { - swagger = new MountPointSwagger(); - helper = new DocGenTestHelper(); - helper.setUp(); - schemaContext = new YangParserImpl().resolveSchemaContext(new HashSet(helper.getModules().values())); + this.swagger = new MountPointSwagger(); + this.helper = new DocGenTestHelper(); + this.helper.setUp(); + this.schemaContext = this.helper.getSchemaContext(); } @Test() public void testGetResourceListBadIid() throws Exception { - UriInfo mockInfo = helper.createMockUriInfo(HTTP_URL); + final UriInfo mockInfo = this.helper.createMockUriInfo(HTTP_URL); - assertEquals(null, swagger.getResourceList(mockInfo, 1L)); + assertEquals(null, this.swagger.getResourceList(mockInfo, 1L)); } @Test() public void getInstanceIdentifiers() throws Exception { - UriInfo mockInfo = setUpSwaggerForDocGeneration(); + final UriInfo mockInfo = setUpSwaggerForDocGeneration(); - assertEquals(0, swagger.getInstanceIdentifiers().size()); - swagger.onMountPointCreated(instanceId); // add this ID into the list of + assertEquals(0, this.swagger.getInstanceIdentifiers().size()); + this.swagger.onMountPointCreated(instanceId); // add this ID into the list of // mount points - assertEquals(1, swagger.getInstanceIdentifiers().size()); - assertEquals((Long) 1L, swagger.getInstanceIdentifiers().entrySet().iterator().next() + assertEquals(1, this.swagger.getInstanceIdentifiers().size()); + assertEquals((Long) 1L, this.swagger.getInstanceIdentifiers().entrySet().iterator().next() .getValue()); - assertEquals(INSTANCE_URL, swagger.getInstanceIdentifiers().entrySet().iterator().next() + assertEquals(INSTANCE_URL, this.swagger.getInstanceIdentifiers().entrySet().iterator().next() .getKey()); - swagger.onMountPointRemoved(instanceId); // remove ID from list of mount + this.swagger.onMountPointRemoved(instanceId); // remove ID from list of mount // points - assertEquals(0, swagger.getInstanceIdentifiers().size()); + assertEquals(0, this.swagger.getInstanceIdentifiers().size()); } @Test public void testGetResourceListGoodId() throws Exception { - UriInfo mockInfo = setUpSwaggerForDocGeneration(); - swagger.onMountPointCreated(instanceId); // add this ID into the list of + final UriInfo mockInfo = setUpSwaggerForDocGeneration(); + this.swagger.onMountPointCreated(instanceId); // add this ID into the list of // mount points - ResourceList resourceList = swagger.getResourceList(mockInfo, 1L); + final ResourceList resourceList = this.swagger.getResourceList(mockInfo, 1L); Resource dataStoreResource = null; - for (Resource r : resourceList.getApis()) { + for (final Resource r : resourceList.getApis()) { if (r.getPath().endsWith("/Datastores(-)")) { dataStoreResource = r; } @@ -98,25 +96,25 @@ public class MountPointSwaggerTest { @Test public void testGetDataStoreApi() throws Exception { - UriInfo mockInfo = setUpSwaggerForDocGeneration(); - swagger.onMountPointCreated(instanceId); // add this ID into the list of + final UriInfo mockInfo = setUpSwaggerForDocGeneration(); + this.swagger.onMountPointCreated(instanceId); // add this ID into the list of // mount points - ApiDeclaration mountPointApi = swagger.getMountPointApi(mockInfo, 1L, "Datastores", "-"); + final ApiDeclaration mountPointApi = this.swagger.getMountPointApi(mockInfo, 1L, "Datastores", "-"); assertNotNull("failed to find Datastore API", mountPointApi); - List apis = mountPointApi.getApis(); + final List apis = mountPointApi.getApis(); assertEquals("Unexpected api list size", 3, apis.size()); - Set actualApis = new TreeSet<>(); - for (Api api : apis) { + final Set actualApis = new TreeSet<>(); + for (final Api api : apis) { actualApis.add(api.getPath()); - List operations = api.getOperations(); + final List operations = api.getOperations(); assertEquals("unexpected operation size on " + api.getPath(), 1, operations.size()); assertEquals("unexpected operation method " + api.getPath(), "GET", operations.get(0) .getMethod()); assertNotNull("expected non-null desc on " + api.getPath(), operations.get(0) .getNotes()); } - Set expectedApis = new TreeSet<>(Arrays.asList(new String[] { + final Set expectedApis = new TreeSet<>(Arrays.asList(new String[] { "/config/" + INSTANCE_URL + "yang-ext:mount/", "/operational/" + INSTANCE_URL + "yang-ext:mount/", "/operations/" + INSTANCE_URL + "yang-ext:mount/", })); @@ -124,20 +122,20 @@ public class MountPointSwaggerTest { } protected UriInfo setUpSwaggerForDocGeneration() throws URISyntaxException { - UriInfo mockInfo = helper.createMockUriInfo(HTTP_URL); + final UriInfo mockInfo = this.helper.createMockUriInfo(HTTP_URL); // We are sharing the global schema service and the mount schema service // in our test. // OK for testing - real thing would have seperate instances. - SchemaContext context = helper.createMockSchemaContext(); - SchemaService schemaService = helper.createMockSchemaService(context); + final SchemaContext context = this.helper.createMockSchemaContext(); + final SchemaService schemaService = this.helper.createMockSchemaService(context); - DOMMountPoint mountPoint = mock(DOMMountPoint.class); + final DOMMountPoint mountPoint = mock(DOMMountPoint.class); when(mountPoint.getSchemaContext()).thenReturn(context); - DOMMountPointService service = mock(DOMMountPointService.class); + final DOMMountPointService service = mock(DOMMountPointService.class); when(service.getMountPoint(instanceId)).thenReturn(Optional.of(mountPoint)); - swagger.setMountService(service); - swagger.setGlobalSchema(schemaService); + this.swagger.setMountService(service); + this.swagger.setGlobalSchema(schemaService); return mockInfo; }