Merge "Bug 6936 - Fix post request"
[netconf.git] / netconf / netconf-console / src / main / java / org / opendaylight / netconf / console / commands / NetconfShowDeviceCommand.java
index f5bf7a5c07f46628209fdfd49f864f2e799c76b9..46d36dceb53e39a5d078bacafd8aa3a60f7f1caf 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.netconf.console.commands;
 
+import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Strings;
 import java.util.List;
 import java.util.Map;
@@ -28,19 +29,28 @@ public class NetconfShowDeviceCommand extends AbstractAction {
         this.service = service;
     }
 
+    @VisibleForTesting
+    NetconfShowDeviceCommand(final NetconfCommands service, final String deviceId, final String deviceIp,
+                             final String devicePort) {
+        this.service = service;
+        this.deviceId = deviceId;
+        this.deviceIp = deviceIp;
+        this.devicePort = devicePort;
+    }
+
     @Option(name = "-id",
             aliases = { "--identifier" },
             description = "Node Identifier of the netconf device",
             required = false,
             multiValued = false)
-    private String deviceId = "";
+    private String deviceId;
 
     @Option(name = "-i",
             aliases = { "--ipaddress" },
             description = "IP address of the netconf device",
             required = false,
             multiValued = false)
-    private String deviceIp = "";
+    private String deviceIp;
 
     @Option(name = "-p",
             aliases = { "--port" },
@@ -52,7 +62,7 @@ public class NetconfShowDeviceCommand extends AbstractAction {
     @Override
     protected Object doExecute() throws Exception {
 
-        if (Strings.isNullOrEmpty(deviceIp) || Strings.isNullOrEmpty(devicePort) && Strings.isNullOrEmpty(deviceId)) {
+        if ((Strings.isNullOrEmpty(deviceIp) || Strings.isNullOrEmpty(devicePort)) && Strings.isNullOrEmpty(deviceId)) {
             return "You must provide either the device Ip and the device Port or the device Id";
         }