97c1d20bd6ead72bcbb3bb3bafb7d89406808cf2
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP : ccsdk features
4  * ================================================================================
5  * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
6  * All rights reserved.
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
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20  *
21  */
22 package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test;
23
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;
34
35 public class TestCapabilites {
36
37     private static final String CAPABILITYSTRING = "network-element";
38
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();
41
42     private static Capabilities capabilites;
43     private static Capabilities uacapabilites;
44
45     @BeforeClass
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);
54     }
55
56     @Test
57     public void testAvailableCapabilites() {
58         boolean result = capabilites.isSupportingNamespaceAndRevision("network-element", null);
59         assertTrue(result);
60     }
61
62     @Test
63     public void testAvailableCapabilitesNotThere() {
64         boolean result = capabilites.isSupportingNamespaceAndRevision(CAPABILITYSTRING+"xy", null);
65         assertFalse(result);
66     }
67
68     @Test
69     public void testUnavailableCapabilites() {
70         assertTrue(uacapabilites.getCapabilities().isEmpty());
71     }
72
73     @Test
74     public void testAvailableCapabilitesQName() {
75         boolean result = capabilites.isSupportingNamespace(QNAMENETWORKELEMENET);
76         assertFalse(result);
77     }
78     @Test
79     public void testSupportsRevision() {
80         boolean result = capabilites.isSupportingNamespaceAndRevision(QNAMENETWORKELEMENET);
81         assertFalse(result);
82     }
83     @Test
84     public void testGetRevision() {
85         String revisionString = capabilites.getRevisionForNamespace(QNAMENETWORKELEMENET);
86         boolean result = Capabilities.isNamespaceSupported(revisionString);
87         assertFalse(result);
88
89     }
90 }