summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/netconfnode-state-service/model
diff options
context:
space:
mode:
authorMichael Dürre <michael.duerre@highstreet-technologies.com>2022-07-20 09:32:50 +0200
committerMichael Dürre <michael.duerre@highstreet-technologies.com>2022-07-21 12:38:52 +0200
commit25423c50e504676f15c7a57c03aad40bfc35c7e6 (patch)
tree811649e2ec44e0332e601c6563e00e914d355b9a /sdnr/wt/netconfnode-state-service/model
parentcea47224b7b6afdd7b3d3ead8d08baf46eadc575 (diff)
migrate sdnr features to sulfur
fix sdnr code for sulfur Issue-ID: CCSDK-3692 Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com> Change-Id: I0a62ade424bb978222e7ce6450215fb327f957b7 Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/netconfnode-state-service/model')
-rw-r--r--sdnr/wt/netconfnode-state-service/model/pom.xml9
-rw-r--r--sdnr/wt/netconfnode-state-service/model/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestCapabilities.java93
2 files changed, 101 insertions, 1 deletions
diff --git a/sdnr/wt/netconfnode-state-service/model/pom.xml b/sdnr/wt/netconfnode-state-service/model/pom.xml
index 8f15f3e24..e1b2a42cf 100644
--- a/sdnr/wt/netconfnode-state-service/model/pom.xml
+++ b/sdnr/wt/netconfnode-state-service/model/pom.xml
@@ -22,13 +22,14 @@
~ ============LICENSE_END=======================================================
~
-->
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.parent</groupId>
<artifactId>binding-parent</artifactId>
- <version>2.4.0</version>
+ <version>2.4.1-SNAPSHOT</version>
<relativePath/>
</parent>
@@ -64,6 +65,12 @@
<groupId>${project.groupId}</groupId>
<artifactId>sdnr-wt-data-provider-model</artifactId>
<version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>annotations</artifactId>
+ <scope>provided</scope>
</dependency>
</dependencies>
diff --git a/sdnr/wt/netconfnode-state-service/model/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestCapabilities.java b/sdnr/wt/netconfnode-state-service/model/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestCapabilities.java
new file mode 100644
index 000000000..0471460a8
--- /dev/null
+++ b/sdnr/wt/netconfnode-state-service/model/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestCapabilities.java
@@ -0,0 +1,93 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2022 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import java.util.Arrays;
+import java.util.List;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.AvailableCapabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.AvailableCapabilitiesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.UnavailableCapabilitiesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapabilityBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.unavailable.capabilities.UnavailableCapability;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.unavailable.capabilities.UnavailableCapabilityBuilder;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
+
+public class TestCapabilities {
+
+ @Test
+ public void testavailableCapabilities() {
+
+ NetconfNodeBuilder nnodeBuilder = new NetconfNodeBuilder().setAvailableCapabilities(getAvailableCapabilities());
+ Capabilities avcapabilities = Capabilities.getAvailableCapabilities(nnodeBuilder.build());
+
+ assertTrue(avcapabilities != null);
+
+ }
+
+ @Test
+ public void testunavailableCapabilities() {
+
+ List<UnavailableCapability> ucapList =
+ Arrays.asList(new UnavailableCapabilityBuilder().setCapability("(test-unavailable-capability?revision=2022-11-03)test").build());
+ UnavailableCapabilitiesBuilder ucb = new UnavailableCapabilitiesBuilder().setUnavailableCapability(ucapList);
+
+ NetconfNodeBuilder nnodeBuilder = new NetconfNodeBuilder().setUnavailableCapabilities(ucb.build());
+ Capabilities uavcapabilities = Capabilities.getUnavailableCapabilities(nnodeBuilder.build());
+ assert (uavcapabilities != null);
+
+ }
+
+ @Test
+ public void testNameSpaceRevision() {
+ QName qname = QName.create("test-capability", "test", Revision.of("2022-11-03"));
+ NetconfNodeBuilder nnodeBuilder = new NetconfNodeBuilder().setAvailableCapabilities(getAvailableCapabilities());
+ Capabilities avcapabilities = Capabilities.getAvailableCapabilities(nnodeBuilder.build());
+
+ NetconfAccessor accessor = mock(NetconfAccessor.class);
+ when(accessor.getCapabilites()).thenReturn(avcapabilities);
+ assertEquals("2022-11-03", accessor.getCapabilites().getRevisionForNamespace(qname));
+ assertEquals("test-capability?2022-11-03", Capabilities.getNamespaceAndRevisionAsString(qname));
+ assertTrue(accessor.getCapabilites().isSupportingNamespace(qname));
+ assertTrue(accessor.getCapabilites().isSupportingNamespace("test-capability"));
+ assertTrue(accessor.getCapabilites().isSupportingNamespaceAndRevision(qname));
+
+ }
+
+ private AvailableCapabilities getAvailableCapabilities() {
+
+ List<AvailableCapability> acapList =
+ Arrays.asList(new AvailableCapabilityBuilder().setCapability("(test-capability?revision=2022-11-03)test").build());
+ AvailableCapabilitiesBuilder acb = new AvailableCapabilitiesBuilder().setAvailableCapability(acapList);
+ return acb.build();
+
+ }
+}