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.DomContext;
 
  30 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
 
  31 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder;
 
  32 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus;
 
  33 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.AvailableCapabilitiesBuilder;
 
  34 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapabilityBuilder;
 
  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.
 
  45     public static Node getTestNode(NodeId nodeId, String capabilityString) {
 
  46         NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder();
 
  47         netconfNodeBuilder.setConnectionStatus(ConnectionStatus.Connected);
 
  48         AvailableCapabilityBuilder availableCapabilityBuilder = new AvailableCapabilityBuilder();
 
  49         availableCapabilityBuilder.setCapability(capabilityString);
 
  50         AvailableCapabilitiesBuilder availableCapabilitesBuilder = new AvailableCapabilitiesBuilder();
 
  51         availableCapabilitesBuilder.setAvailableCapability(Arrays.asList(availableCapabilityBuilder.build()));
 
  52         netconfNodeBuilder.setAvailableCapabilities(availableCapabilitesBuilder.build());
 
  53         NetconfNode rootNodeNetconf = netconfNodeBuilder.build();
 
  55         NodeBuilder nodeBuilder = new NodeBuilder();
 
  57         nodeBuilder.addAugmentation(rootNodeNetconf);
 
  58         nodeBuilder.setNodeId(nodeId);
 
  59         return nodeBuilder.build();
 
  63      * Provide a test NetconfAccessorImpl
 
  64      * @return object NetconfAccessorImpl
 
  66     public static NetconfAccessorImpl getNetconfAcessorImpl() {
 
  67         NetconfCommunicatorManager netconfCommunicatorManager = mock(NetconfCommunicatorManager.class);
 
  68         DomContext domContext = mock(DomContext.class);
 
  69         String nodeIdString = "Test";
 
  70         String capabilityStringForNetworkElement = "network-element";
 
  71         NodeId nodeId = new NodeId(nodeIdString);
 
  72         NetconfNode testNode = TestNetconfHelper.getTestNode(nodeId, capabilityStringForNetworkElement)
 
  73                 .augmentation(NetconfNode.class);
 
  75         NetconfNodeStateServiceImpl netconfNodeStateService = mock(NetconfNodeStateServiceImpl.class);
 
  76         NetconfAccessorImpl netconfAccessor =
 
  77                 new NetconfAccessorImpl(nodeId, testNode, netconfCommunicatorManager, domContext, netconfNodeStateService);
 
  78         return netconfAccessor;