summaryrefslogtreecommitdiffstats
path: root/sliPluginUtils
diff options
context:
space:
mode:
Diffstat (limited to 'sliPluginUtils')
-rw-r--r--sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml19
-rw-r--r--sliPluginUtils/features/features-sliPluginUtils/pom.xml4
-rwxr-xr-xsliPluginUtils/features/pom.xml4
-rwxr-xr-xsliPluginUtils/installer/pom.xml25
-rwxr-xr-xsliPluginUtils/pom.xml4
-rwxr-xr-xsliPluginUtils/provider/pom.xml14
-rw-r--r--sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java259
-rw-r--r--sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java167
8 files changed, 309 insertions, 187 deletions
diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml
index 78f5f1e1..3e15fa44 100644
--- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml
+++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml
@@ -5,13 +5,13 @@
<parent>
<groupId>org.onap.ccsdk.parent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.1.0</version>
<relativePath/>
</parent>
<groupId>org.onap.ccsdk.sli.core</groupId>
<artifactId>ccsdk-sliPluginUtils</artifactId>
- <version>0.3.0-SNAPSHOT</version>
+ <version>0.3.1-SNAPSHOT</version>
<packaging>feature</packaging>
<name>ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId}</name>
@@ -32,6 +32,21 @@
<type>pom</type>
<scope>import</scope>
</dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>dblib-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
<dependencies>
diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml
index 23e54fe5..60d563f7 100644
--- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml
+++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml
@@ -5,13 +5,13 @@
<parent>
<groupId>org.onap.ccsdk.parent</groupId>
<artifactId>feature-repo-parent</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.1.0</version>
<relativePath/>
</parent>
<groupId>org.onap.ccsdk.sli.core</groupId>
<artifactId>features-sliPluginUtils</artifactId>
- <version>0.3.0-SNAPSHOT</version>
+ <version>0.3.1-SNAPSHOT</version>
<packaging>feature</packaging>
<name>ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId}</name>
diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml
index 5b4b70fd..2194f8ec 100755
--- a/sliPluginUtils/features/pom.xml
+++ b/sliPluginUtils/features/pom.xml
@@ -5,13 +5,13 @@
<parent>
<groupId>org.onap.ccsdk.parent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.1.0</version>
<relativePath/>
</parent>
<groupId>org.onap.ccsdk.sli.core</groupId>
<artifactId>sliPluginUtils-features</artifactId>
- <version>0.3.0-SNAPSHOT</version>
+ <version>0.3.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId}</name>
diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml
index 5a22e495..e30e9d26 100755
--- a/sliPluginUtils/installer/pom.xml
+++ b/sliPluginUtils/installer/pom.xml
@@ -5,13 +5,13 @@
<parent>
<groupId>org.onap.ccsdk.parent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.1.0</version>
<relativePath/>
</parent>
<groupId>org.onap.ccsdk.sli.core</groupId>
<artifactId>sliPluginUtils-installer</artifactId>
- <version>0.3.0-SNAPSHOT</version>
+ <version>0.3.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId}</name>
@@ -23,6 +23,27 @@
<include.transitive.dependencies>false</include.transitive.dependencies>
</properties>
+ <dependencyManagement>
+ <dependencies>
+
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>dblib-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
<dependencies>
<dependency>
diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml
index 8ecdf397..da646177 100755
--- a/sliPluginUtils/pom.xml
+++ b/sliPluginUtils/pom.xml
@@ -5,13 +5,13 @@
<parent>
<groupId>org.onap.ccsdk.parent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.1.0</version>
<relativePath/>
</parent>
<groupId>org.onap.ccsdk.sli.core</groupId>
<artifactId>sliPluginUtils</artifactId>
- <version>0.3.0-SNAPSHOT</version>
+ <version>0.3.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>ccsdk-sli-core :: sliPluginUtils</name>
diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml
index 411c1453..4b7fe952 100755
--- a/sliPluginUtils/provider/pom.xml
+++ b/sliPluginUtils/provider/pom.xml
@@ -5,13 +5,13 @@
<parent>
<groupId>org.onap.ccsdk.parent</groupId>
<artifactId>binding-parent</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.1.0</version>
<relativePath/>
</parent>
<groupId>org.onap.ccsdk.sli.core</groupId>
<artifactId>sliPluginUtils-provider</artifactId>
- <version>0.3.0-SNAPSHOT</version>
+ <version>0.3.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId}</name>
@@ -20,7 +20,15 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
-
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>dblib-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
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 266603d1..a7cc1bde 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
@@ -35,119 +35,152 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.gson.JsonObject;
+
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(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));
-
- }
+ @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));
+
+ }
+
+ @Test(expected= SvcLogicException.class)
+ public void testPrintContextForNullParameters() throws SvcLogicException
+ {
+ SvcLogicContext ctx = new SvcLogicContext();
+ Map<String, String> parameters = new HashMap<String, String>();
+ SliPluginUtils.printContext(parameters, ctx);
+ }
+
+ @Test
+ public void testPrintContext() throws SvcLogicException
+ {
+ SvcLogicContext ctx = new SvcLogicContext();
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put("filename","testFileName");
+ SliPluginUtils.printContext(parameters, ctx);
+ }
+
+ @Test
+ public void testWriteJsonObject() throws SvcLogicException
+ {
+ JsonObject obj=new JsonObject();
+ obj.addProperty("name","testName");
+ obj.addProperty("age",27);
+ obj.addProperty("salary",600000);
+ SvcLogicContext ctx = new SvcLogicContext();
+ SliPluginUtils.writeJsonObject(obj, ctx,"root");
+ assertEquals("testName", ctx.getAttribute("root.name"));
+ assertEquals("27", ctx.getAttribute("root.age"));
+ assertEquals("600000", ctx.getAttribute("root.salary"));
+ }
}
diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java
index f9d70f2f..bfd19bc6 100644
--- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java
+++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.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.
@@ -17,15 +19,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ */
package org.onap.ccsdk.sli.core.slipluginutils;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.HashMap;
import java.util.Random;
-
+
import org.junit.Before;
import org.junit.Test;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
@@ -35,62 +38,104 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings("unused")
public class SliPluginUtils_ctxSortList {
- private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils_ctxSortList.class);
- SliPluginUtils utils = new SliPluginUtils();
- SvcLogicContext ctx;
- HashMap<String,String> parameters;
- Random rand = new Random();
-
- @Before
- public void setUp() throws Exception {
- this.ctx = new SvcLogicContext();
- this.parameters = new HashMap<String,String>();
- }
-
- @Test
- public final void list_of_containers() throws SvcLogicException {
- this.parameters.put("list", "input.list");
- this.parameters.put("sort-fields", "sort-key");
- this.parameters.put("delimiter",",");
-
- ctx.setAttribute("input.list_length", "10");
- for( int i = 0; i < 10; i++ ) {
- this.ctx.setAttribute("input.list[" + i + "].sort-key", Integer.toString( rand.nextInt(10) ));
- this.ctx.setAttribute("input.list[" + i + "].value", Integer.toString( rand.nextInt(10) ));
- }
-
- LOG.trace("BEFORE SORT:");
- SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE);
-
- utils.ctxSortList(this.parameters, this.ctx);
-
- LOG.trace("AFTER SORT:");
- SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE);
-
- for( int i = 0; i < 9; i++ ) {
- assertTrue(this.ctx.getAttribute("input.list[" + i + "].sort-key").compareTo(this.ctx.getAttribute("input.list[" + (i+1) + "].sort-key")) < 1 );
- }
- }
-
- @Test public final void list_of_elements() throws SvcLogicException {
- this.parameters.put("list", "input.list");
- this.parameters.put("delimiter",",");
-
- this.ctx.setAttribute("input.list_length", "10");
- for( int i = 0; i < 10; i++ ) {
- this.ctx.setAttribute("input.list[" + i + ']', Integer.toString( rand.nextInt(10) ));
- }
-
- LOG.trace("BEFORE SORT:");
- SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE);
-
- utils.ctxSortList(this.parameters, this.ctx);
-
- LOG.trace("AFTER SORT:");
- SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE);
-
- for( int i = 0; i < 9; i++ ) {
- assertTrue(this.ctx.getAttribute("input.list[" + i + ']').compareTo(this.ctx.getAttribute("input.list[" + (i+1) + ']')) < 1 );
- }
- }
+ private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils_ctxSortList.class);
+ SliPluginUtils utils = new SliPluginUtils();
+ SvcLogicContext ctx;
+ HashMap<String,String> parameters;
+ Random rand = new Random();
+
+ @Before
+ public void setUp() throws Exception {
+ this.ctx = new SvcLogicContext();
+ this.parameters = new HashMap<String,String>();
+ }
+
+ @Test
+ public final void list_of_containers() throws SvcLogicException {
+ this.parameters.put("list", "input.list");
+ this.parameters.put("sort-fields", "sort-key");
+ this.parameters.put("delimiter",",");
+
+ ctx.setAttribute("input.list_length", "10");
+ for( int i = 0; i < 10; i++ ) {
+ this.ctx.setAttribute("input.list[" + i + "].sort-key", Integer.toString( rand.nextInt(10) ));
+ this.ctx.setAttribute("input.list[" + i + "].value", Integer.toString( rand.nextInt(10) ));
+ }
+
+ LOG.trace("BEFORE SORT:");
+ SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE);
+
+ utils.ctxSortList(this.parameters, this.ctx);
+
+ LOG.trace("AFTER SORT:");
+ SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE);
+
+ for( int i = 0; i < 9; i++ ) {
+ assertTrue(this.ctx.getAttribute("input.list[" + i + "].sort-key").compareTo(this.ctx.getAttribute("input.list[" + (i+1) + "].sort-key")) < 1 );
+ }
+ }
+
+ @Test
+ public final void list_of_elements() throws SvcLogicException {
+ this.parameters.put("list", "input.list");
+ this.parameters.put("delimiter",",");
+
+ this.ctx.setAttribute("input.list_length", "10");
+ for( int i = 0; i < 10; i++ ) {
+ this.ctx.setAttribute("input.list[" + i + ']', Integer.toString( rand.nextInt(10) ));
+ }
+
+ LOG.trace("BEFORE SORT:");
+ SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE);
+
+ utils.ctxSortList(this.parameters, this.ctx);
+
+ LOG.trace("AFTER SORT:");
+ SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE);
+
+ for( int i = 0; i < 9; i++ ) {
+ assertTrue(this.ctx.getAttribute("input.list[" + i + ']').compareTo(this.ctx.getAttribute("input.list[" + (i+1) + ']')) < 1 );
+ }
+ }
+
+ @Test
+ public void testGenerateUUID() throws SvcLogicException
+ {
+ SliPluginUtils utils= new SliPluginUtils();
+ this.parameters.put("ctx-destination", "testDestination");
+ utils.generateUUID(this.parameters, ctx);
+ }
+
+ @Test
+ public void testSubstring() throws SvcLogicException
+ {
+ SliPluginUtils utils= new SliPluginUtils();
+ this.parameters.put("string", "testString");
+ this.parameters.put("begin-index", "1");
+ this.parameters.put("result", "testResult");
+ this.parameters.put("end-index", "5");
+ utils.substring(this.parameters, ctx);
+ assertEquals("estS",ctx.getAttribute("testResult"));
+ }
+
+ @Test
+ public void testSubstringForNullEndIndex() throws SvcLogicException
+ {
+ SliPluginUtils utils= new SliPluginUtils();
+ this.parameters.put("string", "testString");
+ this.parameters.put("begin-index", "1");
+ this.parameters.put("result", "testResult");
+ utils.substring(this.parameters, ctx);
+ assertEquals("estString",ctx.getAttribute("testResult"));
+ }
+
+ @Test
+ public void testCtxBulkCopy()
+ {
+ ctx.setAttribute("Mykey1", "MyValue1");
+ ctx.setAttribute("Mykey2", "MyValue2");
+ SliPluginUtils.ctxBulkCopy(ctx, "Mykey", "test.");
+ assertEquals("MyValue1",ctx.getAttribute("test.1"));
+ assertEquals("MyValue2",ctx.getAttribute("test.2"));
+ }
}