summaryrefslogtreecommitdiffstats
path: root/sliPluginUtils/provider/src
diff options
context:
space:
mode:
Diffstat (limited to 'sliPluginUtils/provider/src')
-rw-r--r--sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java201
1 files changed, 119 insertions, 82 deletions
diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java
index 166a60e90..266603d1d 100644
--- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java
+++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java
@@ -3,7 +3,9 @@
* ONAP : CCSDK
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
+ * reserved.
+ * ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +23,9 @@
package org.onap.ccsdk.sli.core.slipluginutils;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
import java.util.HashMap;
import java.util.Map;
@@ -32,85 +37,117 @@ import org.slf4j.LoggerFactory;
public class CheckParametersTest {
- @Test
- public void nullRequiredParameters() throws Exception {
- Map<String, String> parametersMap = new HashMap<String, String>();
- String[] requiredParams = null;
- Logger Log = LoggerFactory.getLogger(SliPluginUtils.class);
- SliPluginUtils.checkParameters(parametersMap, requiredParams, Log);
- }
-
- @Test(expected = SvcLogicException.class)
- public void emptyParametersMap() throws Exception {
- Map<String, String> parametersMap = new HashMap<String, String>();
- String[] requiredParams = new String[] { "param1", "param2", "param3" };
- Logger Log = LoggerFactory.getLogger(SliPluginUtils.class);
- SliPluginUtils.checkParameters(parametersMap, requiredParams, Log);
- }
-
- @Test(expected = SvcLogicException.class)
- public void paramNotFound() throws Exception {
- Map<String, String> parametersMap = new HashMap<String, String>();
- parametersMap.put("tst", "me");
- String[] requiredParams = new String[] { "param1", "parm2", "param3" };
- Logger Log = LoggerFactory.getLogger(SliPluginUtils.class);
- SliPluginUtils.checkParameters(parametersMap, requiredParams, Log);
- }
-
- @Test
- public void testSunnyRequiredParameters() throws Exception {
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("param1", "hello");
- ctx.setAttribute("param2", "world");
- ctx.setAttribute("param3", "!");
-
- Map<String, String> parameters = new HashMap<String, String>();
- parameters.put("param1", "dog");
- parameters.put("param2", "cat");
- parameters.put("param3", "fish");
-
- SliPluginUtils.requiredParameters(parameters, ctx);
- }
-
- @Test
- public void testSunnyRequiredParametersWithPrefix() throws Exception {
- String prefixValue = "my.unique.path.";
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute(prefixValue + "param1", "hello");
- ctx.setAttribute(prefixValue + "param2", "world");
- ctx.setAttribute(prefixValue + "param3", "!");
-
- Map<String, String> parameters = new HashMap<String, String>();
- parameters.put("prefix", prefixValue);
- parameters.put("param1", "dog");
- parameters.put("param2", "cat");
- parameters.put("param3", "fish");
-
- SliPluginUtils.requiredParameters(parameters, ctx);
- }
-
- @Test(expected = SvcLogicException.class)
- public void testRainyMissingRequiredParameters() throws Exception {
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("param1", "hello");
- ctx.setAttribute("param3", "!");
-
- Map<String, String> parameters = new HashMap<String, String>();
- parameters.put("param1", null);
- parameters.put("param2", null);
- parameters.put("param3", null);
-
- SliPluginUtils.requiredParameters(parameters, ctx);
- }
-
- @Test(expected = SvcLogicException.class)
- public void testEmptyRequiredParameters() throws Exception {
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("param1", "hello");
- ctx.setAttribute("param3", "!");
-
- Map<String, String> parameters = new HashMap<String, String>();
-
- SliPluginUtils.requiredParameters(parameters, ctx);
- }
+ @Test
+ public void nullRequiredParameters() throws Exception {
+ Map<String, String> parametersMap = new HashMap<String, String>();
+ String[] requiredParams = null;
+ Logger Log = LoggerFactory.getLogger(SliPluginUtils.class);
+ SliPluginUtils.checkParameters(parametersMap, requiredParams, Log);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void emptyParametersMap() throws Exception {
+ Map<String, String> parametersMap = new HashMap<String, String>();
+ String[] requiredParams = new String[] { "param1", "param2", "param3" };
+ Logger Log = LoggerFactory.getLogger(SliPluginUtils.class);
+ SliPluginUtils.checkParameters(parametersMap, requiredParams, Log);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void paramNotFound() throws Exception {
+ Map<String, String> parametersMap = new HashMap<String, String>();
+ parametersMap.put("tst", "me");
+ String[] requiredParams = new String[] { "param1", "parm2", "param3" };
+ Logger Log = LoggerFactory.getLogger(SliPluginUtils.class);
+ SliPluginUtils.checkParameters(parametersMap, requiredParams, Log);
+ }
+
+ @Test
+ public void testSunnyRequiredParameters() throws Exception {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("param1", "hello");
+ ctx.setAttribute("param2", "world");
+ ctx.setAttribute("param3", "!");
+
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("param1", "dog");
+ parameters.put("param2", "cat");
+ parameters.put("param3", "fish");
+
+ SliPluginUtils.requiredParameters(parameters, ctx);
+ }
+
+ @Test
+ public void testSunnyRequiredParametersWithPrefix() throws Exception {
+ String prefixValue = "my.unique.path.";
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute(prefixValue + "param1", "hello");
+ ctx.setAttribute(prefixValue + "param2", "world");
+ ctx.setAttribute(prefixValue + "param3", "!");
+
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("prefix", prefixValue);
+ parameters.put("param1", "dog");
+ parameters.put("param2", "cat");
+ parameters.put("param3", "fish");
+
+ SliPluginUtils.requiredParameters(parameters, ctx);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testRainyMissingRequiredParameters() throws Exception {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("param1", "hello");
+ ctx.setAttribute("param3", "!");
+
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("param1", null);
+ parameters.put("param2", null);
+ parameters.put("param3", null);
+
+ SliPluginUtils.requiredParameters(parameters, ctx);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testEmptyRequiredParameters() throws Exception {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("param1", "hello");
+ ctx.setAttribute("param3", "!");
+
+ Map<String, String> parameters = new HashMap<String, String>();
+
+ SliPluginUtils.requiredParameters(parameters, ctx);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testJsonStringToCtx() throws Exception {
+ SvcLogicContext ctx = new SvcLogicContext();
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("outputPath", "testPath");
+ parameters.put("isEscaped", "true");
+ parameters.put("source", "//{/name1/:value1/}//");
+ SliPluginUtils.jsonStringToCtx(parameters, ctx);
+ }
+
+ @Test
+ public void testGetAttributeValue() throws Exception {
+ SvcLogicContext ctx = new SvcLogicContext();
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("outputPath", "testPath");
+ parameters.put("source", "testSource");
+ SliPluginUtils.getAttributeValue(parameters, ctx);
+ assertNull(ctx.getAttribute(parameters.get("outputPath")));
+ }
+
+ @Test
+ public void testCtxListContains() throws Exception {
+ SvcLogicContext ctx = new SvcLogicContext();
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("list", "10_length");
+ parameters.put("keyName", "testName");
+ parameters.put("keyValue", "testValue");
+ ctx.setAttribute("10_length", "10");
+ assertEquals("false", SliPluginUtils.ctxListContains(parameters, ctx));
+
+ }
}