aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/test/java/org/onap
diff options
context:
space:
mode:
authorpriyanka.akhade <priyanka.akhade@huawei.com>2020-04-13 13:16:29 +0000
committerpriyanka.akhade <priyanka.akhade@huawei.com>2020-05-04 06:43:16 +0000
commit1db7e72d979afa03bca38d3008f55246f8d6a6c1 (patch)
tree547661ba2a459201a5aa810e92dfa2941bff4f69 /main/src/test/java/org/onap
parent2bb3344c6b3ec9bd77d1491d5beb579bdabc62f2 (diff)
Migrate to Yamlbeans
Issue-ID: CLI-248 Signed-off-by: priyanka.akhade <priyanka.akhade@huawei.com> Change-Id: I182c7a2e2f41bf09990e5b1ac0344f49af33e0c5
Diffstat (limited to 'main/src/test/java/org/onap')
-rw-r--r--main/src/test/java/org/onap/cli/main/OnapCliMainTest.java9
-rw-r--r--main/src/test/java/org/onap/cli/main/utils/OnapCliUtilsTest.java24
2 files changed, 33 insertions, 0 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 634a8d7a..0fb83287 100644
--- a/main/src/test/java/org/onap/cli/main/OnapCliMainTest.java
+++ b/main/src/test/java/org/onap/cli/main/OnapCliMainTest.java
@@ -30,6 +30,10 @@ import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.error.OnapCommandHelpFailed;
import org.onap.cli.fw.registrar.OnapCommandRegistrar;
+import java.util.Map;
+import org.onap.cli.fw.error.OnapCommandInvalidSchema;
+import org.onap.cli.fw.utils.OnapCommandDiscoveryUtils;
+import static org.junit.Assert.assertFalse;
public class OnapCliMainTest {
@@ -213,4 +217,9 @@ public class OnapCliMainTest {
fail("Directive help failed to run");
}
}
+ @Test
+ public void testLoadYamlForYamlReader() throws OnapCommandInvalidSchema {
+ Map<String,?> map = OnapCommandDiscoveryUtils.loadYaml("src/test/resources/open-cli-schema/sample-test-schema.yaml");
+ assertFalse(map.isEmpty());
+ }
}
diff --git a/main/src/test/java/org/onap/cli/main/utils/OnapCliUtilsTest.java b/main/src/test/java/org/onap/cli/main/utils/OnapCliUtilsTest.java
index 0c92a1a3..e74981fb 100644
--- a/main/src/test/java/org/onap/cli/main/utils/OnapCliUtilsTest.java
+++ b/main/src/test/java/org/onap/cli/main/utils/OnapCliUtilsTest.java
@@ -395,4 +395,28 @@ public class OnapCliUtilsTest {
Assert.assertTrue(((List<String>) arrParam.getValue())
.containsAll(Arrays.asList("test1", "test2")));
}
+ @Test
+ public void testReadYamlStringFromUrl() throws OnapCommandException {
+ OnapCommandParameter param1 = new OnapCommandParameter();
+ param1.setLongOption("yaml");
+ param1.setName("name");
+ param1.setParameterType(OnapCommandParameterType.YAML);
+ Set<OnapCommandParameter> paramslist = new HashSet<>();
+ paramslist.add(param1);
+ OnapCliArgsParser.populateParams(paramslist,
+ Arrays.asList("--yaml", "name", "--yaml", "test-schema"));
+ Assert.assertTrue(paramslist.iterator().next().getValue().equals("test-schema"));
+ }
+ @Test
+ public void testReadYamlStringFromUrlForFile() throws OnapCommandException {
+ OnapCommandParameter param1 = new OnapCommandParameter();
+ param1.setLongOption("yaml");
+ param1.setName("name");
+ param1.setParameterType(OnapCommandParameterType.YAML);
+ Set<OnapCommandParameter> paramslist = new HashSet<>();
+ paramslist.add(param1);
+ OnapCliArgsParser.populateParams(paramslist,
+ Arrays.asList("--yaml", "main/src/test/resources/open-cli-schema/sample-test-schema.yaml", "--yaml", "test-schema"));
+ Assert.assertTrue(paramslist.iterator().next().getValue().equals("test-schema"));
+ }
} \ No newline at end of file