From d621496c524846c1d0375926cafefdbf7bdd1d93 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 25 Oct 2017 14:08:31 -0400 Subject: Add unit test case for PrintYangToProp Add junit testing for PrintYangToProp Change-Id: I8c377bb51c812ea9ead32d8e9d5ef871157162a8 Issue-ID: CCSDK-129 Signed-off-by: Dan Timoney --- sli/common/pom.xml | 6 ++ .../ccsdk/sli/core/sli/PrintYangToPropTest.java | 69 ++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java diff --git a/sli/common/pom.xml b/sli/common/pom.xml index bd9ec696a..23f2df873 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -95,6 +95,12 @@ dblib-provider ${sdnctl.dblib.version} + + org.onap.ccsdk.sli.core + sliapi-model + ${project.version} + test + diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java new file mode 100644 index 000000000..21d3e59c3 --- /dev/null +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java @@ -0,0 +1,69 @@ +/** + * + */ +package org.onap.ccsdk.sli.core.sli; + +import static org.junit.Assert.*; + +import java.util.Enumeration; +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; + +import org.junit.Test; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author dt5972 + * + */ +public class PrintYangToPropTest { + + private static final Logger LOG = LoggerFactory.getLogger(PrintYangToPropTest.class); + @Test + public void test() { + + Properties props = new Properties(); + + // Set up a builder with data + ExecuteGraphInputBuilder egBuilder = new ExecuteGraphInputBuilder(); + egBuilder.setMode(Mode.Sync); + egBuilder.setModuleName("my-module"); + egBuilder.setRpcName("my-rpc"); + + List pList = new LinkedList<>(); + + SliParameterBuilder pBuilder = new SliParameterBuilder(); + pBuilder.setParameterName("string-param"); + pBuilder.setStringValue("hi"); + pList.add(pBuilder.build()); + pBuilder.setParameterName("int-param"); + pBuilder.setIntValue(1); + pBuilder.setStringValue(null); + pList.add(pBuilder.build()); + pBuilder.setParameterName("bool-param"); + pBuilder.setIntValue(null); + pBuilder.setBooleanValue(true); + pList.add(pBuilder.build()); + + egBuilder.setSliParameter(pList); + + + // Generate properties + props = PrintYangToProp.toProperties(props, egBuilder); + + Enumeration propNames = props.propertyNames(); + + while (propNames.hasMoreElements()) { + String propName = (String) propNames.nextElement(); + LOG.info("Property {} = {}", propName, props.getProperty(propName)); + } + + } + +} -- cgit 1.2.3-korg