Remove RestconfConstants.IDENTIFIER 61/96861/2
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 9 Jul 2021 23:02:58 +0000 (01:02 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 9 Jul 2021 23:04:26 +0000 (01:04 +0200)
This constant is not really useful, as it is referenced once in
production code and once in testing. Inline the definitions, as we
really want to make an explicit assertion in tests.

Change-Id: I7fd7a6e64562cb054b15011c1aad7624c47fea3d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/spi/AbstractIdentifierAwareJaxRsProvider.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/RestconfConstants.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/AbstractBodyReaderTest.java

index 0d62356b7b67c424a237c6edba0bc836e3f6ee78..730046988e8012af1d910f8ab3a943f96861a263 100644 (file)
@@ -24,7 +24,6 @@ import javax.ws.rs.ext.MessageBodyReader;
 import org.opendaylight.mdsal.dom.api.DOMMountPointService;
 import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
-import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 
@@ -83,7 +82,7 @@ public abstract class AbstractIdentifierAwareJaxRsProvider<T> implements Message
 
 
     private String getIdentifier() {
-        return this.uriInfo.getPathParameters(false).getFirst(RestconfConstants.IDENTIFIER);
+        return this.uriInfo.getPathParameters(false).getFirst("identifier");
     }
 
     private InstanceIdentifierContext<?> getInstanceIdentifierContext() {
index f63cb94cad2c3a3332528a4567bb4e02743695ea..93f6e754baec56e5d213c09c00a629351b719ca6 100644 (file)
@@ -11,16 +11,14 @@ import com.google.common.base.Splitter;
 
 /**
  * Util class for Restconf constants.
- *
  */
 public final class RestconfConstants {
     public static final String MOUNT = "yang-ext:mount";
-    public static final String IDENTIFIER = "identifier";
     public static final Splitter SLASH_SPLITTER = Splitter.on('/');
     public static final String BASE_URI_PATTERN = "rests";
     public static final String NOTIF = "notif";
 
     private RestconfConstants() {
-        throw new UnsupportedOperationException("Util class");
+        // Hidden on purpose
     }
 }
\ No newline at end of file
index 7d2fee7327d37da690763e6169fa0698eb2c0aba..106345a5ecf4a00cbd0362dadce96234c379d093 100644 (file)
@@ -15,7 +15,6 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
 import javax.ws.rs.core.MediaType;
@@ -39,7 +38,6 @@ import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.TestUtils;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.spi.AbstractIdentifierAwareJaxRsProvider;
-import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 
@@ -76,7 +74,7 @@ public abstract class AbstractBodyReaderTest {
         final MultivaluedMap<String, String> pathParm = new MultivaluedHashMap<>(1);
 
         if (!identifier.isEmpty()) {
-            pathParm.put(RestconfConstants.IDENTIFIER, Collections.singletonList(identifier));
+            pathParm.put("identifier", List.of(identifier));
         }
 
         when(uriInfoMock.getPathParameters()).thenReturn(pathParm);