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