From: Kanagaraj Manickam k00365106 Date: Thu, 5 Oct 2017 09:02:33 +0000 (+0530) Subject: Improve profile verification X-Git-Tag: 1.0.0-Amsterdam~127 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F09%2F17309%2F1;p=cli.git Improve profile verification CLI-34 Change-Id: I7c0443c80506dcc12151c448de4b8ebda42dadea Signed-off-by: Kanagaraj Manickam k00365106 --- diff --git a/framework/src/test/java/org/onap/cli/fw/OnapCommandRegistrarTest.java b/framework/src/test/java/org/onap/cli/fw/OnapCommandRegistrarTest.java index b2c15086..16c3f2f3 100644 --- a/framework/src/test/java/org/onap/cli/fw/OnapCommandRegistrarTest.java +++ b/framework/src/test/java/org/onap/cli/fw/OnapCommandRegistrarTest.java @@ -16,6 +16,14 @@ 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 cmd = (Class) 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"); + } } }