From 25423c50e504676f15c7a57c03aad40bfc35c7e6 Mon Sep 17 00:00:00 2001 From: Michael Dürre Date: Wed, 20 Jul 2022 09:32:50 +0200 Subject: migrate sdnr features to sulfur MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix sdnr code for sulfur Issue-ID: CCSDK-3692 Signed-off-by: Michael Dürre Change-Id: I0a62ade424bb978222e7ce6450215fb327f957b7 Signed-off-by: Michael Dürre --- sdnr/wt/netconfnode-state-service/model/pom.xml | 9 ++- .../test/TestCapabilities.java | 93 ++++++++++++++++++++++ 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 sdnr/wt/netconfnode-state-service/model/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestCapabilities.java (limited to 'sdnr/wt/netconfnode-state-service/model') 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======================================================= ~ --> + 4.0.0 org.onap.ccsdk.parent binding-parent - 2.4.0 + 2.4.1-SNAPSHOT @@ -64,6 +65,12 @@ ${project.groupId} sdnr-wt-data-provider-model ${project.version} + provided + + + com.google.code.findbugs + annotations + provided 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 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 acapList = + Arrays.asList(new AvailableCapabilityBuilder().setCapability("(test-capability?revision=2022-11-03)test").build()); + AvailableCapabilitiesBuilder acb = new AvailableCapabilitiesBuilder().setAvailableCapability(acapList); + return acb.build(); + + } +} -- cgit 1.2.3-korg