diff options
author | 2022-03-25 12:44:19 +0530 | |
---|---|---|
committer | 2022-03-25 13:19:08 +0530 | |
commit | 2073da6514668ce17e7359900439354fb3432f4e (patch) | |
tree | 582571835a61daec0bceeaa7d65805c4e3cbb119 /main/src/test | |
parent | f439543779cf2dfac0b68443aea921c55983bf48 (diff) |
Fixed Sonar Bug and Code Smell Blockers
Issue-ID: CLI-439
Signed-off-by: sharath reddy <bs.reddy@huawei.com>
Change-Id: I81bd79661ab7c6b1152fa481d9273a86e77b4f3a
Signed-off-by: sharath reddy <bs.reddy@huawei.com>
Diffstat (limited to 'main/src/test')
-rw-r--r-- | main/src/test/java/org/onap/cli/main/OnapCliMainTest.java | 23 | ||||
-rw-r--r-- | main/src/test/java/org/onap/cli/main/OnapCommandSampleTest.java | 3 |
2 files changed, 14 insertions, 12 deletions
diff --git a/main/src/test/java/org/onap/cli/main/OnapCliMainTest.java b/main/src/test/java/org/onap/cli/main/OnapCliMainTest.java index c1e05093..47cacd10 100644 --- a/main/src/test/java/org/onap/cli/main/OnapCliMainTest.java +++ b/main/src/test/java/org/onap/cli/main/OnapCliMainTest.java @@ -38,6 +38,7 @@ import java.util.Arrays; import org.onap.cli.fw.error.OnapCommandInvalidSchema; import org.onap.cli.fw.utils.OnapCommandDiscoveryUtils; import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; public class OnapCliMainTest { @@ -51,37 +52,37 @@ public class OnapCliMainTest { @Test public void testHelp() { - this.handle(new String[] { "--help" }); + assertDoesNotThrow(() -> this.handle(new String[] { "--help" })); } @Test public void testHelpShort() { - this.handle(new String[] { "-h" }); + assertDoesNotThrow(() -> this.handle(new String[] { "-h" })); } @Test public void testVersion() { - this.handle(new String[] { "--version" }); + assertDoesNotThrow(() -> this.handle(new String[] { "--version" })); } @Test public void testVersionShort() { - this.handle(new String[] { "-v" }); + assertDoesNotThrow(() -> this.handle(new String[] { "-v" })); } @Test public void testHelpSampleCommand() { - this.handle(new String[] { "sample-test", "--help" }); + assertDoesNotThrow(() -> this.handle(new String[] { "sample-test", "--help" })); } @Test public void testHelpSampleCommandShort() { - this.handle(new String[] { "sample-test", "-h" }); + assertDoesNotThrow(() -> this.handle(new String[] { "sample-test", "-h" })); } @Test public void testVersionSampleCommandShort() { - this.handle(new String[] { "sample-test", "-v" }); + assertDoesNotThrow(() -> this.handle(new String[] { "sample-test", "-v" })); } @Test @@ -90,12 +91,12 @@ public class OnapCliMainTest { OnapCommandRegistrar.getRegistrar().addParamCache("host-username", "paramValue"); OnapCommandRegistrar.getRegistrar().addParamCache("host-password", "paramValue"); OnapCommandRegistrar.getRegistrar().addParamCache("host-url", "paramValue"); - this.handle(new String[] { "sample-test", "--string-param", "test"}); + assertDoesNotThrow(() -> this.handle(new String[] { "sample-test", "--string-param", "test"})); } @Test public void testHandleSampleCommandFailure() throws OnapCommandException { - this.handle(new String[] { "sample-test", "--string-param"}); + assertDoesNotThrow(() -> this.handle(new String[] { "sample-test", "--string-param"})); } @Test @@ -184,7 +185,7 @@ public class OnapCliMainTest { cli = new OnapCli(new String[] {}); mockConsoleReader(); - cli.handleInteractive(); + assertDoesNotThrow(() -> cli.handleInteractive()); } @@ -239,7 +240,7 @@ public class OnapCliMainTest { map.put("sampleid","sample1"); map.put("samplefileid","schema-validate-sample.yaml"); map.put("moco","schema-validate-moco.json"); - list.add(map); + assertDoesNotThrow(() -> list.add(map)); return list; } }; diff --git a/main/src/test/java/org/onap/cli/main/OnapCommandSampleTest.java b/main/src/test/java/org/onap/cli/main/OnapCommandSampleTest.java index bf61d344..edd0ab3e 100644 --- a/main/src/test/java/org/onap/cli/main/OnapCommandSampleTest.java +++ b/main/src/test/java/org/onap/cli/main/OnapCommandSampleTest.java @@ -25,6 +25,7 @@ import java.util.HashSet; import java.util.Set; import org.junit.Test; import org.onap.cli.fw.conf.OnapCommandConstants; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; /** * This command helps to test the Command functionalities. @@ -53,7 +54,7 @@ public class OnapCommandSampleTest extends OnapCommand { OnapCommand sample = OnapCommandRegistrar.getRegistrar().get("sample-test"); sample.setParameters(parameters); - sample.execute(); + assertDoesNotThrow(() -> sample.execute()); } } |