From 48c0cd8b7726436d876cbc86c91e92b80583531b Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Fri, 31 Jan 2020 17:52:01 +0000 Subject: minor sli provider base changes add more unit testing, use constants for success/failure and improve some logging calls Issue-ID: CCSDK-2064 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I2c7039c706de1172bd506a20e96eb987cc86f211 --- .../ccsdk/sli/core/slipluginutils/SliPluginUtils.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'sliPluginUtils/provider/src/main') diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java index 1fc05253..0d9ab217 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java @@ -41,6 +41,7 @@ import java.util.Set; import java.util.UUID; import org.apache.commons.lang3.StringUtils; import org.apache.commons.text.StringEscapeUtils; +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.SvcLogicJavaPlugin; @@ -935,19 +936,19 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { try { checkParameters(parameters, new String[]{"root"}, LOG); } catch (Exception ex) { - return "failure"; + return SvcLogicConstants.FAILURE; } String root = parameters.get("root"); if (StringUtils.isEmpty(root)) { - return "failure"; + return SvcLogicConstants.FAILURE; } // set context memory to the the properties passed with root as prefix setParameterValuesToRoot(parameters, ctx, root); - return "success"; + return SvcLogicConstants.SUCCESS; } private static boolean setParameterValuesToRoot(Map parameters, SvcLogicContext ctx, String root) { @@ -1003,7 +1004,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { checkParameters(parameters, new String[]{"prefixKey", "keyName", "keyValue"}, LOG); } catch (Exception e) { LOG.error("a required parameter is missing"); - return "failure"; + return SvcLogicConstants.FAILURE; } String prefixKey = parameters.get("prefixKey"); @@ -1012,7 +1013,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { if (StringUtils.isEmpty(keyName) || StringUtils.isEmpty(keyValue) || StringUtils.isEmpty(prefixKey)) { LOG.error("a required parameters value is empty or null"); - return "failure"; + return SvcLogicConstants.FAILURE; } int listLength = getArrayLength(ctx, prefixKey); @@ -1037,7 +1038,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { + "but " + map.size() + " entries were found in context memory " + "where the key begins with: " + prefixKey); - return "failure"; + return SvcLogicConstants.FAILURE; } } else if (ctxListContains(containParams, ctx) == "false") { setNewEntryInList(parameters, ctx, keyName, keyValue, prefixKey, valuePrefixKey, listLength); @@ -1059,10 +1060,10 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { } catch (SvcLogicException e) { LOG.error("Call to ctxListContains failed: " + e.getMessage()); - return "failure"; + return SvcLogicConstants.FAILURE; } - return "success"; + return SvcLogicConstants.SUCCESS; } private static void setNewEntryInList(Map parameters, SvcLogicContext ctx, String keyName, -- cgit 1.2.3-korg