2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test;
24 import static org.junit.Assert.assertFalse;
25 import static org.junit.Assert.assertTrue;
26 import org.junit.BeforeClass;
27 import org.junit.Test;
28 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
29 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.example.TestNetconfHelper;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
31 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
32 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
33 import org.opendaylight.yangtools.yang.common.QName;
35 public class TestCapabilites {
37 private static final String CAPABILITYSTRING = "network-element";
39 private static final QName QNAMECOREMODEL = QName.create("urn:onf:params:xml:ns:yang:core-model", "2017-03-20", "core-model").intern();
40 private static final QName QNAMENETWORKELEMENET = QName.create(QNAMECOREMODEL, CAPABILITYSTRING).intern();
42 private static Capabilities capabilites;
43 private static Capabilities uacapabilites;
46 public static void before() {
47 String nodeIdString = "Test";
48 NodeId nodeId = new NodeId(nodeIdString);
49 String capabilityString = "network-element";
50 Node node = TestNetconfHelper.getTestNode(nodeId,capabilityString);
51 NetconfNode netconfNode = node.augmentation(NetconfNode.class);
52 capabilites = Capabilities.getAvailableCapabilities(netconfNode);
53 uacapabilites = Capabilities.getUnavailableCapabilities(netconfNode);
57 public void testAvailableCapabilites() {
58 boolean result = capabilites.isSupportingNamespaceAndRevision("network-element", null);
63 public void testAvailableCapabilitesNotThere() {
64 boolean result = capabilites.isSupportingNamespaceAndRevision(CAPABILITYSTRING+"xy", null);
69 public void testUnavailableCapabilites() {
70 assertTrue(uacapabilites.getCapabilities().isEmpty());
74 public void testAvailableCapabilitesQName() {
75 boolean result = capabilites.isSupportingNamespace(QNAMENETWORKELEMENET);
79 public void testSupportsRevision() {
80 boolean result = capabilites.isSupportingNamespaceAndRevision(QNAMENETWORKELEMENET);
84 public void testGetRevision() {
85 String revisionString = capabilites.getRevisionForNamespace(QNAMENETWORKELEMENET);
86 boolean result = Capabilities.isNamespaceSupported(revisionString);