Remove Rfc8040.Capabilities 98/98098/1
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 24 Oct 2021 10:23:05 +0000 (12:23 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 24 Oct 2021 11:13:30 +0000 (13:13 +0200)
We have proper constructs encapsulating the capabilities described
by these constants. There is no need for centralization of constants,
as each parameter now exposes capabilityUri() anyway.

JIRA: NETCONF-773
Change-Id: I1ec8b385c76a74987420c39dd7368c9fa083d841
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/Rfc8040.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/mapping/RestconfMappingNodeUtil.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/mapping/RestconfMappingNodeUtilTest.java

index 2a61ee16060d8c04fcc9d4aefce7cd7061c38f93..0ac9905818da4351e9c1870e9cb3cb2bcfa8f4f5 100644 (file)
@@ -46,38 +46,6 @@ public final class Rfc8040 {
         return RESTCONF_STATE_STREAMS.node(arg);
     }
 
-    /**
-     * Constants for <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-11.4">RESTCONF Capability URNs</a>.
-     */
-    public static final class Capabilities {
-        /**
-         * Support for <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.2">depth</a> Query Parameter.
-         */
-        public static final String DEPTH = "urn:ietf:params:restconf:capability:depth:1.0";
-        /**
-         * Support for <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.3">fields</a> Query Parameter.
-         */
-        public static final String FIELDS = "urn:ietf:params:restconf:capability:fields:1.0";
-        /**
-         * Support for <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.4">filter</a> Query Parameter.
-         */
-        public static final String FILTER = "urn:ietf:params:restconf:capability:filter:1.0";
-        /**
-         * Support for <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.7">start-time</a>
-         * and <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.7">stop-time</a> Query Parameters.
-         */
-        public static final String REPLAY = "urn:ietf:params:restconf:capability:replay:1.0";
-        /**
-         * Support for
-         * <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.9">with-defaults</a> Query Parameter.
-         */
-        public static final String WITH_DEFAULTS = "urn:ietf:params:restconf:capability:with-defaults:1.0";
-
-        private Capabilities() {
-            // Hidden on purpose
-        }
-    }
-
     /**
      * Constants for ietf-yang-library model.
      */
index 4f32018fa90d5f3dfa6874c79cf8e003eaea7174..6f6d522ae52f3a5a626b46a723116c76c83a020c 100644 (file)
@@ -18,7 +18,11 @@ import java.time.format.DateTimeFormatter;
 import java.util.Collection;
 import java.util.Optional;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
+import org.opendaylight.restconf.nb.rfc8040.AbstractReplayParameter;
+import org.opendaylight.restconf.nb.rfc8040.DepthParameter;
+import org.opendaylight.restconf.nb.rfc8040.FieldsParameter;
+import org.opendaylight.restconf.nb.rfc8040.FilterParameter;
+import org.opendaylight.restconf.nb.rfc8040.WithDefaultsParameter;
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.IdentifierCodec;
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.RestconfState;
@@ -75,11 +79,11 @@ public final class RestconfMappingNodeUtil {
                 .withNodeIdentifier(new NodeIdentifier(Capabilities.QNAME))
                 .withChild(Builders.<String>orderedLeafSetBuilder()
                     .withNodeIdentifier(new NodeIdentifier(CAPABILITY_QNAME))
-                    .withChildValue(Rfc8040.Capabilities.DEPTH)
-                    .withChildValue(Rfc8040.Capabilities.FIELDS)
-                    .withChildValue(Rfc8040.Capabilities.FILTER)
-                    .withChildValue(Rfc8040.Capabilities.REPLAY)
-                    .withChildValue(Rfc8040.Capabilities.WITH_DEFAULTS)
+                    .withChildValue(DepthParameter.capabilityUri().toString())
+                    .withChildValue(FieldsParameter.capabilityUri().toString())
+                    .withChildValue(FilterParameter.capabilityUri().toString())
+                    .withChildValue(AbstractReplayParameter.capabilityUri().toString())
+                    .withChildValue(WithDefaultsParameter.capabilityUri().toString())
                     .build())
                 .build())
             .build();
index 52c89e5eb964d5c56c92051c3cce447727a2bdfc..71fdfeaa41713d093482eb4f4580b97860e2c4e6 100644 (file)
@@ -7,6 +7,9 @@
  */
 package org.opendaylight.restconf.nb.rfc8040.utils.mapping;
 
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsInAnyOrder;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -23,7 +26,6 @@ import java.util.List;
 import java.util.Map;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
 import org.opendaylight.restconf.nb.rfc8040.Rfc8040.IetfYangLibrary;
 import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
@@ -101,11 +103,13 @@ public class RestconfMappingNodeUtilTest {
                 }
             }
         }
-        assertTrue(listOfValues.contains(Rfc8040.Capabilities.DEPTH));
-        assertTrue(listOfValues.contains(Rfc8040.Capabilities.FIELDS));
-        assertTrue(listOfValues.contains(Rfc8040.Capabilities.FILTER));
-        assertTrue(listOfValues.contains(Rfc8040.Capabilities.REPLAY));
-        assertTrue(listOfValues.contains(Rfc8040.Capabilities.WITH_DEFAULTS));
+
+        assertThat(listOfValues, containsInAnyOrder(
+            equalTo("urn:ietf:params:restconf:capability:depth:1.0"),
+            equalTo("urn:ietf:params:restconf:capability:fields:1.0"),
+            equalTo("urn:ietf:params:restconf:capability:filter:1.0"),
+            equalTo("urn:ietf:params:restconf:capability:replay:1.0"),
+            equalTo("urn:ietf:params:restconf:capability:with-defaults:1.0")));
     }
 
     @Test