summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2017-10-25 14:08:31 -0400
committerDan Timoney <dtimoney@att.com>2017-10-25 14:16:51 -0400
commitd621496c524846c1d0375926cafefdbf7bdd1d93 (patch)
tree35bea5981993c6c2350d0c35d806fc10aa9b3f1d
parent26f3062b282aff2f33d5c364a9e3e343c569ca0a (diff)
Add unit test case for PrintYangToProp
Add junit testing for PrintYangToProp Change-Id: I8c377bb51c812ea9ead32d8e9d5ef871157162a8 Issue-ID: CCSDK-129 Signed-off-by: Dan Timoney <dtimoney@att.com>
-rwxr-xr-xsli/common/pom.xml6
-rw-r--r--sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java69
2 files changed, 75 insertions, 0 deletions
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 @@
<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 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<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));
+ }
+
+ }
+
+}