Bug 6714 - Use singleton service in clustered netconf topology
[netconf.git] / netconf / netconf-topology-singleton / src / test / java / org / opendaylight / netconf / topology / singleton / impl / TestingRemoteDeviceConnectorImpl.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.netconf.topology.singleton.impl;
10
11 import static org.mockito.Matchers.any;
12 import static org.mockito.Mockito.doReturn;
13
14 import akka.actor.ActorRef;
15 import com.google.common.util.concurrent.Futures;
16 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceHandler;
17 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator;
18 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
19 import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfConnectorDTO;
20 import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
22 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
23
24 class TestingRemoteDeviceConnectorImpl extends RemoteDeviceConnectorImpl {
25
26     private final NetconfDeviceCommunicator communicator;
27     private final RemoteDeviceHandler salFacade;
28
29     TestingRemoteDeviceConnectorImpl(final NetconfTopologySetup netconfTopologyDeviceSetup,
30                                             final RemoteDeviceId remoteDeviceId,
31                                             final NetconfDeviceCommunicator communicator,
32                                             final RemoteDeviceHandler salFacade) {
33         super(netconfTopologyDeviceSetup, remoteDeviceId);
34         this.communicator = communicator;
35         this.salFacade = salFacade;
36     }
37
38     @Override
39     public NetconfConnectorDTO createDeviceCommunicator(final NodeId nodeId, final NetconfNode node,
40                                                         final ActorRef deviceContextActorRef) {
41         final NetconfConnectorDTO connectorDTO = new NetconfConnectorDTO(communicator, salFacade);
42         doReturn(Futures.immediateCheckedFuture(null)).when(communicator).initializeRemoteConnection(any(), any());
43
44         return connectorDTO;
45     }
46
47 }