Move SimpleUriInfo 43/100543/5
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 12 Apr 2022 11:56:04 +0000 (13:56 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 14 Apr 2022 19:04:33 +0000 (21:04 +0200)
This class is used only in tests, move it and hide it. Also rename it to
LocalUriInfo and mark its sole user for future evolution, e.g. use
mocks.

JIRA: NETCONF-837
Change-Id: If3ecdbf332cd3c18bdb8822d2f5396c3d59df3b4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/LocalUriInfo.java [moved from restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/SimpleUriInfo.java with 73% similarity]
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfStreamsSubscriptionServiceImplTest.java

similarity index 73%
rename from restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/SimpleUriInfo.java
rename to restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/LocalUriInfo.java
index b964b4ce657f20803a8ebeb5cd5d40d82c78469c..ade99f26726f5fc73a1ae8fc465392fdc06babc4 100644 (file)
@@ -5,7 +5,7 @@
  * 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.restconf.common.util;
+package org.opendaylight.restconf.nb.rfc8040.rests.services.impl;
 
 import java.net.URI;
 import java.util.List;
@@ -20,17 +20,12 @@ import javax.ws.rs.core.UriInfo;
  *
  * @author Thomas Pantelis
  */
-public class SimpleUriInfo implements UriInfo {
+final class LocalUriInfo implements UriInfo {
+    private final MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<>();
     private final String path;
-    private final MultivaluedMap<String, String> queryParams;
 
-    public SimpleUriInfo(String path) {
-        this(path, new MultivaluedHashMap<>());
-    }
-
-    public SimpleUriInfo(String path, MultivaluedMap<String, String> queryParams) {
-        this.path = path;
-        this.queryParams = queryParams;
+    LocalUriInfo() {
+        path = "/";
     }
 
     @Override
@@ -39,7 +34,7 @@ public class SimpleUriInfo implements UriInfo {
     }
 
     @Override
-    public String getPath(boolean decode) {
+    public String getPath(final boolean decode) {
         return path;
     }
 
@@ -49,7 +44,7 @@ public class SimpleUriInfo implements UriInfo {
     }
 
     @Override
-    public List<PathSegment> getPathSegments(boolean decode) {
+    public List<PathSegment> getPathSegments(final boolean decode) {
         throw new UnsupportedOperationException();
     }
 
@@ -75,7 +70,7 @@ public class SimpleUriInfo implements UriInfo {
 
     @Override
     public URI getBaseUri() {
-        return URI.create("");
+        return UriBuilder.fromUri("http://localhost:8181").build();
     }
 
     @Override
@@ -89,7 +84,7 @@ public class SimpleUriInfo implements UriInfo {
     }
 
     @Override
-    public MultivaluedMap<String, String> getPathParameters(boolean decode) {
+    public MultivaluedMap<String, String> getPathParameters(final boolean decode) {
         return getPathParameters();
     }
 
@@ -99,7 +94,7 @@ public class SimpleUriInfo implements UriInfo {
     }
 
     @Override
-    public MultivaluedMap<String, String> getQueryParameters(boolean decode) {
+    public MultivaluedMap<String, String> getQueryParameters(final boolean decode) {
         return getQueryParameters();
     }
 
@@ -109,7 +104,7 @@ public class SimpleUriInfo implements UriInfo {
     }
 
     @Override
-    public List<String> getMatchedURIs(boolean decode) {
+    public List<String> getMatchedURIs(final boolean decode) {
         return getMatchedURIs();
     }
 
@@ -119,12 +114,12 @@ public class SimpleUriInfo implements UriInfo {
     }
 
     @Override
-    public URI resolve(URI uri) {
+    public URI resolve(final URI uri) {
         return uri;
     }
 
     @Override
-    public URI relativize(URI uri) {
+    public URI relativize(final URI uri) {
         return uri;
     }
 }
index 8accfc7922f81cd18bd55a8aa011b6385f101e87..2d4809c4e63644598f09e3c3d07419abf2fa8234 100644 (file)
@@ -19,7 +19,6 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Map;
 import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -35,7 +34,6 @@ import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
 import org.opendaylight.mdsal.dom.api.DOMNotificationService;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.common.util.SimpleUriInfo;
 import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
@@ -87,6 +85,7 @@ public class RestconfStreamsSubscriptionServiceImplTest {
                 .when(dataBroker).getExtensions();
 
         doReturn(new MultivaluedHashMap<>()).when(uriInfo).getQueryParameters();
+        // FIXME: just mock UriInfo here
         doReturn(new LocalUriInfo().getBaseUriBuilder()).when(uriInfo).getBaseUriBuilder();
         doReturn(new URI("http://127.0.0.1/" + URI)).when(uriInfo).getAbsolutePath();
         schemaHandler.onModelContextUpdated(
@@ -95,17 +94,6 @@ public class RestconfStreamsSubscriptionServiceImplTest {
         configurationSse = new Configuration(0, 100, 10, true);
     }
 
-    private static class LocalUriInfo extends SimpleUriInfo {
-        LocalUriInfo() {
-            super("/");
-        }
-
-        @Override
-        public URI getBaseUri() {
-            return UriBuilder.fromUri("http://localhost:8181").build();
-        }
-    }
-
     @BeforeClass
     public static void setUpBeforeTest() {
         final String name =