Improve profile verification 09/17309/1
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Thu, 5 Oct 2017 09:02:33 +0000 (14:32 +0530)
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Thu, 5 Oct 2017 09:02:33 +0000 (14:32 +0530)
CLI-34

Change-Id: I7c0443c80506dcc12151c448de4b8ebda42dadea
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
framework/src/test/java/org/onap/cli/fw/OnapCommandRegistrarTest.java

index b2c1508..16c3f2f 100644 (file)
 
 package org.onap.cli.fw;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.net.URL;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.onap.cli.fw.error.OnapCommandException;
@@ -23,14 +31,6 @@ import org.onap.cli.fw.error.OnapCommandHelpFailed;
 import org.onap.cli.fw.error.OnapCommandNotFound;
 import org.onap.cli.fw.error.OnapCommandRegistrationFailed;
 
-import java.io.File;
-import java.net.URL;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 public class OnapCommandRegistrarTest {
 
     OnapCommandRegistrar registerar;
@@ -113,7 +113,6 @@ public class OnapCommandRegistrarTest {
     }
 
     @Test(expected = OnapCommandHelpFailed.class)
-    // For coverage
     public void helpTestException() throws OnapCommandException {
         OnapCommand test = new OnapCommandTest1();
         Class<OnapCommand> cmd = (Class<OnapCommand>) test.getClass();
@@ -141,22 +140,25 @@ public class OnapCommandRegistrarTest {
     }
 
     @Test
-    public void testCoverageScope() throws OnapCommandException {
-        OnapCommandRegistrar.getRegistrar().setProfile("test");
-        OnapCommandRegistrar.getRegistrar().addParamCache("a", "b");
-        OnapCommandRegistrar.getRegistrar().getParamCache();
-        OnapCommandRegistrar.getRegistrar().removeParamCache("a");
-
-        OnapCommandRegistrar.getRegistrar().isInteractiveMode();
-        OnapCommandRegistrar.getRegistrar().setInteractiveMode(false);
+    public void testProfile() throws OnapCommandException {
+        try {
+                OnapCommandRegistrar.getRegistrar().setProfile("test");
+                OnapCommandRegistrar.getRegistrar().addParamCache("a", "b");
+                OnapCommandRegistrar.getRegistrar().getParamCache();
+                OnapCommandRegistrar.getRegistrar().removeParamCache("a");
 
-        OnapCommandRegistrar.getRegistrar().setEnabledProductVersion("cli-1.0");
-        OnapCommandRegistrar.getRegistrar().getEnabledProductVersion();
-        OnapCommandRegistrar.getRegistrar().getAvailableProductVersions();
-        OnapCommandRegistrar.getRegistrar().listCommandsForEnabledProductVersion();
+                OnapCommandRegistrar.getRegistrar().setInteractiveMode(false);
+                assertTrue(!OnapCommandRegistrar.getRegistrar().isInteractiveMode());
 
-        OnapCommandRegistrar.getRegistrar().listCommandInfo();
+                OnapCommandRegistrar.getRegistrar().setEnabledProductVersion("cli-1.0");
+                assertEquals("cli-1.0", OnapCommandRegistrar.getRegistrar().getEnabledProductVersion());
+                OnapCommandRegistrar.getRegistrar().getAvailableProductVersions();
+                assertTrue(OnapCommandRegistrar.getRegistrar().listCommandsForEnabledProductVersion().contains("schema-refresh"));
 
+                assertTrue(OnapCommandRegistrar.getRegistrar().listCommandInfo().size() > 2);
+        } catch (Exception e) {
+            fail("failed to test the profile");
+        }
     }
 }