summaryrefslogtreecommitdiffstats
path: root/sli/provider-base/src/test/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'sli/provider-base/src/test/java/org/onap')
-rw-r--r--sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/BadPlugin.java56
-rw-r--r--sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutorTest.java64
-rw-r--r--sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/GraphTests.java61
-rw-r--r--sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/HashMapResolverTest.java51
-rw-r--r--sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/InMemorySvcLogicStoreTest.java35
-rw-r--r--sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/LunchSelectorPlugin.java78
-rw-r--r--sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/PluginTest.java113
-rw-r--r--sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutorTest.java220
-rw-r--r--sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolverTest.java280
-rw-r--r--sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java49
-rw-r--r--sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestSlf4jRecorder.java33
11 files changed, 1040 insertions, 0 deletions
diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/BadPlugin.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/BadPlugin.java
new file mode 100644
index 000000000..6c5877ebc
--- /dev/null
+++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/BadPlugin.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.core.sli.provider.base;
+
+import java.util.Map;
+
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
+
+
+public class BadPlugin implements SvcLogicJavaPlugin {
+ public String selectLunch(Map<String, String> parameters, SvcLogicContext ctx) throws SvcLogicException {
+ String day = parameters.get("day");
+ if (day == null || day.length() < 1) {
+ throw new SvcLogicException("What day is it?");
+ }
+ switch (day) {
+ case ("monday"): {
+ return "pizza";
+ }
+ case ("tuesday"): {
+ return "soup";
+ }
+ case ("wednesday"): {
+ return "salad";
+ }
+ case ("thursday"): {
+ return "sushi";
+ }
+ case ("friday"): {
+ return "bbq";
+ }
+ }
+ throw new SvcLogicException("Lunch cannot be served");
+ }
+}
diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutorTest.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutorTest.java
new file mode 100644
index 000000000..9a929387f
--- /dev/null
+++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutorTest.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.core.sli.provider.base;
+
+import java.util.Properties;
+import org.onap.ccsdk.sli.core.sli.DuplicateValueException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicExpression;
+import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
+import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
+import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
+import junit.framework.TestCase;
+
+public class ExecuteNodeExecutorTest extends TestCase {
+ public class MockExecuteNodeExecutor extends ExecuteNodeExecutor {
+
+ protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName) {
+ return (SvcLogicJavaPlugin) new LunchSelectorPlugin();
+ }
+
+ protected String evaluate(SvcLogicExpression expr, SvcLogicNode node,
+ SvcLogicContext ctx) throws SvcLogicException {
+ return "selectLunch";
+ }
+ }
+
+ public void testBadPlugin() throws DuplicateValueException, SvcLogicException {
+ LunchSelectorPlugin p = new LunchSelectorPlugin();
+ MockExecuteNodeExecutor execute = new MockExecuteNodeExecutor();
+ SvcLogicNode node = new SvcLogicNode(0, "", "", new SvcLogicGraph());
+ node.setAttribute("method", "selectLunch");
+ SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProvider() {
+
+ public Properties getProperties() {
+ return new Properties();
+ };
+ };
+
+
+ execute.execute(new SvcLogicServiceImplBase(null, null), new SvcLogicNode(0, "", "", new SvcLogicGraph()),
+ new SvcLogicContext());
+ }
+
+}
diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/GraphTests.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/GraphTests.java
new file mode 100644
index 000000000..3534d5f90
--- /dev/null
+++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/GraphTests.java
@@ -0,0 +1,61 @@
+package org.onap.ccsdk.sli.core.sli.provider.base;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
+import org.onap.ccsdk.sli.core.sli.SvcLogicParser;
+import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder;
+import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GraphTests {
+
+ private static final Logger LOG = LoggerFactory.getLogger(GraphTests.class);
+ private static final SvcLogicStore store = new InMemorySvcLogicStore();
+ private static final HashMapResolver resolver = new HashMapResolver();
+ private static final SvcLogicServiceBase svc = new SvcLogicServiceImplBase(store, resolver);
+ private static final SvcLogicParser p = new SvcLogicParser();
+ // Write a very simple recorder so record nodes can be used during debugging
+ private static final SvcLogicRecorder recorder = new SvcLogicRecorder() {
+ @Override
+ public void record(Map<String, String> map) throws SvcLogicException {
+ map.remove("level");
+ for (Entry<String, String> entry : map.entrySet()) {
+ LOG.debug(entry.getKey() + " = " + entry.getValue());
+ }
+ }
+ };
+
+ @Test
+ public void testBreakNode() throws Exception {
+ // This graph as a for node that will loop with start 0 and end 999
+ // in the loop idx is printed and variable "a" is incremented by 1
+ // there is an if block in the loop that when a equals 2 a break node should execute and break out of the for
+ // loop
+ SvcLogicContext ctx = executeGraph("src/test/resources/breakGraph.xml");
+ assertTrue(ctx.isSuccess());
+ assertEquals("2", ctx.getAttribute("idx")); // the break should happen when idx equals 2
+ assertEquals("3", ctx.getAttribute("a")); // incrementing a happens before the break so a should be idx + 1
+ }
+
+ public SvcLogicContext executeGraph(String pathToGraph) throws SvcLogicException {
+ return executeGraph(pathToGraph, new SvcLogicContext());
+ }
+
+ public SvcLogicContext executeGraph(String pathToGraph, SvcLogicContext context) throws SvcLogicException {
+ resolver.addSvcLogicRecorder("org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder", recorder);
+ LinkedList<SvcLogicGraph> graphList = p.parse(pathToGraph);
+ SvcLogicGraph graph = graphList.get(0);
+ store.store(graph);
+ store.activate(graph);
+ return svc.execute(graph, context);
+ }
+
+}
diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/HashMapResolverTest.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/HashMapResolverTest.java
new file mode 100644
index 000000000..5a2140696
--- /dev/null
+++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/HashMapResolverTest.java
@@ -0,0 +1,51 @@
+package org.onap.ccsdk.sli.core.sli.provider.base;
+
+import static org.junit.Assert.assertNotNull;
+import org.junit.Rule;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor;
+import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
+import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder;
+import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
+
+public class HashMapResolverTest {
+ @Mock
+ SvcLogicResource myResource;
+
+ @Mock
+ SvcLogicRecorder myRecorder;
+
+ @Mock
+ SvcLogicJavaPlugin myJavaPlugin;
+
+ @Mock
+ SvcLogicAdaptor myAdaptor;
+
+ @Rule
+ public MockitoRule mockitoRule = MockitoJUnit.rule();
+
+ @Test
+ public void simpleTest() throws Exception {
+
+ HashMapResolver resolver = new HashMapResolver();
+ String resourceKey = "simple.resource";
+ String recorderKey = "simple.record";
+ String pluginKey = "simple.plugin";
+ String adaptorKey = "simple.adaptor";
+
+ resolver.addSvcLogicAdaptor(adaptorKey, myAdaptor);
+ resolver.addSvcLogicRecorder(recorderKey, myRecorder);
+ resolver.addSvcLogicResource(resourceKey, myResource);
+ resolver.addSvcLogicSvcLogicJavaPlugin(pluginKey, myJavaPlugin);
+
+ assertNotNull(resolver.getSvcLogicAdaptor(adaptorKey));
+ assertNotNull(resolver.getSvcLogicJavaPlugin(pluginKey));
+ assertNotNull(resolver.getSvcLogicRecorder(recorderKey));
+ assertNotNull(resolver.getSvcLogicResource(resourceKey));
+
+
+ }
+}
diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/InMemorySvcLogicStoreTest.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/InMemorySvcLogicStoreTest.java
new file mode 100644
index 000000000..5f8757aa2
--- /dev/null
+++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/InMemorySvcLogicStoreTest.java
@@ -0,0 +1,35 @@
+package org.onap.ccsdk.sli.core.sli.provider.base;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import java.util.Properties;
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
+
+public class InMemorySvcLogicStoreTest {
+ @Test
+ public void simpleTest() throws Exception {
+ InMemorySvcLogicStore store = new InMemorySvcLogicStore();
+ store.init(new Properties());
+ SvcLogicGraph graph = new SvcLogicGraph();
+ String module = "TEST";
+ String rpc = "NOTIFICATION";
+ String mode = "sync";
+ String version = "1";
+
+ graph.setModule(module);
+ graph.setRpc(rpc);
+ graph.setMode(mode);
+ graph.setVersion(version);
+
+ store.store(graph);
+ assertTrue(store.hasGraph(module, rpc, version, mode));
+ assertNotNull(store.fetch(module, rpc, version, mode));
+ store.activate(graph);
+ store.activate(module, rpc, version, mode);
+
+ store.delete(module, rpc, version, mode);
+ assertNull(store.fetch(module, rpc, version, mode));
+ }
+}
diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/LunchSelectorPlugin.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/LunchSelectorPlugin.java
new file mode 100644
index 000000000..0f4cab748
--- /dev/null
+++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/LunchSelectorPlugin.java
@@ -0,0 +1,78 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.core.sli.provider.base;
+
+import java.util.Map;
+
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
+
+
+
+public class LunchSelectorPlugin implements SvcLogicJavaPlugin {
+ public class UnknownLunchDayException extends Exception{
+
+ public UnknownLunchDayException(String string) {
+ super(string);
+ }
+
+ }
+ class Sandwhich {
+ String meat;
+ String cheese;
+
+ public Sandwhich(String meat, String cheese) {
+ this.meat = meat;
+ this.cheese = cheese;
+ }
+ }
+
+ public String selectLunch(Map<String, String> parameters, SvcLogicContext ctx) throws Exception {
+ String day = parameters.get("day");
+ if (day == null || day.length() < 1) {
+ throw new UnknownLunchDayException("What day is it?");
+ }
+ switch (day) {
+ case ("monday"): {
+ return "pizza";
+ }
+ case ("tuesday"): {
+ return "soup";
+ }
+ case ("wednesday"): {
+ return "salad";
+ }
+ case ("thursday"): {
+ return "sushi";
+ }
+ case ("friday"): {
+ return "bbq";
+ }
+ }
+ throw new SvcLogicException("Lunch cannot be served");
+ }
+
+ public Sandwhich makeLunch(Map<String, String> parameters, SvcLogicContext ctx) throws SvcLogicException {
+ return new Sandwhich("ham", "american");
+ }
+}
diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/PluginTest.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/PluginTest.java
new file mode 100644
index 000000000..b154ecf01
--- /dev/null
+++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/PluginTest.java
@@ -0,0 +1,113 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.core.sli.provider.base;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import org.onap.ccsdk.sli.core.sli.SvcLogicConstants;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
+import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
+import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
+import org.onap.ccsdk.sli.core.sli.provider.base.ExecuteNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicExpressionResolver;
+
+import junit.framework.TestCase;
+
+public class PluginTest extends TestCase {
+
+ // The existing plugins work just like a VoidDummyPlugin
+ // They will return null simply because they are all void
+ // The attribute emitsOutcome will not be present, the expected outcome is success when no exception is thrown by the plugin
+ public void testOldPlugin() throws Exception {
+ ExecuteNodeExecutor executor = new ExecuteNodeExecutor();
+ SvcLogicJavaPlugin plugin = new SvcLogicJavaPlugin() {
+ public void dummy(Map<String, String> parameters, SvcLogicContext ctx) throws SvcLogicException {
+ return;
+ }
+ };
+
+ Class pluginClass = plugin.getClass();
+ Method pluginMethod = pluginClass.getMethod("dummy", Map.class, SvcLogicContext.class);
+ Map<String, String> parmMap = new HashMap<String, String>();
+ SvcLogicContext ctx = new SvcLogicContext();
+ Object o = pluginMethod.invoke(plugin, parmMap, ctx);
+
+ SvcLogicGraph graph = new SvcLogicGraph();
+ SvcLogicNode node = new SvcLogicNode(1, "return", graph);
+ String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx);
+ String outValue = executor.mapOutcome(o, emitsOutcome);
+ assertEquals(SvcLogicConstants.SUCCESS,outValue);
+ }
+
+ //Newer plugins can set the attribute emitsOutcome to true, if so they should return a string
+ //The string represents the outcome value
+ public void testNewPlugin() throws Exception {
+ ExecuteNodeExecutor executor = new ExecuteNodeExecutor();
+ SvcLogicJavaPlugin plugin = new LunchSelectorPlugin();
+
+ Class pluginClass = plugin.getClass();
+ Method pluginMethod = pluginClass.getMethod("selectLunch", Map.class, SvcLogicContext.class);
+
+ Map<String, String> parmMap = new HashMap<String, String>();
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ parmMap.put("day", "monday");
+ Object o = pluginMethod.invoke(plugin, parmMap, ctx);
+ SvcLogicGraph graph = new SvcLogicGraph();
+ SvcLogicNode node = new SvcLogicNode(1, "return", graph);
+ node.setAttribute("emitsOutcome", "true");
+ String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx);
+ String outValue = executor.mapOutcome(o, emitsOutcome);
+ assertEquals("pizza", outValue);
+
+ parmMap.put("day", "tuesday");
+ outValue = (String) pluginMethod.invoke(plugin, parmMap, ctx);
+ o = pluginMethod.invoke(plugin, parmMap, ctx);
+ outValue = executor.mapOutcome(o, emitsOutcome);
+ assertEquals("soup",outValue);
+
+ }
+
+ //APPC had some legacy plugins returning objects which should not be treated as outcomes
+ //The attribute emitsOutcome will not be set
+ //The outcome should be success as it has always been
+ public void testObjPlugin() throws Exception{
+ ExecuteNodeExecutor executor = new ExecuteNodeExecutor();
+ SvcLogicJavaPlugin plugin = new LunchSelectorPlugin();
+
+ Class pluginClass = plugin.getClass();
+ Method pluginMethod = pluginClass.getMethod("makeLunch", Map.class, SvcLogicContext.class);
+
+ Map<String, String> parmMap = new HashMap<String, String>();
+ SvcLogicContext ctx = new SvcLogicContext();
+ Object o = pluginMethod.invoke(plugin, parmMap, ctx);
+ SvcLogicGraph graph = new SvcLogicGraph();
+ SvcLogicNode node = new SvcLogicNode(1, "return", graph);
+ String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx);
+ String outValue = executor.mapOutcome(o, emitsOutcome);
+ assertEquals(SvcLogicConstants.SUCCESS,outValue);
+ }
+
+}
diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutorTest.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutorTest.java
new file mode 100644
index 000000000..115989a80
--- /dev/null
+++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutorTest.java
@@ -0,0 +1,220 @@
+package org.onap.ccsdk.sli.core.sli.provider.base;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import java.util.LinkedList;
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
+import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
+import org.onap.ccsdk.sli.core.sli.SvcLogicParser;
+import org.onap.ccsdk.sli.core.sli.provider.base.SetNodeExecutor;
+
+public class SetNodeExecutorTest {
+ @Test
+ public void clearProperties() throws Exception {
+ SetNodeExecutor sne = new SetNodeExecutor();
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ SvcLogicParser slp = new SvcLogicParser();
+ LinkedList<SvcLogicGraph> graph = slp.parse("src/test/resources/clearValues.xml");
+ SvcLogicNode root = graph.getFirst().getRootNode();
+ SvcLogicNode nodeOne = root.getOutcomeValue("1");
+ SvcLogicNode nodeTwo = root.getOutcomeValue("2");
+
+ sne.execute(nodeOne, ctx);
+ sne.execute(nodeTwo, ctx);
+
+ assertNull(ctx.getAttribute("si.field1"));
+ assertNull(ctx.getAttribute("si.field2"));
+ assertNull(ctx.getAttribute("si.field3"));
+ assertNull(ctx.getAttribute("si.subarray[0]"));
+ assertNull(ctx.getAttribute("si.subarray[1]"));
+ assertNull(ctx.getAttribute("si.subarray[2]"));
+ assertNull(ctx.getAttribute("si.subarray_length"));
+ assertEquals("6", ctx.getAttribute("search1"));
+ assertEquals("KeepMe!", ctx.getAttribute("simonSays"));
+ }
+
+ @Test
+ public void clearMultipleArrayProperties() throws Exception {
+ SetNodeExecutor sne = new SetNodeExecutor();
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ SvcLogicParser slp = new SvcLogicParser();
+ LinkedList<SvcLogicGraph> graph = slp.parse("src/test/resources/clearMultipleArrayValues.xml");
+ SvcLogicNode root = graph.getFirst().getRootNode();
+ SvcLogicNode nodeOne = root.getOutcomeValue("1");
+ SvcLogicNode nodeTwo = root.getOutcomeValue("2");
+
+ sne.execute(nodeOne, ctx);
+ sne.execute(nodeTwo, ctx);
+
+ assertNull(ctx.getAttribute("si[0].field1"));
+ assertNull(ctx.getAttribute("si[1].field2"));
+ assertNull(ctx.getAttribute("si[2].field3"));
+ assertNull(ctx.getAttribute("si_length"));
+ assertNull(ctx.getAttribute("si[0].subarray[0]"));
+ assertNull(ctx.getAttribute("si[0].subarray[1]"));
+ assertNull(ctx.getAttribute("si[0].subarray[2]"));
+ assertNull(ctx.getAttribute("si[0].subarray_length"));
+ assertEquals("6", ctx.getAttribute("search1"));
+ assertEquals("KeepMe!", ctx.getAttribute("simonSays"));
+ }
+
+ @Test
+ public void clearSingleArrayProperties() throws Exception {
+ SetNodeExecutor sne = new SetNodeExecutor();
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ SvcLogicParser slp = new SvcLogicParser();
+ LinkedList<SvcLogicGraph> graph = slp.parse("src/test/resources/clearSingleArrayValues.xml");
+ SvcLogicNode root = graph.getFirst().getRootNode();
+ SvcLogicNode nodeOne = root.getOutcomeValue("1");
+ SvcLogicNode nodeTwo = root.getOutcomeValue("2");
+
+ sne.execute(nodeOne, ctx);
+ sne.execute(nodeTwo, ctx);
+
+ assertNull(ctx.getAttribute("si[0].field1"));
+ assertNull(ctx.getAttribute("si[0].subarray[0]"));
+ assertNull(ctx.getAttribute("si[0].subarray[1]"));
+ assertNull(ctx.getAttribute("si[0].subarray[2]"));
+ assertNull(ctx.getAttribute("si[0].subarray_length"));
+
+ // TODO: This is just setting up elements as null but note reducing the size of Array.
+ assertEquals("3",ctx.getAttribute("si_length"));
+
+ assertEquals("2",ctx.getAttribute("si[1].field2"));
+ assertEquals("3", ctx.getAttribute("si[2].field3"));
+ assertEquals("6", ctx.getAttribute("search1"));
+ assertEquals("KeepMe!", ctx.getAttribute("simonSays"));
+ }
+
+ @Test
+ public void clearSingleSubArrayProperties() throws Exception {
+ SetNodeExecutor sne = new SetNodeExecutor();
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ SvcLogicParser slp = new SvcLogicParser();
+ LinkedList<SvcLogicGraph> graph = slp.parse("src/test/resources/clearSingleSubArrayValues.xml");
+ SvcLogicNode root = graph.getFirst().getRootNode();
+ SvcLogicNode nodeOne = root.getOutcomeValue("1");
+ SvcLogicNode nodeTwo = root.getOutcomeValue("2");
+
+ sne.execute(nodeOne, ctx);
+ sne.execute(nodeTwo, ctx);
+
+ assertEquals("1",ctx.getAttribute("tmp.si[0].field1"));
+ assertEquals("2",ctx.getAttribute("tmp.si[1].field2"));
+ assertEquals("3", ctx.getAttribute("tmp.si[2].field3"));
+ assertEquals("3", ctx.getAttribute("tmp.si_length"));
+
+ assertEquals("a",ctx.getAttribute("tmp.si[0].subarray[0]"));
+
+ // TODO: This is setting up element as Empty instead null
+ //assertNull(ctx.getAttribute("tmp.si[0].subarray[1]"));
+ assertEquals("", ctx.getAttribute("tmp.si[0].subarray[1]"));
+
+ assertEquals("c", ctx.getAttribute("tmp.si[0].subarray[2]"));
+ assertEquals("3", ctx.getAttribute("tmp.si[0].subarray_length"));
+
+ assertEquals("x",ctx.getAttribute("tmp.si[1].subarray[0]"));
+ assertEquals("y",ctx.getAttribute("tmp.si[1].subarray[1]"));
+ assertEquals("z", ctx.getAttribute("tmp.si[1].subarray[2]"));
+ assertEquals("3", ctx.getAttribute("tmp.si[1].subarray_length"));
+
+ assertEquals("6", ctx.getAttribute("search1"));
+ assertEquals("KeepMe!", ctx.getAttribute("simonSays"));
+ }
+
+ @Test
+ public void clearSubArrayProperties() throws Exception {
+ SetNodeExecutor sne = new SetNodeExecutor();
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ SvcLogicParser slp = new SvcLogicParser();
+ LinkedList<SvcLogicGraph> graph = slp.parse("src/test/resources/clearSubArrayValues.xml");
+ SvcLogicNode root = graph.getFirst().getRootNode();
+ SvcLogicNode nodeOne = root.getOutcomeValue("1");
+ SvcLogicNode nodeTwo = root.getOutcomeValue("2");
+
+ sne.execute(nodeOne, ctx);
+ sne.execute(nodeTwo, ctx);
+
+ assertEquals("1", ctx.getAttribute("si[0].field1"));
+ assertEquals("2",ctx.getAttribute("si[1].field2"));
+ assertEquals("3", ctx.getAttribute("si[2].field3"));
+ assertEquals("3", ctx.getAttribute("si_length"));
+ assertNull(ctx.getAttribute("si[0].subarray[0]"));
+ assertNull(ctx.getAttribute("si[0].subarray[1]"));
+ assertNull(ctx.getAttribute("si[0].subarray[2]"));
+ assertNull(ctx.getAttribute("si[0].subarray_length"));
+
+ assertEquals("6", ctx.getAttribute("search1"));
+ assertEquals("KeepMe!", ctx.getAttribute("simonSays"));
+ }
+
+ @Test
+ public void arrayPattern() {
+ SetNodeExecutor sne = new SetNodeExecutor();
+ String source = "one.two[0].three[0].four";
+ assertEquals("one.two.three.four", source.replaceAll(sne.arrayPattern, ""));
+ }
+
+ @Test
+ public void subtreeCopy() throws Exception {
+ SetNodeExecutor sne = new SetNodeExecutor();
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ SvcLogicParser slp = new SvcLogicParser();
+ LinkedList<SvcLogicGraph> graph = slp.parse("src/test/resources/copyValues.xml");
+ SvcLogicNode root = graph.getFirst().getRootNode();
+ SvcLogicNode nodeOne = root.getOutcomeValue("1");
+ SvcLogicNode nodeTwo = root.getOutcomeValue("2");
+
+ sne.execute(nodeOne, ctx);
+ sne.execute(nodeTwo, ctx);
+
+ assertEquals("1", ctx.getAttribute("si.field1"));
+ assertEquals("2", ctx.getAttribute("si.field2"));
+ assertEquals("3", ctx.getAttribute("si.field3"));
+ assertEquals("1", ctx.getAttribute("rootTwo.field1"));
+ assertEquals("2", ctx.getAttribute("rootTwo.field2"));
+ assertEquals("3", ctx.getAttribute("rootTwo.field3"));
+ }
+
+ @Test
+ public void clearNestedSubArrayProperties() throws Exception {
+ SetNodeExecutor sne = new SetNodeExecutor();
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ SvcLogicParser slp = new SvcLogicParser();
+ LinkedList<SvcLogicGraph> graph = slp.parse("src/test/resources/clearNestedSubArrayValues.xml");
+ SvcLogicNode root = graph.getFirst().getRootNode();
+ SvcLogicNode nodeOne = root.getOutcomeValue("1");
+ SvcLogicNode nodeTwo = root.getOutcomeValue("2");
+
+ sne.execute(nodeOne, ctx);
+ sne.execute(nodeTwo, ctx);
+
+ assertEquals("1", ctx.getAttribute("tmp.si[0].field1"));
+ assertEquals("2",ctx.getAttribute("tmp.si[1].field2"));
+ assertEquals("3", ctx.getAttribute("tmp.si[2].field3"));
+ assertEquals("3", ctx.getAttribute("tmp.si_length"));
+
+ assertNull(ctx.getAttribute("tmp.si[0].subarray[0]"));
+ assertNull(ctx.getAttribute("tmp.si[0].subarray[1]"));
+ assertNull(ctx.getAttribute("tmp.si[0].subarray[2]"));
+ assertNull(ctx.getAttribute("tmp.si[0].subarray_length"));
+
+ assertEquals("x", ctx.getAttribute("tmp.si[1].subarray[0]"));
+ assertEquals("y",ctx.getAttribute("tmp.si[1].subarray[1]"));
+ assertEquals("z", ctx.getAttribute("tmp.si[1].subarray[2]"));
+ assertEquals("3", ctx.getAttribute("tmp.si[1].subarray_length"));
+
+ assertEquals("6", ctx.getAttribute("search1"));
+ assertEquals("KeepMe!", ctx.getAttribute("simonSays"));
+ }
+
+}
diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolverTest.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolverTest.java
new file mode 100644
index 000000000..054b38d0f
--- /dev/null
+++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolverTest.java
@@ -0,0 +1,280 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.core.sli.provider.base;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.LinkedList;
+
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicExprListener;
+import org.onap.ccsdk.sli.core.sli.SvcLogicExpression;
+import org.onap.ccsdk.sli.core.sli.SvcLogicExpressionFactory;
+import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
+import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicExpressionResolver;
+import org.onap.ccsdk.sli.core.sli.SvcLogicParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+public class SvcLogicExpressionResolverTest extends TestCase {
+
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(SvcLogicExpressionResolver.class);
+
+ public void testEvaluate()
+ {
+ InputStream testStr = getClass().getResourceAsStream("/expression.tests");
+ BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr));
+
+ try
+ {
+ SvcLogicContext ctx = new SvcLogicContext();
+ SvcLogicGraph graph = new SvcLogicGraph();
+ SvcLogicNode node = new SvcLogicNode(1, "return", graph);
+ graph.setRootNode(node);
+
+ String line = null;
+ int lineNo = 0;
+ while ((line = testsReader.readLine()) != null) {
+ ++lineNo;
+ if (line.startsWith("#"))
+ {
+ String testExpr = line.trim().substring(1).trim();
+ String[] nameValue = testExpr.split("=");
+ String name = nameValue[0].trim();
+ String value = nameValue[1].trim();
+
+ if (name.startsWith("$"))
+ {
+ LOG.info("Setting context attribute "+name+" = "+value);
+ ctx.setAttribute(name.substring(1), value);
+ }
+ else
+ {
+
+ LOG.info("Setting node attribute "+name+" = "+value);
+ node.setAttribute(name, value);
+
+ }
+ }
+ else
+ {
+ // if the line contains #, what comes before is the expression to evaluate, and what comes after
+ // is the expected value
+ String[] substrings = line.split("#");
+ String expectedValue = substrings.length > 1 ? substrings[1].trim() : null;
+ String testExpr = substrings[0].trim();
+
+ LOG.info("Parsing expression "+testExpr);
+ SvcLogicExpression expr = SvcLogicExpressionFactory.parse(testExpr);
+ if (expr == null)
+ {
+ fail("Unable to parse expression "+testExpr);
+ }
+ else
+ {
+ LOG.info("Evaluating parsed expression "+expr.asParsedExpr());
+ String exprValue = SvcLogicExpressionResolver.evaluate(expr, node, ctx);
+ if (exprValue == null)
+ {
+ fail("Unable to evaluate expression "+testExpr);
+ }
+ else
+ {
+ LOG.info("Expression " + testExpr + " evaluates to " + exprValue);
+ if (expectedValue != null) {
+ Assert.assertEquals("Line " + lineNo + ": " + testExpr, expectedValue, exprValue);
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ LOG.error("Caught exception", e);
+ fail("Caught exception");
+ }
+ }
+
+ public void testSvcLogicExpressions() throws Exception {
+ SwitchNodeExecutor switchNodeExecutor = new SwitchNodeExecutor();
+ SetNodeExecutor setNodeExecutor = new SetNodeExecutor();
+ SvcLogicContext ctx = new SvcLogicContext();
+ SvcLogicParser slp = new SvcLogicParser();
+ LinkedList<SvcLogicGraph> graph = slp.parse("src/test/resources/expressions.xml");
+ SvcLogicNode root = graph.getFirst().getRootNode();
+//Test a set node that makes use of arithmetic operations
+/*
+<set>
+ <parameter name='add' value='`1 + 1`' />
+ <parameter name='sub' value='`2 - 1`' />
+ <parameter name='div' value='`6 / 2`' />
+ <parameter name='multi' value='`2 * 2`' />
+ <parameter name='addDoubleQuotes' value="`1 + 1`" />
+ <parameter name='subDoubleQuotes' value="`2 - 1`" />
+ <parameter name='divDoubleQuotes' value="`6 / 2`" />
+ <parameter name='multiDoubleQuotes' value="`2 * 2`" />
+</set>
+*/
+//the node matching outcome value 1 comes from parsing the block of xml above
+ ctx.setAttribute("a", "5");
+ ctx.setAttribute("b", "3");
+ setNodeExecutor.execute(root.getOutcomeValue("1"), ctx);
+ assertEquals("2", ctx.getAttribute("add"));
+ assertEquals("1", ctx.getAttribute("sub"));
+ assertEquals("3", ctx.getAttribute("div"));
+ assertEquals("4", ctx.getAttribute("multi"));
+ assertEquals("2", ctx.getAttribute("addDoubleQuotes"));
+ assertEquals("1", ctx.getAttribute("subDoubleQuotes"));
+ assertEquals("3", ctx.getAttribute("divDoubleQuotes"));
+ assertEquals("4", ctx.getAttribute("multiDoubleQuotes"));
+
+//Test a set node that makes use of string concatenation
+/*
+<set>
+ <parameter name='varA' value='`$a + $b`' />
+ <parameter name='varB' value='`$a + &apos;literal&apos; `' />
+ <parameter name='varC' value='`&apos;literal&apos; + $b `' />
+ <parameter name='varD' value='`&apos;too&apos; + &apos;literal&apos;`' />
+ <parameter name='varADoubleQuotes' value="`$a + $b`" />
+ <parameter name='varBDoubleQuotes' value="`$a +'literal' `" />
+ <parameter name='varCDoubleQuotes' value="`'literal' + $b `" />
+ <parameter name='varDDoubleQuotes' value="`'too' + 'literal'`" />
+</set>
+*/
+//the node matching outcome value 2 comes from parsing the block of xml above
+ ctx.setAttribute("a", "cat");
+ ctx.setAttribute("b", "dog");
+ setNodeExecutor.execute(root.getOutcomeValue("2"), ctx);
+ assertEquals("catdog", ctx.getAttribute("varA"));
+ assertEquals("catliteral", ctx.getAttribute("varB"));
+ assertEquals("literaldog", ctx.getAttribute("varC"));
+ assertEquals("tooliteral", ctx.getAttribute("varD"));
+ assertEquals("catdog", ctx.getAttribute("varADoubleQuotes"));
+ assertEquals("catliteral", ctx.getAttribute("varBDoubleQuotes"));
+ assertEquals("literaldog", ctx.getAttribute("varCDoubleQuotes"));
+ assertEquals("tooliteral", ctx.getAttribute("varDDoubleQuotes"));
+
+//Shows how backticks interact with + operator
+/*
+<set>
+ <parameter name='testOne' value='`1 + 1`' />
+ <parameter name='testThree' value='"1" +"1"' />
+ <parameter name='testFour' value='`$portNumber + $slot + $shelf`' />
+ <parameter name='testOneDoubleQuotes' value="`1 + 1`" />
+ <parameter name='testThreeDoubleQuotes' value="'1' +'1'" />
+ <parameter name='testFourDoubleQuotes' value="`$portNumber + $slot + $shelf`" />
+</set>
+*/
+//the node matching outcome value 3 comes from parsing the block of xml above
+ ctx.setAttribute("portNumber", "2");
+ ctx.setAttribute("slot", "3");
+ ctx.setAttribute("shelf", "1");
+
+ setNodeExecutor.execute(root.getOutcomeValue("3"), ctx);
+ assertEquals("2", ctx.getAttribute("testOne"));
+ assertEquals("\"1\" +\"1\"", ctx.getAttribute("testThree"));
+ assertEquals("6", ctx.getAttribute("testFour"));
+ assertEquals("2", ctx.getAttribute("testOneDoubleQuotes"));
+ assertEquals("'1' +'1'", ctx.getAttribute("testThreeDoubleQuotes"));
+ assertEquals("6", ctx.getAttribute("testFourDoubleQuotes"));
+
+ ctx.setAttribute("a", "5");
+ ctx.setAttribute("b", "3");
+
+ // series of switch statements showing and or != > < >= == <=
+ // the XML for the node is commented above the line that evaluates that node, the switch statements are single line
+
+ //<switch test="`'PIZZA' == 'NOTPIZZA' or $a != $b`" />
+ assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("4"), ctx));
+
+ //<switch test="`'PIZZA' == 'PIZZA' and $a != $b`" />
+ assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("5"), ctx));
+
+ //<switch test="`'PIZZA' == 'NOTPIZZA' or $a &gt;= $b`" />
+ assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("6"), ctx));
+
+ //<switch test="`'PIZZA' == 'PIZZA' and $b &lt; $a`" />
+ assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("7"), ctx));
+
+ //<switch test="`'PIZZA' == 'PIZZA'`" />
+ assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("8"), ctx));
+
+ //<switch test="`$a == $b`" />
+ assertEquals("false",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("9"), ctx));
+
+ //<switch test="`'PIZZA' == 'NOTPIZZA'`" />
+ assertEquals("false",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("10"), ctx));
+
+ //<switch test="`'PIZZA' != 'PIZZA'`" />
+ assertEquals("false",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("11"), ctx));
+
+ //<switch test="`'PIZZA' != 'NOTPIZZA'`" />
+ assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("12"), ctx));
+
+ //<switch test='`$a != $b`' />
+ assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("13"), ctx));
+
+ //<switch test='`1 &lt; 2`' />
+ assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("14"), ctx));
+
+ //<switch test='`2 &lt;= 2`' />
+ assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("15"), ctx));
+
+ //<switch test='`3 &gt; 2`' />
+ assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("16"), ctx));
+
+ //<switch test='`2 &gt;= 2`' />
+ assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("17"), ctx));
+
+ // Series of switch statements that show the effect of using backticks
+
+ ctx.setAttribute("literalStartingWithDollarSign", "DONT READ ME!");
+ //<switch test='$literalStartingWithDollarSign'/>
+ assertEquals("$literalStartingWithDollarSign",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("18"), ctx));
+
+ ctx.setAttribute("dollarSignFollowedByVariableSurroundedinBackticks", "README");
+ //<switch test='$literalStartingWithDollarSign'/>
+ assertEquals("README",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("19"), ctx));
+
+ ctx.setAttribute("a", "2");
+ ctx.setAttribute("b", "2");
+ //<switch test='`$a == $b`' />
+ assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("20"), ctx));
+
+ //<switch test="`$a == $b`" />
+ assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("21"), ctx));
+
+ //<switch test='$a == $b' />
+ assertEquals("$a == $b",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("22"), ctx));
+
+ //<switch test="$a == $b" />
+ assertEquals("$a == $b",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("23"), ctx));
+ }
+}
diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java
new file mode 100644
index 000000000..d0cc83182
--- /dev/null
+++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java
@@ -0,0 +1,49 @@
+/**
+ *
+ */
+package org.onap.ccsdk.sli.core.sli.recording;
+
+import static org.junit.Assert.fail;
+
+import java.util.HashMap;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+
+/**
+ * @author dt5972
+ *
+ */
+public class TestFileRecorder {
+ private FileRecorder recorder;
+
+ @Before
+ public void setUp() {
+ recorder = new FileRecorder();
+ }
+
+ /**
+ * Test method for
+ * {@link org.onap.ccsdk.sli.core.sli.recording.FileRecorder#record(java.util.Map)}.
+ */
+ @Test
+ public void testRecord() {
+ HashMap<String, String> parms = new HashMap<>();
+ parms.put("file", "/dev/null");
+ parms.put("field1", "hi");
+ try {
+ recorder.record(parms);
+ } catch (SvcLogicException e) {
+ fail("Caught SvcLogicException : " + e.getMessage());
+ }
+ }
+
+ @Test(expected = Exception.class)
+ public void testRecordForEmptyFileName() throws Exception {
+ HashMap<String, String> parms = new HashMap<>();
+ parms.put("field1", "hi");
+ recorder.record(parms);
+ }
+
+}
diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestSlf4jRecorder.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestSlf4jRecorder.java
new file mode 100644
index 000000000..c696f25b5
--- /dev/null
+++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestSlf4jRecorder.java
@@ -0,0 +1,33 @@
+/**
+ *
+ */
+package org.onap.ccsdk.sli.core.sli.recording;
+
+import static org.junit.Assert.*;
+import java.util.HashMap;
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+
+/**
+ * @author dt5972
+ *
+ */
+public class TestSlf4jRecorder {
+
+ /**
+ * Test method for {@link org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder#record(java.util.Map)}.
+ */
+ @Test
+ public void testRecord() {
+ Slf4jRecorder recorder = new Slf4jRecorder();
+
+ HashMap<String,String> parms = new HashMap<>();
+ parms.put("field1","hi");
+ try {
+ recorder.record(parms);
+ } catch (SvcLogicException e) {
+ fail("Caught SvcLogicException : "+e.getMessage());
+ }
+ }
+
+}