Migrate netconf-topology to new transport
[netconf.git] / apps / callhome-provider / src / test / java / org / opendaylight / netconf / callhome / mount / CallHomeMountFactoryTest.java
similarity index 93%
rename from apps/callhome-provider/src/test/java/org/opendaylight/netconf/callhome/mount/CallHomeMountDispatcherTest.java
rename to apps/callhome-provider/src/test/java/org/opendaylight/netconf/callhome/mount/CallHomeMountFactoryTest.java
index d3c3c4d375ba82b6982b882531c6752e4e8bf9aa..52746952d3f0bb381b8b5be03df423a44440c7e5 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.netconf.callhome.mount;
 
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doReturn;
@@ -16,9 +17,9 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
 import io.netty.util.concurrent.EventExecutor;
-import io.netty.util.concurrent.Future;
 import java.net.InetSocketAddress;
 import java.net.UnknownHostException;
+import java.util.concurrent.ExecutionException;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
@@ -28,7 +29,6 @@ import org.opendaylight.mdsal.dom.api.DOMMountPointService;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
 import org.opendaylight.netconf.callhome.protocol.CallHomeChannelActivator;
 import org.opendaylight.netconf.callhome.protocol.CallHomeProtocolSessionContext;
-import org.opendaylight.netconf.client.NetconfClientSession;
 import org.opendaylight.netconf.client.NetconfClientSessionListener;
 import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
 import org.opendaylight.netconf.client.conf.NetconfClientConfigurationBuilder;
@@ -39,14 +39,14 @@ import org.opendaylight.netconf.topology.spi.NetconfClientConfigurationBuilderFa
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 
-public class CallHomeMountDispatcherTest {
+public class CallHomeMountFactoryTest {
     private String topologyId;
     private EventExecutor mockExecutor;
     private ScheduledThreadPool mockKeepAlive;
     private ThreadPool mockProcessingExecutor;
     private SchemaResourceManager mockSchemaRepoProvider;
 
-    private CallHomeMountDispatcher instance;
+    private CallHomeMountFactory instance;
     private DataBroker mockDataBroker;
     private DOMMountPointService mockMount;
 
@@ -71,7 +71,7 @@ public class CallHomeMountDispatcherTest {
         mockBuilderFactory = mock(NetconfClientConfigurationBuilderFactory .class);
         mockBaseSchemas = mock(BaseNetconfSchemas.class);
 
-        instance = new CallHomeMountDispatcher(topologyId, mockExecutor, mockKeepAlive,
+        instance = new CallHomeMountFactory(topologyId, mockExecutor, mockKeepAlive,
                 mockProcessingExecutor, mockSchemaRepoProvider, mockBaseSchemas, mockDataBroker, mockMount,
                 mockBuilderFactory) {
             @Override
@@ -115,14 +115,15 @@ public class CallHomeMountDispatcherTest {
     }
 
     @Test
-    public void noSessionIsCreatedWithoutAContextAvailableForAGivenAddress() {
+    public void noSessionIsCreatedWithoutAContextAvailableForAGivenAddress() throws Exception {
         // given
         final InetSocketAddress someAddress = InetSocketAddress.createUnresolved("1.2.3.4", 123);
         final NetconfClientConfiguration someCfg = someConfiguration(someAddress);
         // when
-        final Future<NetconfClientSession> future = instance.createClient(someCfg);
+        final var future = instance.createClient(someCfg);
         // then
-        assertFalse(future.isSuccess());
+        assertNotNull(future);
+        assertThrows(ExecutionException.class, future::get);
     }
 
     @Test