Remove LocalUriInfo 82/103982/2
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 11 Jan 2023 00:39:51 +0000 (01:39 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 11 Jan 2023 12:23:40 +0000 (13:23 +0100)
This is a rather shortcut to jax-rs, ditch the indirection.

Change-Id: I4bf70723c3cc58396c32df3db24d3618759e7cfe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/LocalUriInfo.java [deleted file]
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfStreamsSubscriptionServiceImplTest.java

diff --git a/restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/LocalUriInfo.java b/restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/LocalUriInfo.java
deleted file mode 100644 (file)
index ade99f2..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2017 Inocybe Technologies and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.nb.rfc8040.rests.services.impl;
-
-import java.net.URI;
-import java.util.List;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.PathSegment;
-import javax.ws.rs.core.UriBuilder;
-import javax.ws.rs.core.UriInfo;
-
-/**
- * Simple implementation of the {@link UriInfo} interface.
- *
- * @author Thomas Pantelis
- */
-final class LocalUriInfo implements UriInfo {
-    private final MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<>();
-    private final String path;
-
-    LocalUriInfo() {
-        path = "/";
-    }
-
-    @Override
-    public String getPath() {
-        return path;
-    }
-
-    @Override
-    public String getPath(final boolean decode) {
-        return path;
-    }
-
-    @Override
-    public List<PathSegment> getPathSegments() {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public List<PathSegment> getPathSegments(final boolean decode) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public URI getRequestUri() {
-        return URI.create(path);
-    }
-
-    @Override
-    public UriBuilder getRequestUriBuilder() {
-        return UriBuilder.fromUri(getRequestUri());
-    }
-
-    @Override
-    public URI getAbsolutePath() {
-        return getRequestUri();
-    }
-
-    @Override
-    public UriBuilder getAbsolutePathBuilder() {
-        return UriBuilder.fromUri(getAbsolutePath());
-    }
-
-    @Override
-    public URI getBaseUri() {
-        return UriBuilder.fromUri("http://localhost:8181").build();
-    }
-
-    @Override
-    public UriBuilder getBaseUriBuilder() {
-        return UriBuilder.fromUri(getBaseUri());
-    }
-
-    @Override
-    public MultivaluedMap<String, String> getPathParameters() {
-        return new MultivaluedHashMap<>();
-    }
-
-    @Override
-    public MultivaluedMap<String, String> getPathParameters(final boolean decode) {
-        return getPathParameters();
-    }
-
-    @Override
-    public MultivaluedMap<String, String> getQueryParameters() {
-        return queryParams;
-    }
-
-    @Override
-    public MultivaluedMap<String, String> getQueryParameters(final boolean decode) {
-        return getQueryParameters();
-    }
-
-    @Override
-    public List<String> getMatchedURIs() {
-        return List.of();
-    }
-
-    @Override
-    public List<String> getMatchedURIs(final boolean decode) {
-        return getMatchedURIs();
-    }
-
-    @Override
-    public List<Object> getMatchedResources() {
-        return List.of();
-    }
-
-    @Override
-    public URI resolve(final URI uri) {
-        return uri;
-    }
-
-    @Override
-    public URI relativize(final URI uri) {
-        return uri;
-    }
-}
index 6f52bdbdf8729433e0236397667efd3f8d410105..71ac4b9e45dbc65cb3d1127d958e7b03cd9f02ba 100644 (file)
@@ -19,6 +19,7 @@ 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;
@@ -85,8 +86,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(UriBuilder.fromUri("http://localhost:8181")).when(uriInfo).getBaseUriBuilder();
         doReturn(new URI("http://127.0.0.1/" + URI)).when(uriInfo).getAbsolutePath();
 
         modelContext = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/notifications"));