ac466579fd05258c8ebb221f98d075cec64f997e
[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.example;
23
24 import java.util.Arrays;
25 import org.mockito.Mockito;
26 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.NetconfAccessorImpl;
27 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.NetconfCommunicatorManager;
28 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.DomContext;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.AvailableCapabilitiesBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapabilityBuilder;
34 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
35 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
36 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
37
38 public class TestNetconfHelper extends Mockito {
39
40     /**
41      * Provide a test node.
42      * @param nodeIdString
43      */
44     public static Node getTestNode(NodeId nodeId, String capabilityString) {
45         NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder();
46         netconfNodeBuilder.setConnectionStatus(ConnectionStatus.Connected);
47         AvailableCapabilityBuilder availableCapabilityBuilder = new AvailableCapabilityBuilder();
48         availableCapabilityBuilder.setCapability(capabilityString);
49         AvailableCapabilitiesBuilder availableCapabilitesBuilder = new AvailableCapabilitiesBuilder();
50         availableCapabilitesBuilder.setAvailableCapability(Arrays.asList(availableCapabilityBuilder.build()));
51         netconfNodeBuilder.setAvailableCapabilities(availableCapabilitesBuilder.build());
52         NetconfNode rootNodeNetconf = netconfNodeBuilder.build();
53
54         NodeBuilder nodeBuilder = new NodeBuilder();
55
56         nodeBuilder.addAugmentation(rootNodeNetconf);
57         nodeBuilder.setNodeId(nodeId);
58         return nodeBuilder.build();
59     }
60
61     /**
62      * Provide a test NetconfAccessorImpl
63      * @return object NetconfAccessorImpl
64      */
65     public static NetconfAccessorImpl getNetconfAcessorImpl() {
66         NetconfCommunicatorManager netconfCommunicatorManager = mock(NetconfCommunicatorManager.class);
67         DomContext domContext = mock(DomContext.class);
68         String nodeIdString = "Test";
69         String capabilityStringForNetworkElement = "network-element";
70         NodeId nodeId = new NodeId(nodeIdString);
71         NetconfNode testNode = TestNetconfHelper.getTestNode(nodeId, capabilityStringForNetworkElement)
72                 .augmentation(NetconfNode.class);
73
74         NetconfAccessorImpl netconfAccessor =
75                 new NetconfAccessorImpl(nodeId, testNode, netconfCommunicatorManager, domContext);
76         return netconfAccessor;
77     }
78 }