From 3bd15af9248f3347ab43324ab2ccee9dbb945db3 Mon Sep 17 00:00:00 2001 From: "priyanka.akhade" Date: Wed, 16 Sep 2020 14:41:40 +0530 Subject: printyaml method fix Signed-off-by: priyanka.akhade Change-Id: I4e9178a884981600731b2a33fb8bec2640fcd9b7 Issue-ID: CLI-251 --- .../onap/cli/fw/output/OnapCommandResultTest.java | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'framework/src/test') diff --git a/framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultTest.java b/framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultTest.java index f46fc911..cf274f23 100644 --- a/framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultTest.java +++ b/framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultTest.java @@ -235,4 +235,39 @@ public class OnapCommandResultTest { assertEquals(expRes,result); } + + @Test + public void printYamlTest() throws OnapCommandException { + OnapCommandResult res = new OnapCommandResult(); + res.setDebugInfo("debugInfo"); + res.setIncludeSeparator(true); + res.setIncludeTitle(true); + res.setOutput("Output"); + res.setPrintDirection(OnapCommandPrintDirection.LANDSCAPE); + + OnapCommandResultAttribute att = new OnapCommandResultAttribute(); + att.setName("param"); + att.setDescription("description"); + att.setType(OnapCommandParameterType.YAML); + att.setValues( + new ArrayList(Arrays.asList(new String[] { "{\"id\": \"0001\",\"value\": \"result\"}" }))); + List list = new ArrayList(); + list.add(att); + res.setRecords(list); + res.setScope(OnapCommandResultAttributeScope.LONG); + res.setType(OnapCommandResultType.YAML); + String result = res.print(); + String expRes="---\n- param:\n id: \"0001\"\n value: \"result\"\n"; + assertEquals(expRes,result); + + att.setValues( + new ArrayList(Arrays.asList(new String[] { "{\"id\": \"0001\": \"value\": }" }))); + list = new ArrayList(); + list.add(att); + res.setRecords(list); + result = res.print(); + expRes="---\n- param: null\n"; + assertEquals(expRes,result); + + } } -- cgit 1.2.3-korg