diff options
-rwxr-xr-x | sli/common/pom.xml | 6 | ||||
-rw-r--r-- | sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java | 69 |
2 files changed, 75 insertions, 0 deletions
diff --git a/sli/common/pom.xml b/sli/common/pom.xml index bd9ec696..23f2df87 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -95,6 +95,12 @@ <artifactId>dblib-provider</artifactId> <version>${sdnctl.dblib.version}</version> </dependency> + <dependency> + <groupId>org.onap.ccsdk.sli.core</groupId> + <artifactId>sliapi-model</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> <build> 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 00000000..21d3e59c --- /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<SliParameter> 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)); + } + + } + +} |