diff options
author | jitendra007 <jitendra.sharma1@huawei.com> | 2020-06-18 16:25:39 +0530 |
---|---|---|
committer | priyanka.akhade <priyanka.akhade@huawei.com> | 2020-07-09 13:06:31 +0530 |
commit | 5f23e02caa5ab128a4c01866dec91eaea8dc7cee (patch) | |
tree | ca3c4f31dc56ce64aa9c0165b8cac4dab8e70b7c /framework/src/test | |
parent | c3391bef9e04c2ad38ed96bd28a5c43ab6d961de (diff) |
Fixed sonarcloud issues
Issue-ID: CLI-270
Signed-off-by: jitendra007 <jitendra.sharma1@huawei.com>
Change-Id: Ibb52afb2fe8fe7c9be4299d1a1cb1e3d32ab0eca
Diffstat (limited to 'framework/src/test')
4 files changed, 61 insertions, 1 deletions
diff --git a/framework/src/test/java/org/onap/cli/fw/registrar/OnapCommandRegistrarTest.java b/framework/src/test/java/org/onap/cli/fw/registrar/OnapCommandRegistrarTest.java index 800a6c96..2b3c62ba 100644 --- a/framework/src/test/java/org/onap/cli/fw/registrar/OnapCommandRegistrarTest.java +++ b/framework/src/test/java/org/onap/cli/fw/registrar/OnapCommandRegistrarTest.java @@ -24,6 +24,8 @@ import static org.junit.Assert.fail; import java.io.File; import java.net.URL; import java.util.ArrayList; +import java.util.List; +import java.util.Map; import org.junit.Before; import org.junit.Test; @@ -95,6 +97,11 @@ public class OnapCommandRegistrarTest { cmd.printVersion(); registrar.listCommands(); } + @Test + public void getTestSuiteTest() throws OnapCommandException { + List<Map<String, Object>> cmds =registerar.getTestSuite("schema-validate","open-cli"); + assertTrue(cmds.size() >= 1); + } } @OnapCommandSchema(schema = "sample-test-schema.yaml") diff --git a/framework/src/test/java/org/onap/cli/fw/schema/ValidateSchemaTest.java b/framework/src/test/java/org/onap/cli/fw/schema/ValidateSchemaTest.java index 4c64ca2a..e951793e 100644 --- a/framework/src/test/java/org/onap/cli/fw/schema/ValidateSchemaTest.java +++ b/framework/src/test/java/org/onap/cli/fw/schema/ValidateSchemaTest.java @@ -18,7 +18,10 @@ package org.onap.cli.fw.schema; import static org.junit.Assert.assertTrue; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.junit.Test; import org.onap.cli.fw.cmd.OnapCommand; @@ -137,4 +140,38 @@ public class ValidateSchemaTest { assertTrue(errorList2.size() > 0); } + @Test + public void parseSchemaTest() throws OnapCommandException { + OnapCommand cmd = new OnapCommand() { + @Override + protected void run() throws OnapCommandException {} + }; + Map<String, Object> values=new HashMap<>(); + List<Map<String, Object>> list=new ArrayList<>(); + Map<String,Object> paraValues=new HashMap<>(); + paraValues.put("is_secured","yes"); + paraValues.put("is_default_param","yes"); + list.add(paraValues); + values.put("parameters",list); + assertTrue(OnapCommandSchemaLoader.parseSchema(cmd,values,true).size()==2); + + } + @Test + public void parseSchema2Test() throws OnapCommandException { + OnapCommand cmd = new OnapCommand() { + @Override + protected void run() throws OnapCommandException {} + }; + Map<String, Object> values=new HashMap<>(); + List<Map<String, Object>> list=new ArrayList<>(); + Map<String,Object> paraValues=new HashMap<>(); + Map<String, Object> attributesValues=new HashMap<>(); + paraValues.put("is_secured","yes"); + paraValues.put("is_default_attr","yes"); + list.add(paraValues); + attributesValues.put("attributes",list); + values.put("results",attributesValues); + assertTrue(OnapCommandSchemaLoader.parseSchema(cmd,values,true).size()==2); + + } } diff --git a/framework/src/test/java/org/onap/cli/fw/store/OnapCommandProfileStoreTest.java b/framework/src/test/java/org/onap/cli/fw/store/OnapCommandProfileStoreTest.java index 1635b1b5..c2f2fe17 100644 --- a/framework/src/test/java/org/onap/cli/fw/store/OnapCommandProfileStoreTest.java +++ b/framework/src/test/java/org/onap/cli/fw/store/OnapCommandProfileStoreTest.java @@ -79,7 +79,11 @@ public class OnapCommandProfileStoreTest { assertNotNull(onapCommandProfileStore.getParams("abc")); } - + @Test + public void removeTest() { + onapCommandProfileStore.add("abc", "abc", "abc"); + onapCommandProfileStore.remove("abc","abc"); + } @AfterClass public static void tearDown() throws Exception { diff --git a/framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java b/framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java index b7da1c2f..d7bd8051 100644 --- a/framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java +++ b/framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java @@ -43,6 +43,7 @@ import org.onap.cli.fw.schema.OnapCommandSchema; import org.onap.cli.fw.schema.OnapCommandSchemaInfo; import org.onap.cli.fw.schema.OnapCommandSchemaLoader; +import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -428,6 +429,11 @@ public class OnapCommandUtilsTest { List<Class<OnapCommand>> cmds = OnapCommandDiscoveryUtils.discoverCommandPlugins(); assertTrue(cmds.size() >= 1); } + @Test + public void createTestSuiteTest() throws OnapCommandException { + List<Map<String, Object>> cmds = OnapCommandDiscoveryUtils.createTestSuite("schema-validate","open-cli"); + assertTrue(cmds.size() >= 1); + } @Test public void sortTest() { @@ -544,4 +550,10 @@ public class OnapCommandUtilsTest { assertTrue(mapExample.get("key2").equals("paramB")); } + @Test + public void loadYamlTest() throws OnapCommandInvalidSchema { + File file=new File("src/test/resources/sample-test-info.yaml"); + Map<String, Object> values= OnapCommandDiscoveryUtils.loadYaml(file.getAbsolutePath()); + assertEquals(values.get("name"),"sample-test-info"); + } } |