Fix sonar coverage issues 09/13009/1
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Mon, 18 Sep 2017 06:58:09 +0000 (12:28 +0530)
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Mon, 18 Sep 2017 06:58:09 +0000 (12:28 +0530)
CLI-43

Change-Id: I7dc674db9ffc0bd2281003b3a680e52a0af9baab
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
framework/src/main/java/org/onap/cli/fw/input/cache/OnapCommandParameterCache.java
framework/src/test/java/org/onap/cli/fw/error/OnapCommandErrorTest.java
main/src/test/java/org/onap/cli/main/OnapCliMainTest.java

index f8afd54..1d9cb54 100644 (file)
@@ -95,7 +95,7 @@ public class OnapCommandParameterCache {
         try {
             OnapCommandUtils.persistParams(params, this.profileName);
         } catch (OnapCommandPersistProfileFailed e) {
-            throw new RuntimeException(e);
+            throw new RuntimeException(e);   // NOSONAR
         }
     }
 
@@ -104,7 +104,7 @@ public class OnapCommandParameterCache {
         try {
             params = OnapCommandUtils.loadParamFromCache(this.profileName);
         } catch (OnapCommandLoadProfileFailed e) {
-            throw new RuntimeException(e);
+            throw new RuntimeException(e);   // NOSONAR
         }
 
         for (Param p : params) {
index dd42cdc..704d470 100644 (file)
@@ -275,6 +275,10 @@ public class OnapCommandErrorTest {
         OnapCommandPersistProfileFailed failed = new OnapCommandPersistProfileFailed("error");
 
         assertEquals("0x1302::Failed to persist profile details, error", failed.getMessage());
+
+        failed = new OnapCommandPersistProfileFailed(new Exception("error"));
+
+        assertEquals("0x1302::Failed to persist profile details, error", failed.getMessage());
     }
 
 
@@ -283,5 +287,9 @@ public class OnapCommandErrorTest {
         OnapCommandLoadProfileFailed failed = new OnapCommandLoadProfileFailed("error");
 
         assertEquals("0x1301::Failed to load profile details, error", failed.getMessage());
+
+        failed = new OnapCommandLoadProfileFailed(new Exception("error"));
+
+        assertEquals("0x1301::Failed to load profile details, error", failed.getMessage());
     }
 }
index f052cbd..092ef8d 100644 (file)
@@ -160,43 +160,71 @@ public class OnapCliMainTest {
         } catch (Exception e) {
         }
 
-        mockConsole("microservice-create -h");
+        cli = new OnapCli(new String[] {});
+        mockConsole("sample-test -h");
 
         try {
             cli.handleInteractive();
         } catch (Exception e) {
         }
 
+        cli = new OnapCli(new String[] {});
+        mockConsole("use cli-1.0");
+        try {
+            cli.handleInteractive();
+        } catch (Exception e) {
+        }
+
+        cli = new OnapCli(new String[] {});
         mockConsole("set a=b");
         try {
             cli.handleInteractive();
         } catch (Exception e) {
         }
 
+        cli = new OnapCli(new String[] {});
+        mockConsole("set");
+        try {
+            cli.handleInteractive();
+        } catch (Exception e) {
+        }
+
+        cli = new OnapCli(new String[] {});
+        mockConsole("set a=");
+        try {
+            cli.handleInteractive();
+        } catch (Exception e) {
+        }
+
+        cli = new OnapCli(new String[] {});
         mockConsole("unset a");
         try {
             cli.handleInteractive();
         } catch (Exception e) {
         }
 
+        cli = new OnapCli(new String[] {});
         mockConsole("profile test");
         try {
             cli.handleInteractive();
         } catch (Exception e) {
         }
 
+        cli = new OnapCli(new String[] {});
         mockConsole("version");
         try {
             cli.handleInteractive();
         } catch (Exception e) {
         }
 
+        cli = new OnapCli(new String[] {});
         mockConsole("help");
         try {
             cli.handleInteractive();
         } catch (Exception e) {
         }
 
+        cli = new OnapCli(new String[] {});
         mockConsoleReader();
         cli.handleInteractive();