From 8b4f5b8f95b02cd8b511fd2890ffa1589cb404fa Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Thu, 5 Oct 2017 14:32:33 +0530 Subject: Improve profile verification CLI-34 Change-Id: I7c0443c80506dcc12151c448de4b8ebda42dadea Signed-off-by: Kanagaraj Manickam k00365106 --- .../org/onap/cli/fw/OnapCommandRegistrarTest.java | 46 +++++++++++----------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'framework/src/test/java/org/onap') 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"); + } } } -- cgit 1.2.3-korg