summaryrefslogtreecommitdiffstats
path: root/template-node/provider/src/test
diff options
context:
space:
mode:
authorJessica Wagantall <jwagantall@linuxfoundation.org>2020-12-01 11:33:35 -0800
committerJessica Wagantall <jwagantall@linuxfoundation.org>2020-12-01 11:33:35 -0800
commit96a9aafdff7813324bc8a8ba1e743683e251dde6 (patch)
tree644c6837ab58ed21fb05f4bf988dc392875b9f8d /template-node/provider/src/test
parenta0e97e71a49a8b54fddf8fb004b32f202f114011 (diff)
Migrate files from sli-plugins
Migrate sli-plugins repo into new directory "plugins". Signed-off-by: Jessica Wagantall <jwagantall@linuxfoundation.org>
Diffstat (limited to 'template-node/provider/src/test')
-rw-r--r--template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/MockTemplateNode.java7
-rw-r--r--template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/TemplateNodeTest.java85
-rw-r--r--template-node/provider/src/test/resources/basic.vtl12
-rw-r--r--template-node/provider/src/test/resources/template-node.properties4
4 files changed, 0 insertions, 108 deletions
diff --git a/template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/MockTemplateNode.java b/template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/MockTemplateNode.java
deleted file mode 100644
index d628ac929..000000000
--- a/template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/MockTemplateNode.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.onap.ccsdk.sli.plugins.template;
-
-public class MockTemplateNode extends TemplateNode {
- protected void setProperties() {
- // do nothing
- }
-}
diff --git a/template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/TemplateNodeTest.java b/template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/TemplateNodeTest.java
deleted file mode 100644
index 29c5c973e..000000000
--- a/template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/TemplateNodeTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package org.onap.ccsdk.sli.plugins.template;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Vector;
-import org.apache.velocity.runtime.RuntimeConstants;
-import org.junit.Test;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-
-public class TemplateNodeTest {
-
- @Test
- public void sunnyDay() throws Exception {
- String requestId = "REQ001";
- String uniqueKey = "UNIQUE_TEST";
- String action = "uPdaTe";
- String serviceType = "VPN";
-
- TemplateNode t = new MockTemplateNode();
-
- Map<String, String> params = new HashMap<String, String>();
- params.put(TemplateNode.PREFIX_KEY, "output");
- params.put(TemplateNode.OUTPUT_PATH_KEY, "mycontainer");
- params.put(TemplateNode.TEMPLATE_PATH, "src/test/resources/basic.vtl");
- params.put("service-type", serviceType);
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("input.svc-request-id", requestId);
- ctx.setAttribute("input.unique-key", uniqueKey);
- ctx.setAttribute("action", action);
-
- t.evaluateTemplate(params, ctx);
- String result = ctx.getAttribute("output.mycontainer");
- assertNotNull(result);
- assertTrue(result.contains(requestId));
- assertTrue(result.contains(uniqueKey));
- assertTrue(result.contains(action.toUpperCase()));
- assertTrue(result.contains(serviceType));
- }
-
- @Test(expected = SvcLogicException.class)
- public void parameterException() throws Exception {
- TemplateNode t = new MockTemplateNode();
- Map<String, String> params = new HashMap<String, String>();
- SvcLogicContext ctx = new SvcLogicContext();
- t.evaluateTemplate(params, ctx);
- }
-
- @Test(expected = SvcLogicException.class)
- public void missingTemplate() throws Exception {
- TemplateNode t = new MockTemplateNode();
- Map<String, String> params = new HashMap<String, String>();
- params.put(TemplateNode.PREFIX_KEY, "output");
- params.put(TemplateNode.OUTPUT_PATH_KEY, "mycontainer");
- params.put(TemplateNode.TEMPLATE_PATH, "src/test/resources/missing.vtl");
- SvcLogicContext ctx = new SvcLogicContext();
- t.evaluateTemplate(params, ctx);
- }
-
- @Test
- public void withProperties() throws Exception {
- System.setProperty(TemplateNode.PROPERTIES_DIR_KEY, "src/test/resources");
- TemplateNode t = new TemplateNode();
- Vector<String> loader = (Vector<String>) t.ve.getProperty(RuntimeConstants.RESOURCE_LOADER);
- assertTrue(loader.contains("class"));
- assertEquals("/home/my/example", t.ve.getProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH));
- assertEquals("true", t.ve.getProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE));
- assertEquals("customValue", t.ve.getProperty("custom.property"));
- }
-
- @Test
- public void withNoProperties() throws Exception {
- System.setProperty(TemplateNode.PROPERTIES_DIR_KEY, "i/do/not/exist");
- TemplateNode t = new TemplateNode();
- Vector<String> loader = (Vector<String>) t.ve.getProperty(RuntimeConstants.RESOURCE_LOADER);
- assertTrue(loader.contains("file"));
- assertEquals("/opt/onap/sdnc/restapi/templates", t.ve.getProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH));
- assertEquals("false", t.ve.getProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE));
- assertEquals(null, t.ve.getProperty("custom.property"));
- }
-
-} \ No newline at end of file
diff --git a/template-node/provider/src/test/resources/basic.vtl b/template-node/provider/src/test/resources/basic.vtl
deleted file mode 100644
index 63fcc670a..000000000
--- a/template-node/provider/src/test/resources/basic.vtl
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "input": {
- "sdnc-request-header": {
- "svc-request-id": "$ctx.getAttribute("input.svc-request-id")",
- "svc-action": "$ctx.getAttribute("action").toUpperCase()"
- },
- "service-information": {
- "service-type": "$params.get("service-type")",
- "service-instance-id": "$ctx.getAttribute("input.unique-key")"
- }
- }
-} \ No newline at end of file
diff --git a/template-node/provider/src/test/resources/template-node.properties b/template-node/provider/src/test/resources/template-node.properties
deleted file mode 100644
index 1199a0cde..000000000
--- a/template-node/provider/src/test/resources/template-node.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-velocity.resource.loader=class
-velocity.file.resource.loader.path=/home/my/example
-velocity.file.resource.loader.cache=true
-velocity.custom.property=customValue \ No newline at end of file