Integrate MRI projects for Neon
[netconf.git] / netconf / netconf-console / src / test / java / org / opendaylight / netconf / console / commands / NetconfCommandsImplCallsTest.java
index c037c33fe5c8d94ce54f02ec060af9abe39b20e1..ccbcc41a6053f4c6406792332390c57ec9048bb3 100644 (file)
@@ -10,15 +10,16 @@ package org.opendaylight.netconf.console.commands;
 
 import static junit.framework.TestCase.assertEquals;
 import static junit.framework.TestCase.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.isNull;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.MockitoAnnotations.initMocks;
 
-import com.google.common.collect.Lists;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -43,12 +44,13 @@ public class NetconfCommandsImplCallsTest {
     public void testConnectDeviceCommand() throws Exception {
         NetconfConnectDeviceCommand netconfConnectDeviceCommand =
                 new NetconfConnectDeviceCommand(netconfCommands);
-        netconfConnectDeviceCommand.doExecute();
+        netconfConnectDeviceCommand.execute();
         verify(netconfCommands, times(0)).connectDevice(any(), any());
 
-        netconfConnectDeviceCommand = new NetconfConnectDeviceCommand(netconfCommands, "192.168.1.1", "7777");
+        netconfConnectDeviceCommand = new NetconfConnectDeviceCommand(netconfCommands, "192.168.1.1", "7777", "user",
+            "pass");
 
-        netconfConnectDeviceCommand.doExecute();
+        netconfConnectDeviceCommand.execute();
         doNothing().when(netconfCommands).connectDevice(any(), any());
         verify(netconfCommands, times(1)).connectDevice(any(), any());
     }
@@ -57,14 +59,14 @@ public class NetconfCommandsImplCallsTest {
     public void testDisconnectDeviceCommand() throws Exception {
         NetconfDisconnectDeviceCommand netconfDisconnectDeviceCommand =
                 new NetconfDisconnectDeviceCommand(netconfCommands);
-        netconfDisconnectDeviceCommand.doExecute();
+        netconfDisconnectDeviceCommand.execute();
 
-        verify(netconfCommands, times(0)).connectDevice(any(), any());
+        verify(netconfCommands, times(0)).disconnectDevice(any(), any());
 
         netconfDisconnectDeviceCommand = new NetconfDisconnectDeviceCommand(netconfCommands, "deviceId", null, null);
 
         doReturn(true).when(netconfCommands).disconnectDevice(any());
-        netconfDisconnectDeviceCommand.doExecute();
+        netconfDisconnectDeviceCommand.execute();
 
         verify(netconfCommands, times(1)).disconnectDevice(any());
 
@@ -72,7 +74,7 @@ public class NetconfCommandsImplCallsTest {
                 new NetconfDisconnectDeviceCommand(netconfCommands, null, "192.168.1.1", "7777");
 
         doReturn(true).when(netconfCommands).disconnectDevice(any(), any());
-        netconfDisconnectDeviceCommand.doExecute();
+        netconfDisconnectDeviceCommand.execute();
 
         verify(netconfCommands, times(1)).disconnectDevice(any(), any());
     }
@@ -82,7 +84,7 @@ public class NetconfCommandsImplCallsTest {
         final NetconfListDevicesCommand netconfListDeviceCommand = new NetconfListDevicesCommand(netconfCommands);
         doReturn(getDeviceHashMap()).when(netconfCommands).listDevices();
 
-        netconfListDeviceCommand.doExecute();
+        netconfListDeviceCommand.execute();
 
         verify(netconfCommands, times(1)).listDevices();
     }
@@ -90,21 +92,21 @@ public class NetconfCommandsImplCallsTest {
     @Test
     public void testShowDeviceCommand() throws Exception {
         NetconfShowDeviceCommand netconfShowDeviceCommand = new NetconfShowDeviceCommand(netconfCommands);
-        netconfShowDeviceCommand.doExecute();
+        netconfShowDeviceCommand.execute();
 
         verify(netconfCommands, times(0)).showDevice(any());
 
         netconfShowDeviceCommand = new NetconfShowDeviceCommand(netconfCommands, "deviceId", null, null);
 
         doReturn(getDeviceHashMap()).when(netconfCommands).showDevice(any());
-        netconfShowDeviceCommand.doExecute();
+        netconfShowDeviceCommand.execute();
 
         verify(netconfCommands, times(1)).showDevice(any());
 
         netconfShowDeviceCommand = new NetconfShowDeviceCommand(netconfCommands, null, "192.168.1.1", "7777");
 
         doReturn(getDeviceHashMap()).when(netconfCommands).showDevice(any(), any());
-        netconfShowDeviceCommand.doExecute();
+        netconfShowDeviceCommand.execute();
 
         verify(netconfCommands, times(1)).showDevice(any(), any());
     }
@@ -119,22 +121,22 @@ public class NetconfCommandsImplCallsTest {
 
         doReturn("").when(netconfCommands).updateDevice(anyString(), anyString(), anyString(), any());
 
-        netconfUpdateDeviceCommand.doExecute();
+        netconfUpdateDeviceCommand.execute();
 
-        verify(netconfCommands, times(1)).updateDevice(anyString(), anyString(), anyString(),
+        verify(netconfCommands, times(1)).updateDevice(isNull(), isNull(), isNull(),
                 hashMapArgumentCaptor.capture());
 
         assertTrue(hashMapArgumentCaptor.getValue().containsKey(NetconfConsoleConstants.NETCONF_IP));
         assertEquals("192.168.1.1", hashMapArgumentCaptor.getValue().get(NetconfConsoleConstants.NETCONF_IP));
     }
 
-    private HashMap getDeviceHashMap() {
+    private static HashMap<String, Map<String, List<String>>> getDeviceHashMap() {
         final HashMap<String, Map<String, List<String>>> devices = new HashMap<>();
         final HashMap<String, List<String>> deviceMap = new HashMap<>();
-        deviceMap.put(NetconfConsoleConstants.NETCONF_IP, Lists.newArrayList("192.168.1.1"));
-        deviceMap.put(NetconfConsoleConstants.NETCONF_PORT, Lists.newArrayList("7777"));
-        deviceMap.put(NetconfConsoleConstants.STATUS, Lists.newArrayList("connecting"));
-        deviceMap.put(NetconfConsoleConstants.AVAILABLE_CAPABILITIES, Lists.newArrayList("cap1", "cap2", "cap3"));
+        deviceMap.put(NetconfConsoleConstants.NETCONF_IP, Arrays.asList("192.168.1.1"));
+        deviceMap.put(NetconfConsoleConstants.NETCONF_PORT, Arrays.asList("7777"));
+        deviceMap.put(NetconfConsoleConstants.STATUS, Arrays.asList("connecting"));
+        deviceMap.put(NetconfConsoleConstants.AVAILABLE_CAPABILITIES, Arrays.asList("cap1", "cap2", "cap3"));
         devices.put("device", deviceMap);
         return devices;
     }