diff options
author | Michael Dürre <michael.duerre@highstreet-technologies.com> | 2022-07-20 09:32:50 +0200 |
---|---|---|
committer | Michael Dürre <michael.duerre@highstreet-technologies.com> | 2022-07-21 12:38:52 +0200 |
commit | 25423c50e504676f15c7a57c03aad40bfc35c7e6 (patch) | |
tree | 811649e2ec44e0332e601c6563e00e914d355b9a /sdnr/wt/netconfnode-state-service/model/src | |
parent | cea47224b7b6afdd7b3d3ead8d08baf46eadc575 (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/src')
-rw-r--r-- | sdnr/wt/netconfnode-state-service/model/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestCapabilities.java | 93 |
1 files changed, 93 insertions, 0 deletions
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(); + + } +} |