Fix Sonar issues in apex 09/66809/1
authorliamfallon <liam.fallon@ericsson.com>
Sun, 16 Sep 2018 01:03:12 +0000 (02:03 +0100)
committerliamfallon <liam.fallon@ericsson.com>
Sun, 16 Sep 2018 01:04:11 +0000 (02:04 +0100)
Fixing various Sonar issues in apex.

Issue-ID: POLICY-1034
Change-Id: Ie693637d75bd7e38c71b7ba04886fb75636276ed
Signed-off-by: liamfallon <liam.fallon@ericsson.com>
56 files changed:
client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ApexDeploymentRestParameterParser.java
client/client-deployment/src/main/java/org/onap/policy/apex/client/deployment/rest/ParameterCheck.java
client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/ApexEditorMain.java
client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/ApexEditorRestResource.java
client/client-editor/src/main/java/org/onap/policy/apex/client/editor/rest/RestUtils.java
client/client-full/src/main/java/org/onap/policy/apex/client/full/rest/ApexServicesRestParameterParser.java
client/client-full/src/main/java/org/onap/policy/apex/client/full/rest/ParameterCheck.java
client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ApexMonitoringRestParameterParser.java
client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ApexMonitoringRestResource.java
client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ParameterCheck.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextBooleanItem.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextByteItem.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateItem.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDateLocaleItem.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextDoubleItem.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextFloatItem.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextIntItem.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongItem.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextLongObjectItem.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeMapItem.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/concepts/TestContextTreeSetItem.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextAlbumUpdate.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextInstantiation.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/SequentialContextInstantiation.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/factory/TestContextAlbumFactory.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/AlbumModifier.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/lock/modifier/LockType.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContext.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJvm.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/locking/ConcurrentContextJvmThread.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/ConfigrationProviderImpl.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/Constants.java
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/utils/NetworkUtils.java
core/core-deployment/src/main/java/org/onap/policy/apex/core/deployment/BatchDeployer.java
core/core-deployment/src/main/java/org/onap/policy/apex/core/deployment/PeriodicEventManager.java
core/core-engine/src/main/java/org/onap/policy/apex/core/engine/engine/EnEventListener.java
core/core-engine/src/main/java/org/onap/policy/apex/core/engine/event/EnEvent.java
core/core-engine/src/main/java/org/onap/policy/apex/core/engine/event/EnField.java
model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextAlbumFacade.java
model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyLogicReader.java
plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/main/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaHelper.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java
plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutor.java
plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutor.java
plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutor.java
services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/HeaderDelimitedTextBlockReader.java
services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/ApexEventListener.java
services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/EngineServiceEventInterface.java
testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/EvalDomainModelFactory.java
testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/TestConcurrentContext.java
testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engdep/EngDepMessagingTest.java
testsuites/performance/performance-context-metrics/src/test/java/org/onap/policy/apex/testsuites/performance/context/metrics/TestMetrics.java
tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java

index 7e30578..d56e05d 100644 (file)
@@ -38,7 +38,7 @@ import org.apache.commons.cli.ParseException;
  */
 public class ApexDeploymentRestParameterParser {
     // Apache Commons CLI options
-    Options options;
+    private Options options;
 
     /**
      * Construct the options for the CLI RESTful services.
index fb18a00..5026c51 100644 (file)
@@ -178,9 +178,9 @@ public final class ParameterCheck {
         }
 
         ParameterCheck.StartStop startStop;
-        if (startStopValue[0].equalsIgnoreCase("start")) {
+        if ("start".equalsIgnoreCase(startStopValue[0])) {
             startStop = ParameterCheck.StartStop.START;
-        } else if (startStopValue[0].equalsIgnoreCase("stop")) {
+        } else if ("stop".equalsIgnoreCase(startStopValue[0])) {
             startStop = ParameterCheck.StartStop.STOP;
         } else {
             LOGGER.warn("value \"{}\"of parameter \"{}\" not \"start\" or \"stop\"", startStopValue[0], startStopPar);
index ea4f206..4d09599 100644 (file)
@@ -64,20 +64,6 @@ public class ApexEditorMain {
     // Output and error streams for messages
     private final PrintStream outStream;
 
-    /**
-     * Main method, main entry point for command.
-     *
-     * @param args The command line arguments for the editor
-     */
-    public static void main(final String[] args) {
-        try {
-            final ApexEditorMain editorMain = new ApexEditorMain(args, System.out);
-            editorMain.init();
-        } catch (final Exception e) {
-            LOGGER.error("start failed", e);
-        }
-    }
-
     /**
      * Constructor, kicks off the editor.
      *
@@ -212,4 +198,18 @@ public class ApexEditorMain {
             }
         }
     }
+
+    /**
+     * Main method, main entry point for command.
+     *
+     * @param args The command line arguments for the editor
+     */
+    public static void main(final String[] args) {
+        try {
+            final ApexEditorMain editorMain = new ApexEditorMain(args, System.out);
+            editorMain.init();
+        } catch (final Exception e) {
+            LOGGER.error("start failed", e);
+        }
+    }
 }
index 72c2941..fed1a50 100644 (file)
@@ -536,10 +536,10 @@ public class ApexEditorRestResource {
                 return ret;
             }
 
-            if (name1 == null || name1.equals("")) {
+            if (name1 == null || "".equals(name1)) {
                 name1 = null;
             }
-            if (version1 == null || version1.equals("")) {
+            if (version1 == null || "".equals(version1)) {
                 version1 = null;
             }
 
@@ -646,10 +646,10 @@ public class ApexEditorRestResource {
                 return ret;
             }
 
-            if (name1 == null || name1.equals("")) {
+            if (name1 == null || "".equals(name1)) {
                 name1 = null;
             }
-            if (version1 == null || version1.equals("")) {
+            if (version1 == null || "".equals(version1)) {
                 version1 = null;
             }
 
@@ -690,10 +690,10 @@ public class ApexEditorRestResource {
                 return ret;
             }
 
-            if (name1 == null || name1.equals("")) {
+            if (name1 == null || "".equals(name1)) {
                 name1 = null;
             }
-            if (version1 == null || version1.equals("")) {
+            if (version1 == null || "".equals(version1)) {
                 version1 = null;
             }
 
@@ -728,10 +728,10 @@ public class ApexEditorRestResource {
         String version1 = version;
         LOGGER.entry(name1, version1);
         try {
-            if (name1 == null || name1.equals("")) {
+            if (name1 == null || "".equals(name1)) {
                 name1 = null;
             }
-            if (version1 == null || version1.equals("")) {
+            if (version1 == null || "".equals(version1)) {
                 version1 = null;
             }
 
@@ -849,10 +849,10 @@ public class ApexEditorRestResource {
                 return ret;
             }
 
-            if (name1 == null || name1.equals("")) {
+            if (name1 == null || "".equals(name1)) {
                 name1 = null;
             }
-            if (version1 == null || version1.equals("")) {
+            if (version1 == null || "".equals(version1)) {
                 version1 = null;
             }
 
@@ -893,10 +893,10 @@ public class ApexEditorRestResource {
                 return ret;
             }
 
-            if (name1 == null || name1.equals("")) {
+            if (name1 == null || "".equals(name1)) {
                 name1 = null;
             }
-            if (version1 == null || version1.equals("")) {
+            if (version1 == null || "".equals(version1)) {
                 version1 = null;
             }
 
@@ -931,10 +931,10 @@ public class ApexEditorRestResource {
         String version1 = version;
         LOGGER.entry(name1, version1);
         try {
-            if (name1 == null || name1.equals("")) {
+            if (name1 == null || "".equals(name1)) {
                 name1 = null;
             }
-            if (version1 == null || version1.equals("")) {
+            if (version1 == null || "".equals(version1)) {
                 version1 = null;
             }
 
@@ -1037,8 +1037,8 @@ public class ApexEditorRestResource {
 
             final BeanEvent jsonbean = RestUtils.getJsonParameters(jsonString, BeanEvent.class);
 
-            if (jsonbean.getName() == null || jsonbean.getName().equals("") || jsonbean.getVersion() == null
-                            || jsonbean.getVersion().equals("")) {
+            if (jsonbean.getName() == null || "".equals(jsonbean.getName()) || jsonbean.getVersion() == null
+                            || "".equals(jsonbean.getVersion())) {
                 ret = new ApexApiResult(Result.FAILED, "Null/Empty event name/version (\"" + jsonbean.getName() + ":"
                                 + jsonbean.getVersion() + "\" passed to UpdateEvent");
                 return ret;
@@ -1085,10 +1085,10 @@ public class ApexEditorRestResource {
                 return ret;
             }
 
-            if (name1 == null || name1.equals("")) {
+            if (name1 == null || "".equals(name1)) {
                 name1 = null;
             }
-            if (version1 == null || version1.equals("")) {
+            if (version1 == null || "".equals(version1)) {
                 version1 = null;
             }
 
@@ -1124,10 +1124,10 @@ public class ApexEditorRestResource {
         String version1 = version;
         LOGGER.entry(name1, version1);
         try {
-            if (name1 == null || name1.equals("")) {
+            if (name1 == null || "".equals(name1)) {
                 name1 = null;
             }
-            if (version1 == null || version1.equals("")) {
+            if (version1 == null || "".equals(version1)) {
                 version1 = null;
             }
 
@@ -1171,10 +1171,10 @@ public class ApexEditorRestResource {
                 return ret;
             }
 
-            if (name1 == null || name1.equals("")) {
+            if (name1 == null || "".equals(name1)) {
                 name1 = null;
             }
-            if (version1 == null || version1.equals("")) {
+            if (version1 == null || "".equals(version1)) {
                 version1 = null;
             }
 
@@ -1374,8 +1374,8 @@ public class ApexEditorRestResource {
 
             final BeanTask jsonbean = RestUtils.getJsonParameters(jsonString, BeanTask.class);
 
-            if (jsonbean.getName() == null || jsonbean.getName().equals("") || jsonbean.getVersion() == null
-                            || jsonbean.getVersion().equals("")) {
+            if (jsonbean.getName() == null || "".equals(jsonbean.getName()) || jsonbean.getVersion() == null
+                            || "".equals(jsonbean.getVersion())) {
                 ret = new ApexApiResult(Result.FAILED, "Null/Empty task name/version (\"" + jsonbean.getName() + ":"
                                 + jsonbean.getVersion() + "\" passed to UpdateTask");
                 return ret;
@@ -1422,10 +1422,10 @@ public class ApexEditorRestResource {
                 return ret;
             }
 
-            if (name1 == null || name1.equals("")) {
+            if (name1 == null || "".equals(name1)) {
                 name1 = null;
             }
-            if (version1 == null || version1.equals("")) {
+            if (version1 == null || "".equals(version1)) {
                 version1 = null;
             }
 
@@ -1466,10 +1466,10 @@ public class ApexEditorRestResource {
                 return ret;
             }
 
-            if (name1 == null || name1.equals("")) {
+            if (name1 == null || "".equals(name1)) {
                 name1 = null;
             }
-            if (version1 == null || version1.equals("")) {
+            if (version1 == null || "".equals(version1)) {
                 version1 = null;
             }
 
@@ -1511,10 +1511,10 @@ public class ApexEditorRestResource {
                 return ret;
             }
 
-            if (name1 == null || name1.equals("")) {
+            if (name1 == null || "".equals(name1)) {
                 name1 = null;
             }
-            if (version1 == null || version1.equals("")) {
+            if (version1 == null || "".equals(version1)) {
                 version1 = null;
             }
 
@@ -1777,8 +1777,8 @@ public class ApexEditorRestResource {
 
             final BeanPolicy jsonbean = RestUtils.getJsonParameters(jsonString, BeanPolicy.class);
 
-            if (jsonbean.getName() == null || jsonbean.getName().equals("") || jsonbean.getVersion() == null
-                            || jsonbean.getVersion().equals("")) {
+            if (jsonbean.getName() == null || "".equals(jsonbean.getName()) || jsonbean.getVersion() == null
+                            || "".equals(jsonbean.getVersion())) {
                 ret = new ApexApiResult(Result.FAILED, "Null/Empty Policy name/version (\"" + jsonbean.getName() + ":"
                                 + jsonbean.getVersion() + "\" passed to UpdatePolicy");
                 return ret;
@@ -1839,10 +1839,10 @@ public class ApexEditorRestResource {
                 return ret;
             }
 
-            if (name1 == null || name1.equals("")) {
+            if (name1 == null || "".equals(name1)) {
                 name1 = null;
             }
-            if (version1 == null || version1.equals("")) {
+            if (version1 == null || "".equals(version1)) {
                 version1 = null;
             }
 
@@ -1884,10 +1884,10 @@ public class ApexEditorRestResource {
                 return ret;
             }
 
-            if (name1 == null || name1.equals("")) {
+            if (name1 == null || "".equals(name1)) {
                 name1 = null;
             }
-            if (version1 == null || version1.equals("")) {
+            if (version1 == null || "".equals(version1)) {
                 version1 = null;
             }
 
index 2bd4723..2888b03 100644 (file)
@@ -49,6 +49,12 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
  * @author Liam Fallon (liam.fallon@ericsson.com)
  */
 public abstract class RestUtils {
+    // Regular expressions for checking input types
+    private static final String XML_INPUT_TYPE_REGEXP = "^\\s*<\\?xml.*>\\s*"; //starts with <?xml...>
+    /**
+     * starts with some kind of bracket [ or ( or {, then has something, then has bracket.
+     */
+    private static final String JSON_INPUT_TYPE_REGEXP = "^\\s*[\\(\\{\\[][\\s+\\S]*[\\)\\}\\]]";
 
     /**
      * Constructor, block inheritance.
@@ -77,7 +83,7 @@ public abstract class RestUtils {
         }
         if (val.isJsonPrimitive() && ((JsonPrimitive) val).isString()) {
             final String v = ((JsonPrimitive) val).getAsString();
-            if (v == null || v.equals("")) {
+            if (v == null || "".equals(v)) {
                 return JsonNull.INSTANCE;
             }
         }
@@ -137,13 +143,6 @@ public abstract class RestUtils {
         return gb.create().fromJson(jsonObject, clz);
     }
 
-    // Regular expressions for checking input types
-    private static final String XML_INPUT_TYPE_REGEXP = "^\\s*<\\?xml.*>\\s*"; //starts with <?xml...>
-    /**
-     * starts with some kind of bracket [ or ( or {, then has something, then has bracket.
-     */
-    private static final String JSON_INPUT_TYPE_REGEXP = "^\\s*[\\(\\{\\[][\\s+\\S]*[\\)\\}\\]]";
-
     /**
      * Gets the concept from JSON.
      *
index bb27943..5812ebd 100644 (file)
@@ -38,7 +38,7 @@ import org.apache.commons.cli.ParseException;
  */
 public class ApexServicesRestParameterParser {
     // Apache Commons CLI options
-    Options options;
+    private Options options;
 
     /**
      * Construct the options for the CLI RESTful services.
index d0b374f..301b19f 100644 (file)
@@ -173,9 +173,9 @@ public final class ParameterCheck {
         }
 
         ParameterCheck.StartStop startStop;
-        if (startStopValue[0].equalsIgnoreCase("start")) {
+        if ("start".equalsIgnoreCase(startStopValue[0])) {
             startStop = ParameterCheck.StartStop.START;
-        } else if (startStopValue[0].equalsIgnoreCase("stop")) {
+        } else if ("stop".equalsIgnoreCase(startStopValue[0])) {
             startStop = ParameterCheck.StartStop.STOP;
         } else {
             LOGGER.warn("value \"{}\" of parameter \"{}\" not \"start\" or \"stop\"", startStopValue[0], startStopPar);
index f5c8ad8..a72fbe0 100644 (file)
@@ -38,7 +38,7 @@ import org.apache.commons.cli.ParseException;
  */
 public class ApexMonitoringRestParameterParser {
     // Apache Commons CLI options
-    Options options;
+    private Options options;
 
     /**
      * Construct the options for the CLI RESTful services.
index f8cee77..6b7f120 100644 (file)
@@ -195,9 +195,9 @@ public class ApexMonitoringRestResource {
             parameterMap.put("AxArtifactKey#" + engineId, new String[]
                 { startStop });
             final AxArtifactKey engineKey = ParameterCheck.getEngineKey(parameterMap);
-            if (startStop.equals("Start")) {
+            if ("Start".equals(startStop)) {
                 engineServiceFacade.startEngine(engineKey);
-            } else if (startStop.equals("Stop")) {
+            } else if ("Stop".equals(startStop)) {
                 engineServiceFacade.stopEngine(engineKey);
             }
         } catch (final Exception e) {
@@ -241,10 +241,10 @@ public class ApexMonitoringRestResource {
             parameterMap.put("period", new String[]
                 { Long.toString(period) });
             final AxArtifactKey engineKey = ParameterCheck.getEngineKey(parameterMap);
-            if (startStop.equals("Start")) {
+            if ("Start".equals(startStop)) {
                 engineServiceFacade.startPerioidicEvents(engineKey, period);
                 setPeriodicEventsState(host, true);
-            } else if (startStop.equals("Stop")) {
+            } else if ("Stop".equals(startStop)) {
                 engineServiceFacade.stopPerioidicEvents(engineKey);
                 setPeriodicEventsState(host, false);
             }
index 9052775..46e1452 100644 (file)
@@ -173,9 +173,9 @@ public final class ParameterCheck {
         }
 
         ParameterCheck.StartStop startStop;
-        if (startStopValue[0].equalsIgnoreCase("start")) {
+        if ("start".equalsIgnoreCase(startStopValue[0])) {
             startStop = ParameterCheck.StartStop.START;
-        } else if (startStopValue[0].equalsIgnoreCase("stop")) {
+        } else if ("stop".equalsIgnoreCase(startStopValue[0])) {
             startStop = ParameterCheck.StartStop.STOP;
         } else {
             LOGGER.warn("value \"{}\"of parameter \"{}\" not \"start\" or \"stop\"", startStopValue[0], startStopPar);
index 3afd5c8..436624b 100644 (file)
@@ -96,10 +96,7 @@ public class TestContextBooleanItem implements Serializable {
             return false;
         }
         final TestContextBooleanItem other = (TestContextBooleanItem) obj;
-        if (flag != other.flag) {
-            return false;
-        }
-        return true;
+        return flag == other.flag;
     }
 
     /*
index 2b107b4..eec5d2b 100644 (file)
@@ -94,10 +94,7 @@ public class TestContextByteItem implements Serializable {
             return false;
         }
         final TestContextByteItem other = (TestContextByteItem) obj;
-        if (byteValue != other.byteValue) {
-            return false;
-        }
-        return true;
+        return byteValue == other.byteValue;
     }
 
     /*
index f7c8490..188b69c 100644 (file)
@@ -239,10 +239,7 @@ public class TestContextDateItem implements Serializable {
         if (time != other.time) {
             return false;
         }
-        if (year != other.year) {
-            return false;
-        }
-        return true;
+        return year == other.year;
     }
 
     /*
index efad260..4712074 100644 (file)
@@ -241,10 +241,7 @@ public class TestContextDateLocaleItem implements Serializable {
         } else if (!timeZoneString.equals(other.timeZoneString)) {
             return false;
         }
-        if (utcOffset != other.utcOffset) {
-            return false;
-        }
-        return true;
+        return utcOffset == other.utcOffset;
     }
 
     /*
index ac4f506..26d98cd 100644 (file)
@@ -97,10 +97,7 @@ public class TestContextDoubleItem implements Serializable {
             return false;
         }
         final TestContextDoubleItem other = (TestContextDoubleItem) obj;
-        if (Double.doubleToLongBits(doubleValue) != Double.doubleToLongBits(other.doubleValue)) {
-            return false;
-        }
-        return true;
+        return Double.doubleToLongBits(doubleValue) == Double.doubleToLongBits(other.doubleValue);
     }
 
     /*
index cd81652..294cf5b 100644 (file)
@@ -94,10 +94,7 @@ public class TestContextFloatItem implements Serializable {
             return false;
         }
         final TestContextFloatItem other = (TestContextFloatItem) obj;
-        if (Float.floatToIntBits(floatValue) != Float.floatToIntBits(other.floatValue)) {
-            return false;
-        }
-        return true;
+        return Float.floatToIntBits(floatValue) == Float.floatToIntBits(other.floatValue);
     }
 
     /*
index 8983027..24cfebb 100644 (file)
@@ -103,10 +103,7 @@ public class TestContextIntItem implements Serializable {
             return false;
         }
         final TestContextIntItem other = (TestContextIntItem) obj;
-        if (intValue != other.intValue) {
-            return false;
-        }
-        return true;
+        return intValue == other.intValue;
     }
 
     /*
index be3ee60..025cde6 100644 (file)
@@ -95,10 +95,7 @@ public class TestContextLongItem implements Serializable {
             return false;
         }
         final TestContextLongItem other = (TestContextLongItem) obj;
-        if (longValue != other.longValue) {
-            return false;
-        }
-        return true;
+        return longValue == other.longValue;
     }
 
     /*
index 215868d..9027bfc 100644 (file)
@@ -30,7 +30,7 @@ public class TestContextLongObjectItem implements Serializable {
 
     private static final int HASH_PRIME_1 = 31;
 
-    private Long longValue = new Long(0);
+    private Long longValue = 0L;
 
     /**
      * The Constructor.
index eed0c1a..538a543 100644 (file)
@@ -32,7 +32,7 @@ public class TestContextTreeMapItem implements Serializable {
 
     private static final int HASH_PRIME_1 = 31;
 
-    private Map<String, String> mapValue = new TreeMap<String, String>();
+    private Map<String, String> mapValue = new TreeMap<>();
 
     /**
      * The Constructor.
@@ -55,7 +55,7 @@ public class TestContextTreeMapItem implements Serializable {
      */
     public Map<String, String> getMapValue() {
         if (mapValue == null) {
-            mapValue = new TreeMap<String, String>();
+            mapValue = new TreeMap<>();
         }
         return mapValue;
     }
index fe47c1a..e38d9c6 100644 (file)
@@ -22,6 +22,7 @@ package org.onap.policy.apex.context.test.concepts;
 
 import java.io.Serializable;
 import java.util.Set;
+import java.util.SortedSet;
 import java.util.TreeSet;
 
 /**
@@ -32,7 +33,7 @@ public class TestContextTreeSetItem implements Serializable {
 
     private static final int HASH_PRIME_1 = 31;
 
-    private TreeSet<String> setValue = new TreeSet<String>();
+    private SortedSet<String> setValue = new TreeSet<>();
 
     /**
      * The Constructor.
@@ -51,7 +52,7 @@ public class TestContextTreeSetItem implements Serializable {
      *
      * @param setValue the set value
      */
-    public TestContextTreeSetItem(final TreeSet<String> setValue) {
+    public TestContextTreeSetItem(final SortedSet<String> setValue) {
         this.setValue = setValue;
     }
 
@@ -62,7 +63,7 @@ public class TestContextTreeSetItem implements Serializable {
      */
     public Set<String> getSetValue() {
         if (setValue == null) {
-            setValue = new TreeSet<String>();
+            setValue = new TreeSet<>();
         }
         return setValue;
     }
@@ -72,7 +73,7 @@ public class TestContextTreeSetItem implements Serializable {
      *
      * @param setValue the sets the value
      */
-    public void setSetValue(final TreeSet<String> setValue) {
+    public void setSetValue(final SortedSet<String> setValue) {
         this.setValue = setValue;
     }
 
index 189208f..0d25287 100644 (file)
@@ -54,7 +54,7 @@ public class ContextAlbumUpdate {
      * @throws IOException the IO exception
      * @throws ApexException the apex exception
      */
-    public void testContextAlbumUpdate() throws ApexModelException, IOException, ApexException {
+    public void testContextAlbumUpdate() throws IOException, ApexException {
         LOGGER.debug("Running TestContextAlbumUpdate test . . .");
 
         final AxArtifactKey distributorKey = new AxArtifactKey(APEX_DISTRIBUTOR, VERSION);
index 75c6158..17c98a1 100644 (file)
@@ -94,6 +94,17 @@ public class ContextInstantiation {
     // Logger for this class
     private static final XLogger LOGGER = XLoggerFactory.getXLogger(ContextInstantiation.class);
 
+    // Recurring string constants
+    private static final String TEST_POLICY_CONTEXT_ITEM000 = "TestPolicyContextItem000";
+    private static final String TEST_POLICY_CONTEXT_ITEM005 = "TestPolicyContextItem005";
+    private static final String TEST_POLICY_CONTEXT_ITEM004 = "TestPolicyContextItem004";
+    private static final String TEST_POLICY_CONTEXT_ITEM003 = "TestPolicyContextItem003";
+    private static final String TEST_POLICY_CONTEXT_ITEM002 = "TestPolicyContextItem002";
+    private static final String TEST_POLICY_CONTEXT_ITEM001 = "TestPolicyContextItem001";
+    private static final String NORMAL_TEST_EXCEPTION = "normal test exception";
+    private static final String NULL_VALUES_ILLEGAL_TAG =
+                    "album \"ExternalContextAlbum:0.0.1\" null values are illegal on key ";
+
     private static final TreeSet<String> TEST_TREE_SET = new TreeSet<>();
     private static final Map<String, String> TEST_HASH_MAP = new HashMap<>();
 
@@ -124,8 +135,8 @@ public class ContextInstantiation {
 
         try {
 
-            final ContextAlbum policyContextAlbum =
-                    contextDistributor.createContextAlbum(new AxArtifactKey(POLICY_CONTEXT_ALBUM, VERSION));
+            final ContextAlbum policyContextAlbum = contextDistributor
+                            .createContextAlbum(new AxArtifactKey(POLICY_CONTEXT_ALBUM, VERSION));
 
             assertNotNull(policyContextAlbum);
             policyContextAlbum.setUserArtifactStack(Constants.getAxArtifactKeyArray());
@@ -142,8 +153,8 @@ public class ContextInstantiation {
 
             policyContextAlbum.putAll(valueMap0);
 
-            final TestPolicyContextItem contextItem =
-                    (TestPolicyContextItem) policyContextAlbum.get(TEST_POLICY_CONTEXT_ITEM);
+            final TestPolicyContextItem contextItem = (TestPolicyContextItem) policyContextAlbum
+                            .get(TEST_POLICY_CONTEXT_ITEM);
             assertEquals(STRING_VAL, contextItem.getTestPolicyContextItem000().getStringValue());
 
             assertEquals(LONG_VAL, contextItem.getTestPolicyContextItem001().getLongValue());
@@ -152,8 +163,8 @@ public class ContextInstantiation {
             assertEquals(contextItem.getTestPolicyContextItem004().getLongValue(), testDate.getTime());
             assertEquals(TEST_HASH_MAP, contextItem.getTestPolicyContextItem005().getMapValue());
 
-            final TestGlobalContextItem globalContext =
-                    getTestGlobalContextItem(contextDistributor, testDate, tci9, tciA);
+            final TestGlobalContextItem globalContext = getTestGlobalContextItem(contextDistributor, testDate, tci9,
+                            tciA);
 
             final Map<String, Object> valueMap1 = new HashMap<>();
             valueMap1.put(GLOBAL_CONTEXT_KEY, globalContext);
@@ -162,8 +173,8 @@ public class ContextInstantiation {
 
             globalContextAlbum.putAll(valueMap1);
 
-            final TestGlobalContextItem globalContextItem =
-                    (TestGlobalContextItem) globalContextAlbum.get(GLOBAL_CONTEXT_KEY);
+            final TestGlobalContextItem globalContextItem = (TestGlobalContextItem) globalContextAlbum
+                            .get(GLOBAL_CONTEXT_KEY);
 
             assertFalse(globalContextItem.getTestGlobalContextItem000().getFlag());
 
@@ -176,13 +187,13 @@ public class ContextInstantiation {
             assertDouble(PI_VAL, globalContextItem.getTestGlobalContextItem005().getDoubleValue());
             assertEquals(STRING_GLOBAL_VAL, globalContextItem.getTestGlobalContextItem006().getStringValue());
 
-            assertEquals(new Long(testDate.getTime()), globalContextItem.getTestGlobalContextItem007().getLongValue());
+            assertEquals((Long) testDate.getTime(), globalContextItem.getTestGlobalContextItem007().getLongValue());
             assertEquals(testDate, globalContextItem.getTestGlobalContextItem008().getDateValue());
             assertEquals(tci9.getDateValue().getTime(),
-                    globalContextItem.getTestGlobalContextItem009().getDateValue().getTime());
+                            globalContextItem.getTestGlobalContextItem009().getDateValue().getTime());
 
             assertEquals(tciA.getDateValue().getTime(),
-                    globalContextItem.getTestGlobalContextItem00A().getDateValue().getTime());
+                            globalContextItem.getTestGlobalContextItem00A().getDateValue().getTime());
 
             assertEquals(TEST_TREE_SET, globalContextItem.getTestGlobalContextItem00B().getSetValue());
             assertEquals(TEST_HASH_MAP, globalContextItem.getTestGlobalContextItem00C().getMapValue());
@@ -190,8 +201,8 @@ public class ContextInstantiation {
             final AxContextModel externalContextModel = TestContextAlbumFactory.createExternalContextModel();
 
             final TestContextDateTzItem tci9A = new TestContextDateTzItem(tci9);
-            final TestContextDateLocaleItem tciA_A = new TestContextDateLocaleItem(tciA);
-            final TestExternalContextItem externalContext = getTestExternalContextItem(testDate, tci9A, tciA_A);
+            final TestContextDateLocaleItem tciAa = new TestContextDateLocaleItem(tciA);
+            final TestExternalContextItem externalContext = getTestExternalContextItem(testDate, tci9A, tciAa);
 
             final Map<String, Object> valueMap2 = new HashMap<>();
             valueMap2.put(EXTERNAL_CONTEXT, externalContext);
@@ -208,8 +219,8 @@ public class ContextInstantiation {
             externalContextAlbum.putAll(valueMap2);
             externalContextAlbum.getAlbumDefinition().setWritable(false);
 
-            TestExternalContextItem externalContextItem =
-                    (TestExternalContextItem) externalContextAlbum.get(EXTERNAL_CONTEXT);
+            TestExternalContextItem externalContextItem = (TestExternalContextItem) externalContextAlbum
+                            .get(EXTERNAL_CONTEXT);
 
             assertFalse(externalContextItem.getTestExternalContextItem000().getFlag());
             assertEquals(BYTE_VAL, externalContextItem.getTestExternalContextItem001().getByteValue());
@@ -220,14 +231,13 @@ public class ContextInstantiation {
 
             assertDouble(PI_VAL, externalContextItem.getTestExternalContextItem005().getDoubleValue());
             assertEquals(STRING_EXT_VAL, externalContextItem.getTestExternalContextItem006().getStringValue());
-            assertEquals(new Long(testDate.getTime()),
-                    externalContextItem.getTestExternalContextItem007().getLongValue());
+            assertEquals((Long) testDate.getTime(), externalContextItem.getTestExternalContextItem007().getLongValue());
             assertEquals(testDate, externalContextItem.getTestExternalContextItem008().getDateValue());
             assertEquals(tci9A.getDateValue().getTime(),
-                    externalContextItem.getTestExternalContextItem009().getDateValue().getTime());
+                            externalContextItem.getTestExternalContextItem009().getDateValue().getTime());
 
-            assertEquals(tciA_A.getDateValue().getTime(),
-                    externalContextItem.getTestExternalContextItem00A().getDateValue().getTime());
+            assertEquals(tciAa.getDateValue().getTime(),
+                            externalContextItem.getTestExternalContextItem00A().getDateValue().getTime());
             assertEquals(TEST_TREE_SET, externalContextItem.getTestExternalContextItem00B().getSetValue());
             assertEquals(TEST_HASH_MAP, externalContextItem.getTestExternalContextItem00C().getMapValue());
 
@@ -240,7 +250,8 @@ public class ContextInstantiation {
                 fail(EXCEPTION_MESSAGE);
             } catch (final ContextRuntimeException e) {
                 assertEquals("album \"ExternalContextAlbum:0.0.1\" clear() not allowed on read only albums",
-                        e.getMessage());
+                                e.getMessage());
+                LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
             }
 
             assertEquals(1, externalContextAlbum.size());
@@ -254,8 +265,8 @@ public class ContextInstantiation {
                 externalContextAlbum.get(null);
             } catch (final ContextRuntimeException e) {
                 assertEquals("album \"ExternalContextAlbum:0.0.1\" null keys are illegal on keys for get()",
-                        e.getMessage());
-
+                                e.getMessage());
+                LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
             }
 
             final Object aObject = externalContextAlbum.get(EXTERNAL_CONTEXT);
@@ -266,16 +277,17 @@ public class ContextInstantiation {
                 externalContextAlbum.put(null, null);
             } catch (final ContextRuntimeException e) {
                 assertEquals("album \"ExternalContextAlbum:0.0.1\" null keys are illegal on keys for put()",
-                        e.getMessage());
+                                e.getMessage());
+                LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
             }
 
             try {
                 externalContextAlbum.put("TestExternalContextItem00A", null);
             } catch (final ContextRuntimeException e) {
-                assertEquals("album \"ExternalContextAlbum:0.0.1\" null values are illegal on key "
-                        + "\"TestExternalContextItem00A\" for put()", e.getMessage());
+                assertEquals(NULL_VALUES_ILLEGAL_TAG + "\"TestExternalContextItem00A\" for put()", e.getMessage());
+                LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
             }
-            assertEquals(tciA_A, externalContextItem.getTestExternalContextItem00A());
+            assertEquals(tciAa, externalContextItem.getTestExternalContextItem00A());
 
             // Should return the hash set
             assertEquals(TEST_TREE_SET, externalContextItem.getTestExternalContextItem00B().getSetValue());
@@ -300,24 +312,24 @@ public class ContextInstantiation {
             try {
                 externalContextAlbum.put("TestExternalContextItem00A", null);
             } catch (final ContextRuntimeException e) {
-                assert (e.getMessage().equals("album \"ExternalContextAlbum:0.0.1\" null values are illegal on key "
-                        + "\"TestExternalContextItem00A\" for put()"));
+                assert (e.getMessage().equals(NULL_VALUES_ILLEGAL_TAG + "\"TestExternalContextItem00A\" for put()"));
+                LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
             }
             assertTrue(externalContextAlbum.get(EXTERNAL_CONTEXT).equals(externalContext));
 
             try {
                 externalContextAlbum.put("TestExternalContextItemFFF", null);
             } catch (final ContextRuntimeException e) {
-                assert (e.getMessage().equals("album \"ExternalContextAlbum:0.0.1\" null values are illegal on key "
-                        + "\"TestExternalContextItemFFF\" for put()"));
+                assert (e.getMessage().equals(NULL_VALUES_ILLEGAL_TAG + "\"TestExternalContextItemFFF\" for put()"));
+                LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
             }
             assertEquals(1, externalContextAlbum.size());
 
             try {
                 externalContextAlbum.put("TestExternalContextItemFFF", null);
             } catch (final ContextRuntimeException e) {
-                assertEquals("album \"ExternalContextAlbum:0.0.1\" null values are illegal on key "
-                        + "\"TestExternalContextItemFFF\" for put()", e.getMessage());
+                assertEquals(NULL_VALUES_ILLEGAL_TAG + "\"TestExternalContextItemFFF\" for put()", e.getMessage());
+                LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
             }
             assertEquals(1, externalContextAlbum.size());
 
@@ -336,11 +348,12 @@ public class ContextInstantiation {
     }
 
     private void assertContextAlbumContains(final TestExternalContextItem externalContext,
-            final ContextAlbum externalContextAlbum) {
+                    final ContextAlbum externalContextAlbum) {
         try {
             externalContextAlbum.containsKey(null);
         } catch (final ContextRuntimeException e) {
             assertEquals("null values are illegal on method parameter \"key\"", e.getMessage());
+            LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
         }
 
         assertTrue(externalContextAlbum.containsKey(EXTERNAL_CONTEXT));
@@ -350,6 +363,7 @@ public class ContextInstantiation {
             externalContextAlbum.containsValue(null);
         } catch (final ContextRuntimeException e) {
             assertEquals("null values are illegal on method parameter \"value\"", e.getMessage());
+            LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
         }
 
         assertTrue(externalContextAlbum.containsValue(externalContext));
@@ -357,15 +371,15 @@ public class ContextInstantiation {
     }
 
     private ContextAlbum getContextAlbum(final Distributor contextDistributor) throws ContextException {
-        final ContextAlbum globalContextAlbum =
-                contextDistributor.createContextAlbum(new AxArtifactKey(GLOBAL_CONTEXT_ALBUM, VERSION));
+        final ContextAlbum globalContextAlbum = contextDistributor
+                        .createContextAlbum(new AxArtifactKey(GLOBAL_CONTEXT_ALBUM, VERSION));
         assertNotNull(globalContextAlbum);
         globalContextAlbum.setUserArtifactStack(Constants.getAxArtifactKeyArray());
         return globalContextAlbum;
     }
 
     private TestGlobalContextItem getTestGlobalContextItem(final Distributor contextDistributor, final Date testDate,
-            final TestContextDateTzItem tci9, final TestContextDateLocaleItem tciA) throws ContextException {
+                    final TestContextDateTzItem tci9, final TestContextDateLocaleItem tciA) throws ContextException {
         final AxContextModel globalContextModel = TestContextAlbumFactory.createGlobalContextModel();
         final TestGlobalContextItem globalContext = getTestGlobalContextItem(testDate, tci9, tciA);
         contextDistributor.registerModel(globalContextModel);
@@ -373,14 +387,14 @@ public class ContextInstantiation {
     }
 
     private TestGlobalContextItem getTestGlobalContextItem(final Date testDate, final TestContextDateTzItem tci9,
-            final TestContextDateLocaleItem tciA) {
+                    final TestContextDateLocaleItem tciA) {
         final TestGlobalContextItem globalContext = new TestGlobalContextItem();
 
         final TestContextBooleanItem testGlobalContextItem000 = new TestContextBooleanItem(false);
         final TestContextByteItem testGlobalContextItem001 = new TestContextByteItem(BYTE_VAL);
         final TestContextIntItem testGlobalContextItem002 = new TestContextIntItem(INT_VAL);
         final TestContextLongItem testGlobalContextItem003 = new TestContextLongItem(LONG_VAL);
-        final TestContextFloatItem testGlobalContextItem004 = new TestContextFloatItem(new Float(FLOAT_VAL));
+        final TestContextFloatItem testGlobalContextItem004 = new TestContextFloatItem(FLOAT_VAL);
         final TestContextDoubleItem testGlobalContextItem005 = new TestContextDoubleItem(PI_VAL);
         final TestContextStringItem testGlobalContextItem006 = new TestContextStringItem(STRING_GLOBAL_VAL);
         final TestContextLongObjectItem testGlobalContextItem007 = new TestContextLongObjectItem(testDate.getTime());
@@ -389,7 +403,6 @@ public class ContextInstantiation {
         final TestContextTreeSetItem testGlobalContextItem00B = new TestContextTreeSetItem(TEST_TREE_SET);
         final TestContextTreeMapItem testGlobalContextItem00C = new TestContextTreeMapItem(TEST_HASH_MAP);
 
-
         globalContext.setTestGlobalContextItem000(testGlobalContextItem000);
         globalContext.setTestGlobalContextItem001(testGlobalContextItem001);
         globalContext.setTestGlobalContextItem002(testGlobalContextItem002);
@@ -415,12 +428,12 @@ public class ContextInstantiation {
         final TestContextTreeMapItem contextTreeMapItem = new TestContextTreeMapItem(TEST_HASH_MAP);
 
         final Map<String, Object> valueMapA = new LinkedHashMap<>();
-        valueMapA.put("TestPolicyContextItem001", contextLongItem);
-        valueMapA.put("TestPolicyContextItem002", contextDoubleItem);
-        valueMapA.put("TestPolicyContextItem003", contextBooleanItem);
-        valueMapA.put("TestPolicyContextItem004", contextLongItem2);
-        valueMapA.put("TestPolicyContextItem005", contextTreeMapItem);
-        valueMapA.put("TestPolicyContextItem000", contextStringItem);
+        valueMapA.put(TEST_POLICY_CONTEXT_ITEM001, contextLongItem);
+        valueMapA.put(TEST_POLICY_CONTEXT_ITEM002, contextDoubleItem);
+        valueMapA.put(TEST_POLICY_CONTEXT_ITEM003, contextBooleanItem);
+        valueMapA.put(TEST_POLICY_CONTEXT_ITEM004, contextLongItem2);
+        valueMapA.put(TEST_POLICY_CONTEXT_ITEM005, contextTreeMapItem);
+        valueMapA.put(TEST_POLICY_CONTEXT_ITEM000, contextStringItem);
 
         assertPutMethods(policyContextAlbum, contextStringItem, valueMapA);
 
@@ -438,23 +451,24 @@ public class ContextInstantiation {
     }
 
     private void assertPutMethods(final ContextAlbum policyContextAlbum, final TestContextStringItem contextStringItem,
-            final Map<String, Object> valueMapA) {
+                    final Map<String, Object> valueMapA) {
         try {
-            policyContextAlbum.put("TestPolicyContextItem000", contextStringItem);
+            policyContextAlbum.put(TEST_POLICY_CONTEXT_ITEM000, contextStringItem);
             fail(EXCEPTION_MESSAGE);
         } catch (final ContextRuntimeException e) {
-            assertEquals(
-                    getMessage("TestPolicyContextItem000", "TestContextItem006",
+            assertEquals(getMessage(TEST_POLICY_CONTEXT_ITEM000, "TestContextItem006",
                             TestContextStringItem.class.getCanonicalName(), "stringValue=" + STRING_VAL),
-                    e.getMessage());
+                            e.getMessage());
+            LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
         }
 
         try {
             policyContextAlbum.putAll(valueMapA);
             fail(EXCEPTION_MESSAGE);
         } catch (final ContextRuntimeException e) {
-            assertEquals(getMessage("TestPolicyContextItem001", "TestContextItem003",
-                    TestContextLongItem.class.getCanonicalName(), "longValue=" + INT_VAL_3), e.getMessage());
+            assertEquals(getMessage(TEST_POLICY_CONTEXT_ITEM001, "TestContextItem003",
+                            TestContextLongItem.class.getCanonicalName(), "longValue=" + INT_VAL_3), e.getMessage());
+            LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
         }
     }
 
@@ -487,7 +501,7 @@ public class ContextInstantiation {
     }
 
     private TestExternalContextItem getTestExternalContextItem(final Date testDate, final TestContextDateTzItem tci9A,
-            final TestContextDateLocaleItem tciAa) {
+                    final TestContextDateLocaleItem tciAa) {
         final TestExternalContextItem externalContext = new TestExternalContextItem();
 
         final TestContextBooleanItem testExternalContextItem000 = new TestContextBooleanItem(false);
@@ -502,7 +516,6 @@ public class ContextInstantiation {
         final TestContextTreeSetItem testExternalContextItem00B = new TestContextTreeSetItem(TEST_TREE_SET);
         final TestContextTreeMapItem testExternalContextItem00C = new TestContextTreeMapItem(TEST_HASH_MAP);
 
-
         externalContext.setTestExternalContextItem000(testExternalContextItem000);
         externalContext.setTestExternalContextItem001(testExternalContextItem001);
         externalContext.setTestExternalContextItem002(testExternalContextItem002);
@@ -524,10 +537,10 @@ public class ContextInstantiation {
     }
 
     private String getMessage(final String key, final String objName, final String clazzName, final String valString,
-            final String compatibleClazzName) {
+                    final String compatibleClazzName) {
         return "Failed to set context value for key \"" + key + "\" in album \"PolicyContextAlbum:0.0.1\": "
-                + "PolicyContextAlbum:0.0.1: object \"" + objName + " [" + valString + "]\" " + "of class \""
-                + clazzName + "\"" + " not compatible with class \"" + compatibleClazzName + "\"";
+                        + "PolicyContextAlbum:0.0.1: object \"" + objName + " [" + valString + "]\" " + "of class \""
+                        + clazzName + "\"" + " not compatible with class \"" + compatibleClazzName + "\"";
     }
 
     private void assertFloat(final float actual, final float expected) {
@@ -538,7 +551,6 @@ public class ContextInstantiation {
         assertTrue(Double.compare(actual, expected) == 0);
     }
 
-
     private Distributor getDistributor() throws ContextException {
         final AxArtifactKey distributorKey = new AxArtifactKey("ApexDistributorInit", VERSION);
         final Distributor distributor = new DistributorFactory().getDistributor(distributorKey);
index 95d1432..d6a55ef 100644 (file)
@@ -62,8 +62,11 @@ import org.slf4j.ext.XLoggerFactory;
  * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
  */
 public class ContextUpdate {
+    // Recurring string constants.
+    private static final String NORMAL_TEST_EXCEPTION = "normal test exception";
+
     private static final String ZERO = "zero";
-    private static final String _0 = "0";
+    private static final String NUMBER_ZERO = "0";
     // Logger for this class
     private static final XLogger LOGGER = XLoggerFactory.getXLogger(ContextUpdate.class);
 
@@ -74,7 +77,7 @@ public class ContextUpdate {
      * @throws IOException the IO exception
      * @throws ApexException the apex exception
      */
-    public void testContextUpdate() throws ApexModelException, IOException, ApexException {
+    public void testContextUpdate() throws IOException, ApexException {
         LOGGER.debug("Running TestContextUpdate test . . .");
 
         final Distributor contextDistributor = getDistributor();
@@ -86,35 +89,38 @@ public class ContextUpdate {
         final TestContextDateLocaleItem tciA = getTestContextDateLocaleItem();
         final TestContextTreeMapItem tciC = getTestContextTreeMapItem();
 
-        longContextAlbum.put(_0, (long) 0);
-        longContextAlbum.put(_0, 0);
-        longContextAlbum.put(_0, _0);
+        longContextAlbum.put(NUMBER_ZERO, (long) 0);
+        longContextAlbum.put(NUMBER_ZERO, 0);
+        longContextAlbum.put(NUMBER_ZERO, NUMBER_ZERO);
 
         try {
-            longContextAlbum.put(_0, ZERO);
+            longContextAlbum.put(NUMBER_ZERO, ZERO);
             fail(EXCEPTION_MESSAGE);
         } catch (final ContextRuntimeException e) {
             assertEquals("Failed to set context value for key \"0\" in album \"LongContextAlbum:0.0.1\":"
                     + " LongContextAlbum:0.0.1: object \"zero\" of class \"java.lang.String\" not compatible with"
                     + " class \"java.lang.Long\"", e.getMessage());
+            LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
         }
 
         try {
-            longContextAlbum.put(_0, "");
+            longContextAlbum.put(NUMBER_ZERO, "");
             fail(EXCEPTION_MESSAGE);
         } catch (final ContextRuntimeException e) {
             assertEquals(
                     "Failed to set context value for key \"0\" in album \"LongContextAlbum:0.0.1\": LongContextAlbum"
                     + ":0.0.1: object \"\" of class \"java.lang.String\" not compatible with class \"java.lang.Long\"",
                     e.getMessage());
+            LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
         }
 
         try {
-            longContextAlbum.put(_0, null);
+            longContextAlbum.put(NUMBER_ZERO, null);
             fail(EXCEPTION_MESSAGE);
         } catch (final ContextRuntimeException e) {
             assertEquals("album \"LongContextAlbum:0.0.1\" null values are illegal on key \"0\" for put()",
                     e.getMessage());
+            LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
         }
 
         try {
@@ -122,6 +128,7 @@ public class ContextUpdate {
             fail(EXCEPTION_MESSAGE);
         } catch (final ContextRuntimeException e) {
             assertEquals("album \"LongContextAlbum:0.0.1\" null keys are illegal on keys for put()", e.getMessage());
+            LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
         }
 
         assertNull(dateContextAlbum.put("date0", tciA));
@@ -136,14 +143,13 @@ public class ContextUpdate {
 
     private TestContextTreeMapItem getTestContextTreeMapItem() {
         final Map<String, String> testHashMap = new HashMap<>();
-        testHashMap.put(_0, ZERO);
+        testHashMap.put(NUMBER_ZERO, ZERO);
         testHashMap.put("1", "one");
         testHashMap.put("2", "two");
         testHashMap.put("3", "three");
         testHashMap.put("4", "four");
 
-        final TestContextTreeMapItem tciC = new TestContextTreeMapItem(testHashMap);
-        return tciC;
+        return new TestContextTreeMapItem(testHashMap);
     }
 
     private TestContextDateLocaleItem getTestContextDateLocaleItem() {
index 244bd7d..293ef92 100644 (file)
@@ -67,19 +67,31 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
 import org.slf4j.ext.XLogger;
 import org.slf4j.ext.XLoggerFactory;
 
-
-
 /**
  * The Class SequentialContextInstantiation checks sequential initiation of context.
  *
  * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
  */
 public class SequentialContextInstantiation {
-    private static final String DV1 = "dv1";
-    private static final String DV0 = "dv0";
     // Logger for this class
     private static final XLogger LOGGER = XLoggerFactory.getXLogger(SequentialContextInstantiation.class);
 
+    // Recurring string constants.
+    private static final String TEST_AB = "TestAB";
+    private static final String TEST_AA = "TestAA";
+    private static final String ITEM_NULL = "ItemNull";
+    private static final String ITEM06 = "Item06";
+    private static final String ITEM05 = "Item05";
+    private static final String ITEM03 = "Item03";
+    private static final String ITEM02 = "Item02";
+    private static final String ITEM01 = "Item01";
+    private static final String ITEM00_2 = "Item00_2";
+
+    // Recurring string constants.
+    private static final String NORMAL_TEST_EXCEPTION = "normal test exception";
+    private static final String DV1 = "dv1";
+    private static final String DV0 = "dv0";
+
     /**
      * Test sequential context instantiation.
      *
@@ -107,8 +119,10 @@ public class SequentialContextInstantiation {
                 dateAlbum.put("tci9", tci9);
             } catch (final Exception e) {
                 final String message = "class \"" + TestContextDateTzItem.class.getCanonicalName()
-                        + "\" not compatible with class \"" + TestContextDateLocaleItem.class.getCanonicalName() + "\"";
+                                + "\" not compatible with class \"" + TestContextDateLocaleItem.class.getCanonicalName()
+                                + "\"";
                 assertTrue(e.getMessage().contains(message));
+                LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
             }
 
             final TestContextDateLocaleItem tciA01 = new TestContextDateLocaleItem(tciA00);
@@ -116,15 +130,15 @@ public class SequentialContextInstantiation {
             final TestContextDateLocaleItem tciA03 = new TestContextDateLocaleItem(tciA00);
 
             final Map<String, Object> valueMap0 = new HashMap<>();
-            valueMap0.put("Item01", tciA01);
-            valueMap0.put("Item02", tciA02);
-            valueMap0.put("Item03", tciA03);
+            valueMap0.put(ITEM01, tciA01);
+            valueMap0.put(ITEM02, tciA02);
+            valueMap0.put(ITEM03, tciA03);
 
             dateAlbum.putAll(valueMap0);
             assertEquals(5, dateAlbum.size());
-            assertEquals(tciA01, dateAlbum.get("Item01"));
-            assertEquals(tciA02, dateAlbum.get("Item02"));
-            assertEquals(tciA03, dateAlbum.get("Item03"));
+            assertEquals(tciA01, dateAlbum.get(ITEM01));
+            assertEquals(tciA02, dateAlbum.get(ITEM02));
+            assertEquals(tciA03, dateAlbum.get(ITEM03));
 
             final Map<String, Object> valueMap1 = getMap(testDate, tciA00, tci9);
 
@@ -135,31 +149,32 @@ public class SequentialContextInstantiation {
                 dateAlbum1.putAll(valueMap1);
                 fail(EXCEPTION_MESSAGE);
             } catch (final Exception e) {
-                assertTrue(e.getMessage().endsWith(
-                        "not compatible with class \"" + TestContextDateLocaleItem.class.getCanonicalName() + "\""));
+                assertTrue(e.getMessage().endsWith("not compatible with class \""
+                                + TestContextDateLocaleItem.class.getCanonicalName() + "\""));
+                LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
             }
             assertEquals(5, dateAlbum1.size());
 
             valueMap1.clear();
-            valueMap1.put("Item00_2", tciA00);
+            valueMap1.put(ITEM00_2, tciA00);
             dateAlbum1.putAll(valueMap1);
             assertEquals(6, dateAlbum1.size());
 
-            assertEquals(tciA00, dateAlbum1.get("Item00_2"));
-            dateAlbum.remove("Item00_2");
+            assertEquals(tciA00, dateAlbum1.get(ITEM00_2));
+            dateAlbum.remove(ITEM00_2);
             assertEquals(5, dateAlbum1.size());
 
             final ContextAlbum dateAlbumCopy = getContextAlbum(DATE_CONTEXT_ALBUM, contextDistributor);
 
             final Map<String, Object> valueMap2 = new HashMap<>();
             valueMap2.put("Item04", tciA01);
-            valueMap2.put("Item05", tciA02);
-            valueMap2.put("Item06", tciA03);
+            valueMap2.put(ITEM05, tciA02);
+            valueMap2.put(ITEM06, tciA03);
 
             dateAlbumCopy.putAll(valueMap2);
             assertEquals(8, dateAlbumCopy.size());
 
-            assertEquals(tciA03, dateAlbumCopy.get("Item06"));
+            assertEquals(tciA03, dateAlbumCopy.get(ITEM06));
 
             final Collection<Object> mapValues = dateAlbum.values();
             assertTrue(dateAlbumCopy.values().containsAll(mapValues));
@@ -168,18 +183,17 @@ public class SequentialContextInstantiation {
             dateAlbum1.clear();
             assertTrue(dateAlbum1.isEmpty());
 
-
             dateAlbum.put("Item00", tciA00);
             final Map<String, Object> valueMap3 = new HashMap<>();
-            valueMap3.put("Item01", tciA01);
-            valueMap3.put("Item02", tciA02);
-            valueMap3.put("Item03", tciA03);
+            valueMap3.put(ITEM01, tciA01);
+            valueMap3.put(ITEM02, tciA02);
+            valueMap3.put(ITEM03, tciA03);
             dateAlbum.putAll(valueMap3);
 
             final Map<String, Object> valueMap4 = new HashMap<>();
             valueMap4.put("Item04", tciA01);
-            valueMap4.put("Item05", tciA02);
-            valueMap4.put("Item06", tciA03);
+            valueMap4.put(ITEM05, tciA02);
+            valueMap4.put(ITEM06, tciA03);
 
             dateAlbumCopy.putAll(valueMap4);
 
@@ -191,9 +205,9 @@ public class SequentialContextInstantiation {
             assertAlbumGetAndPutMethods(dateAlbum, tciA03, tciA00);
 
             // Should do removes
-            dateAlbum.remove("TestAA");
-            dateAlbum.remove("TestAB");
-            dateAlbum.remove("ItemNull");
+            dateAlbum.remove(TEST_AA);
+            dateAlbum.remove(TEST_AB);
+            dateAlbum.remove(ITEM_NULL);
             assertEquals(7, entrySet.size());
             assertTrue(dateAlbumCopy.values().containsAll(mapValues));
             // CHECKSTYLE:ON: checkstyle:magicNumber
@@ -208,16 +222,17 @@ public class SequentialContextInstantiation {
             fail(EXCEPTION_MESSAGE);
         } catch (final Exception e) {
             assertEquals("null values are illegal on method parameter \"key\"", e.getMessage());
+            LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
         }
 
-        assertTrue(dateAlbum.containsKey("Item05"));
+        assertTrue(dateAlbum.containsKey(ITEM05));
         assertTrue(!dateAlbum.containsKey("Item07"));
 
         try {
             dateAlbum.containsValue(null);
         } catch (final Exception e) {
             assertEquals("null values are illegal on method parameter \"value\"", e.getMessage());
-
+            LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
         }
 
         assertTrue(dateAlbum.containsValue(tciA01));
@@ -225,75 +240,81 @@ public class SequentialContextInstantiation {
     }
 
     private void assertAlbumGetAndPutMethods(final ContextAlbum dateAlbum, final TestContextDateLocaleItem tciA03,
-            final TestContextDateLocaleItem tciA00) {
+                    final TestContextDateLocaleItem tciA00) {
         try {
             dateAlbum.get(null);
             fail(EXCEPTION_MESSAGE);
         } catch (final Exception e) {
             assertEquals("album \"DateContextAlbum:0.0.1\" null keys are illegal on keys for get()", e.getMessage());
+            LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
         }
 
-        final Object aObject = dateAlbum.get("Item03");
+        final Object aObject = dateAlbum.get(ITEM03);
         assertEquals(tciA03, aObject);
         try {
             dateAlbum.put(null, null);
             fail(EXCEPTION_MESSAGE);
         } catch (final Exception e) {
             assertEquals("album \"DateContextAlbum:0.0.1\" null keys are illegal on keys for put()", e.getMessage());
+            LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
         }
 
         // Put null ContextItem should work (return null)
         try {
-            dateAlbum.put("ItemNull", null);
+            dateAlbum.put(ITEM_NULL, null);
         } catch (final Exception e) {
             assertEquals("album \"DateContextAlbum:0.0.1\" null values are illegal on key \"ItemNull\" for put()",
-                    e.getMessage());
+                            e.getMessage());
+            LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
         }
 
         // Should return null
-        assertNull(dateAlbum.get("ItemNull"));
+        assertNull(dateAlbum.get(ITEM_NULL));
         // Put should return the previous contextItem
         tciA00.setDst(false);
-        final TestContextDateLocaleItem tciA03_clone = new TestContextDateLocaleItem(tciA03);
-        tciA03_clone.setDst(true);
-        TestContextDateLocaleItem retItem = (TestContextDateLocaleItem) dateAlbum.put("Item03", tciA03_clone);
+        final TestContextDateLocaleItem tciA03Clone = new TestContextDateLocaleItem(tciA03);
+        tciA03Clone.setDst(true);
+        TestContextDateLocaleItem retItem = (TestContextDateLocaleItem) dateAlbum.put(ITEM03, tciA03Clone);
         assertEquals(tciA03, retItem);
-        retItem = (TestContextDateLocaleItem) dateAlbum.put("Item03", tciA03);
-        assertEquals(tciA03_clone, retItem);
+        retItem = (TestContextDateLocaleItem) dateAlbum.put(ITEM03, tciA03);
+        assertEquals(tciA03Clone, retItem);
 
         try {
-            dateAlbum.put("ItemNull", null);
+            dateAlbum.put(ITEM_NULL, null);
             fail(EXCEPTION_MESSAGE);
 
         } catch (final Exception e) {
-            assert (e.getMessage()
-                    .equals("album \"DateContextAlbum:0.0.1\" null values are illegal on key \"ItemNull\" for put()"));
+            assert ("album \"DateContextAlbum:0.0.1\" null values are illegal on key \"ItemNull\" for put()"
+                            .equals(e.getMessage()));
+            LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
         }
 
-        dateAlbum.put("TestAA", tciA00);
-        assertEquals(tciA00, dateAlbum.get("TestAA"));
+        dateAlbum.put(TEST_AA, tciA00);
+        assertEquals(tciA00, dateAlbum.get(TEST_AA));
 
         // Should print warning
         try {
-            dateAlbum.put("TestAA", null);
+            dateAlbum.put(TEST_AA, null);
             fail(EXCEPTION_MESSAGE);
         } catch (final Exception e) {
             assertEquals("album \"DateContextAlbum:0.0.1\" null values are illegal on key \"TestAA\" for put()",
-                    e.getMessage());
+                            e.getMessage());
+            LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
         }
         assertEquals(8, dateAlbum.size());
         try {
-            dateAlbum.put("TestAB", null);
+            dateAlbum.put(TEST_AB, null);
             fail(EXCEPTION_MESSAGE);
         } catch (final Exception e) {
             assertEquals("album \"DateContextAlbum:0.0.1\" null values are illegal on key \"TestAB\" for put()",
-                    e.getMessage());
+                            e.getMessage());
+            LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
         }
         assertEquals(8, dateAlbum.size());
     }
 
     private Map<String, Object> getMap(final Date testDate, final TestContextDateLocaleItem tciA00,
-            final TestContextDateTzItem tci9) {
+                    final TestContextDateTzItem tci9) {
         final TestContextBooleanItem testBadItem000 = new TestContextBooleanItem();
         final TestContextByteItem testBadItem001 = new TestContextByteItem();
         final TestContextIntItem testBadItem002 = new TestContextIntItem();
@@ -325,7 +346,7 @@ public class SequentialContextInstantiation {
         values.put("TestBadItem007", testBadItem007);
         values.put("TestBadItem008", testBadItem008);
         values.put("TestBadItem009", tci9);
-        values.put("Item00_2", tciA00);
+        values.put(ITEM00_2, tciA00);
         return values;
     }
 
@@ -348,7 +369,7 @@ public class SequentialContextInstantiation {
     }
 
     private ContextAlbum getContextAlbum(final String albumName, final Distributor contextDistributor)
-            throws ContextException {
+                    throws ContextException {
         final ContextAlbum dateAlbum = contextDistributor.createContextAlbum(new AxArtifactKey(albumName, VERSION));
         assertNotNull(dateAlbum);
         dateAlbum.setUserArtifactStack(Constants.getAxArtifactKeyArray());
index 3003344..9689acb 100644 (file)
@@ -48,7 +48,10 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
  * @author Liam Fallon (liam.fallon@ericsson.com)
  */
 public final class TestContextAlbumFactory {
-
+    // Recurring string constants.
+    private static final String CONTEXT = "context";
+    private static final String SCHEMAS2 = "Schemas";
+    private static final String KEY_INFO_MAP_KEY = "KeyInfoMapKey";
     private static final String APPLICATION = "APPLICATION";
     private static final String JAVA_LONG = Long.class.getCanonicalName();
     private static final String JAVA_FLAVOUR = "Java";
@@ -69,12 +72,12 @@ public final class TestContextAlbumFactory {
         final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(POLICY_CONTEXT_ALBUM, VERSION),
                 APPLICATION, true, policySchema.getKey());
 
-        final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", VERSION));
+        final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey(SCHEMAS2, VERSION));
         schemas.getSchemasMap().put(policySchema.getKey(), policySchema);
-        final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
+        final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey(CONTEXT, VERSION));
         albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
 
-        final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
+        final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey(KEY_INFO_MAP_KEY, VERSION));
         final AxContextModel contextModel =
                 new AxContextModel(new AxArtifactKey("PolicyContextModel", VERSION), schemas, albums, keyInformation);
         contextModel.setKeyInformation(keyInformation);
@@ -94,12 +97,12 @@ public final class TestContextAlbumFactory {
         final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(GLOBAL_CONTEXT_ALBUM, VERSION),
                 "GLOBAL", true, globalSchema.getKey());
 
-        final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", VERSION));
+        final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey(SCHEMAS2, VERSION));
         schemas.getSchemasMap().put(globalSchema.getKey(), globalSchema);
-        final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
+        final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey(CONTEXT, VERSION));
         albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
 
-        final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
+        final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey(KEY_INFO_MAP_KEY, VERSION));
         final AxContextModel contextModel =
                 new AxContextModel(new AxArtifactKey("GlobalContextModel", VERSION), schemas, albums, keyInformation);
         contextModel.setKeyInformation(keyInformation);
@@ -119,12 +122,12 @@ public final class TestContextAlbumFactory {
         final AxContextAlbum albumDefinition = new AxContextAlbum(new AxArtifactKey(EXTERNAL_CONTEXT_ALBUM, VERSION),
                 "EXTERNAL", true, externalSchema.getKey());
 
-        final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", VERSION));
+        final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey(SCHEMAS2, VERSION));
         schemas.getSchemasMap().put(externalSchema.getKey(), externalSchema);
-        final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
+        final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey(CONTEXT, VERSION));
         albums.getAlbumsMap().put(albumDefinition.getKey(), albumDefinition);
 
-        final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
+        final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey(KEY_INFO_MAP_KEY, VERSION));
         final AxContextModel contextModel =
                 new AxContextModel(new AxArtifactKey("ExternalContextModel", VERSION), schemas, albums, keyInformation);
         contextModel.setKeyInformation(keyInformation);
@@ -150,13 +153,13 @@ public final class TestContextAlbumFactory {
         final AxContextAlbum albumDefinition2 =
                 new AxContextAlbum(longContextAlbumKey2, APPLICATION, true, longSchema.getKey());
 
-        final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", VERSION));
+        final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey(SCHEMAS2, VERSION));
         schemas.getSchemasMap().put(longSchema.getKey(), longSchema);
-        final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
+        final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey(CONTEXT, VERSION));
         albums.getAlbumsMap().put(albumDefinition1.getKey(), albumDefinition1);
         albums.getAlbumsMap().put(albumDefinition2.getKey(), albumDefinition2);
 
-        final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
+        final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey(KEY_INFO_MAP_KEY, VERSION));
         final AxContextModel contextModel =
                 new AxContextModel(new AxArtifactKey("LongContextModel", VERSION), schemas, albums, keyInformation);
         contextModel.setKeyInformation(keyInformation);
@@ -180,7 +183,7 @@ public final class TestContextAlbumFactory {
         final AxContextSchema mapSchema = new AxContextSchema(new AxArtifactKey("MapSchema", VERSION), JAVA_FLAVOUR,
                 TestContextTreeMapItem.class.getCanonicalName());
 
-        final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("Schemas", VERSION));
+        final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey(SCHEMAS2, VERSION));
         schemas.getSchemasMap().put(longSchema.getKey(), longSchema);
         schemas.getSchemasMap().put(lTypeSchema.getKey(), lTypeSchema);
         schemas.getSchemasMap().put(dateSchema.getKey(), dateSchema);
@@ -195,13 +198,13 @@ public final class TestContextAlbumFactory {
         final AxContextAlbum mapAlbumDefinition = new AxContextAlbum(new AxArtifactKey(MAP_CONTEXT_ALBUM, VERSION),
                 APPLICATION, true, mapSchema.getKey());
 
-        final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", VERSION));
+        final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey(CONTEXT, VERSION));
         albums.getAlbumsMap().put(longAlbumDefinition.getKey(), longAlbumDefinition);
         albums.getAlbumsMap().put(lTypeAlbumDefinition.getKey(), lTypeAlbumDefinition);
         albums.getAlbumsMap().put(dateAlbumDefinition.getKey(), dateAlbumDefinition);
         albums.getAlbumsMap().put(mapAlbumDefinition.getKey(), mapAlbumDefinition);
 
-        final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", VERSION));
+        final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey(KEY_INFO_MAP_KEY, VERSION));
         final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("MultiAlbumsContextModel", VERSION),
                 schemas, albums, keyInformation);
         contextModel.setKeyInformation(keyInformation);
index 1253d22..d1127ff 100644 (file)
@@ -26,6 +26,7 @@ import org.onap.policy.apex.context.ContextException;
 /**
  * The Interface AlbumModifier defines the interface to allow context albums be modified during context tests.
  */
+@FunctionalInterface
 public interface AlbumModifier {
 
     /**
index 82de5b4..c4e6ac4 100644 (file)
@@ -64,7 +64,7 @@ public enum LockType {
      *
      * @param value the value
      */
-    private LockType(final int value) {
+    LockType(final int value) {
         this.value = value;
     }
 
index 88cdccc..87ffa3b 100644 (file)
@@ -67,7 +67,7 @@ public class ConcurrentContext {
      * @throws ApexException the Apex exception occurs in handling Apex
      */
     public Map<String, TestContextLongItem> testConcurrentContext()
-            throws ApexModelException, IOException, ApexException {
+            throws IOException, ApexException {
 
         try {
             setupAndVerifyContext();
@@ -140,7 +140,7 @@ public class ConcurrentContext {
      *
      * @throws ContextException the context exception
      */
-    private void setupAndVerifyContext() throws ContextException {
+    private void setupAndVerifyContext() {
         contextDistributor = configrationProvider.getDistributor();
         ltypeAlbum = configrationProvider.getContextAlbum(contextDistributor);
         final Map<String, Object> initValues = configrationProvider.getContextAlbumInitValues();
index 7d75485..b8e0529 100644 (file)
@@ -119,7 +119,7 @@ public final class ConcurrentContextJvm {
     public static void main(final String[] args) throws Exception {
         configure();
 
-        System.out.println("JVM Arguments: " + Arrays.toString(args));
+        LOGGER.info("JVM Arguments: " + Arrays.toString(args));
         // CHECKSTYLE:OFF: checkstyle:magicNumber
 
         // An even number of arguments greater than 3
@@ -137,7 +137,7 @@ public final class ConcurrentContextJvm {
         final int threadLoops = getIntValue("threadLoops", args, 3);
         final int albumSize = getIntValue("albumSize", args, 4);
         final int lockType = getIntValue("lockType", args, 5);
-        final String hazelCastfileLocation = getStringValue("hazelcast file location", args, 6);;
+        final String hazelCastfileLocation = getStringValue("hazelcast file location", args, 6);
 
         System.setProperty("hazelcast.config", hazelCastfileLocation);
 
@@ -162,10 +162,8 @@ public final class ConcurrentContextJvm {
 
         } catch (final Exception e) {
             LOGGER.error("error running test in JVM", e);
-            return;
         }
         // CHECKSTYLE:ON: checkstyle:magicNumber
-
     }
 
     private static String getStringValue(final String key, final String[] args, final int position) {
@@ -204,7 +202,7 @@ public final class ConcurrentContextJvm {
         // first non-loopback
         // IPv4 address
         // on a host
-        final TreeSet<String> ipAddressSet = new TreeSet<String>();
+        final TreeSet<String> ipAddressSet = new TreeSet<>();
 
         final Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
         for (final NetworkInterface netint : Collections.list(nets)) {
@@ -217,10 +215,10 @@ public final class ConcurrentContextJvm {
             }
         }
 
-        if (ipAddressSet.size() == 0) {
+        if (ipAddressSet.isEmpty()) {
             throw new Exception("cound not find real IP address for test");
         }
-        System.out.println("Setting jgroups.tcp.address to: " + ipAddressSet.first());
+        LOGGER.info("Setting jgroups.tcp.address to: " + ipAddressSet.first());
         System.setProperty("jgroups.tcp.address", ipAddressSet.first());
     }
 }
index 339c95d..dca7239 100644 (file)
@@ -72,11 +72,11 @@ public class ConcurrentContextJvmThread implements Runnable, Closeable {
         commandList.add(System.getProperty("java.class.path"));
         commandList.add(ConcurrentContextJvm.class.getCanonicalName());
         commandList.add(configrationProvider.getTestName());
-        commandList.add(new Integer(jvm).toString());
-        commandList.add(new Integer(configrationProvider.getThreadCount()).toString());
-        commandList.add(new Integer(configrationProvider.getLoopSize()).toString());
-        commandList.add(new Integer(configrationProvider.getAlbumSize()).toString());
-        commandList.add(new Integer(configrationProvider.getLockType().getValue()).toString());
+        commandList.add(Integer.toString(jvm));
+        commandList.add(Integer.toString(configrationProvider.getThreadCount()));
+        commandList.add(Integer.toString(configrationProvider.getLoopSize()));
+        commandList.add(Integer.toString(configrationProvider.getAlbumSize()));
+        commandList.add(Integer.toString(configrationProvider.getLockType().getValue()));
         commandList.add(System.getProperty("hazelcast.config", ""));
 
         for (final Entry<String, ParameterGroup> parameterServiceEntry : ParameterService.getAll()) {
index c632809..7020094 100644 (file)
@@ -129,8 +129,7 @@ public class ConfigrationProviderImpl implements ConfigrationProvider {
     public ExecutorService getExecutorService() {
         final String name = getThreadFactoryName(jvmCount, testType);
         final IntegrationThreadFactory threadFactory = new IntegrationThreadFactory(name);
-        final ExecutorService executorService = Executors.newFixedThreadPool(threadCount, threadFactory);
-        return executorService;
+        return Executors.newFixedThreadPool(threadCount, threadFactory);
     }
 
     /*
@@ -141,8 +140,7 @@ public class ConfigrationProviderImpl implements ConfigrationProvider {
     @Override
     public ExecutorService getExecutorService(final String threadFactoryName, final int threadPoolSize) {
         final IntegrationThreadFactory threadFactory = new IntegrationThreadFactory(threadFactoryName);
-        final ExecutorService executorService = Executors.newFixedThreadPool(threadPoolSize, threadFactory);
-        return executorService;
+        return Executors.newFixedThreadPool(threadPoolSize, threadFactory);
     }
 
     /*
index 927876e..4761bc6 100644 (file)
@@ -45,7 +45,7 @@ public class Constants {
     public static final String EXCEPTION_MESSAGE = "Test should throw an exception";
     public static final byte BYTE_VAL = (byte) 0xFF;
     public static final double PI_VAL = Math.PI;
-    public static final float FLOAT_VAL = 3.14159265359f;
+    public static final float FLOAT_VAL = 3.14159265359F;
     public static final String EXTERNAL_CONTEXT = "externalContext";
     public static final String GLOBAL_CONTEXT_KEY = "globalContext";
     public static final String STRING_GLOBAL_VAL = "This is a global context string";
index 9803840..d26ce95 100644 (file)
@@ -25,6 +25,7 @@ import java.net.NetworkInterface;
 import java.net.SocketException;
 import java.util.Collections;
 import java.util.Enumeration;
+import java.util.SortedSet;
 import java.util.TreeSet;
 
 /**
@@ -45,8 +46,8 @@ public class NetworkUtils {
      * @return Set of IPv4 addresses
      * @throws SocketException throw socket exception if error occurs
      */
-    public static TreeSet<String> getIPv4NonLoopAddresses() throws SocketException {
-        final TreeSet<String> ipAddressSet = new TreeSet<String>();
+    public static SortedSet<String> getIPv4NonLoopAddresses() throws SocketException {
+        final TreeSet<String> ipAddressSet = new TreeSet<>();
 
         final Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
         for (final NetworkInterface netint : Collections.list(nets)) {
index 8bfb150..b275c72 100644 (file)
@@ -127,7 +127,7 @@ public class BatchDeployer {
      * @throws IOException on IO exceptions from the operating system
      */
     public void deployModel(final AxPolicyModel policyModel, final boolean ignoreConflicts, final boolean force)
-                    throws ApexException, IOException {
+                    throws ApexException {
         engineServiceFacade.deployModel(policyModel, ignoreConflicts, force);
     }
 
index a1db5ef..5f0752a 100644 (file)
@@ -40,39 +40,6 @@ public class PeriodicEventManager {
     // The facade that is handling messaging to the engine service
     private EngineServiceFacade engineServiceFacade = null;
 
-    /**
-     * The main method, reads the Apex server host address, port and location of the Apex model XML file from the
-     * command line arguments.
-     *
-     * @param args the arguments that specify the Apex engine and the Apex model file
-     */
-    public static void main(final String[] args) {
-        if (args.length != NUM_ARGUMENTS) {
-            String message = "invalid arguments: " + Arrays.toString(args)
-                            + "\nusage: Deployer <server address> <port address> <start/stop> <periods in ms>";
-            LOGGER.error(message);
-            return;
-        }
-
-        PeriodicEventManager deployer = null;
-        try {
-            // Use a Deployer object to handle model deployment
-            deployer = new PeriodicEventManager(args[0], Integer.parseInt(args[1]));
-            deployer.init();
-            if (args[2].equalsIgnoreCase("start")) {
-                deployer.startPerioidicEvents(Long.parseLong(args[PERIODIC_EVENT_INTERVAL]));
-            } else {
-                deployer.stopPerioidicEvents();
-            }
-        } catch (final ApexException e) {
-            LOGGER.error("model deployment failed on parameters {}", args, e);
-        } finally {
-            if (deployer != null) {
-                deployer.close();
-            }
-        }
-    }
-
     /**
      * Instantiates a new deployer.
      *
@@ -121,4 +88,37 @@ public class PeriodicEventManager {
             engineServiceFacade.stopPerioidicEvents(engineKey);
         }
     }
+
+    /**
+     * The main method, reads the Apex server host address, port and location of the Apex model XML file from the
+     * command line arguments.
+     *
+     * @param args the arguments that specify the Apex engine and the Apex model file
+     */
+    public static void main(final String[] args) {
+        if (args.length != NUM_ARGUMENTS) {
+            String message = "invalid arguments: " + Arrays.toString(args)
+                            + "\nusage: Deployer <server address> <port address> <start/stop> <periods in ms>";
+            LOGGER.error(message);
+            return;
+        }
+
+        PeriodicEventManager deployer = null;
+        try {
+            // Use a Deployer object to handle model deployment
+            deployer = new PeriodicEventManager(args[0], Integer.parseInt(args[1]));
+            deployer.init();
+            if ("start".equalsIgnoreCase(args[2])) {
+                deployer.startPerioidicEvents(Long.parseLong(args[PERIODIC_EVENT_INTERVAL]));
+            } else {
+                deployer.stopPerioidicEvents();
+            }
+        } catch (final ApexException e) {
+            LOGGER.error("model deployment failed on parameters {}", args, e);
+        } finally {
+            if (deployer != null) {
+                deployer.close();
+            }
+        }
+    }
 }
index 7c49af9..58bee82 100644 (file)
@@ -58,7 +58,7 @@ public class EnEvent extends HashMap<String, Object> {
     private final AxEvent axEvent;
 
     // The event monitor for this event
-    private final EventMonitor eventMonitor = new EventMonitor();
+    private final transient EventMonitor eventMonitor = new EventMonitor();
 
     // The stack of execution of this event, used for monitoring
     private AxConcept[] userArtifactStack;
@@ -289,7 +289,7 @@ public class EnEvent extends HashMap<String, Object> {
     @Override
     public void putAll(final Map<? extends String, ? extends Object> incomingMap) {
         // Override the generic "putAll()" call as we want to monitor the puts
-        for (final java.util.Map.Entry<? extends String, ? extends Object> incomingEntry : incomingMap.entrySet()) {
+        for (final Map.Entry<? extends String, ? extends Object> incomingEntry : incomingMap.entrySet()) {
             put(incomingEntry.getKey(), incomingEntry.getValue());
         }
     }
index 15fbacf..a4b2218 100644 (file)
@@ -45,10 +45,10 @@ public class EnField implements Serializable {
     private final AxField axField;
 
     // The schema helper for this field
-    private SchemaHelper schemaHelper;
+    private transient SchemaHelper schemaHelper;
 
     // The value of this field
-    private final Object value;
+    private final transient Object value;
 
     /**
      * Instantiates a new EnField, an Engine Field.
index ad5b74c..c361701 100644 (file)
@@ -164,7 +164,7 @@ public class ContextAlbumFacade {
                 contextAlbum.setScope(scope);
             }
             if (writable != null) {
-                if (writable.trim().equalsIgnoreCase("true") || writable.trim().equalsIgnoreCase("t")) {
+                if ("true".equalsIgnoreCase(writable.trim()) || "t".equalsIgnoreCase(writable.trim())) {
                     contextAlbum.setWritable(true);
                 } else {
                     contextAlbum.setWritable(false);
index a40a810..f1bc4ae 100644 (file)
@@ -99,7 +99,7 @@ public class PolicyLogicReader implements AxLogicReader {
     @Override
     public String readLogic(final AxLogic axLogic) {
         // Java uses compiled logic, other executor types run scripts
-        if (axLogic.getLogicFlavour().equals("JAVA")) {
+        if ("JAVA".equals(axLogic.getLogicFlavour())) {
             // Check if we're using the default logic
             if (defaultLogic != null) {
                 // Return the java class name for the default logic
index a9418d8..ed2b521 100644 (file)
@@ -210,7 +210,7 @@ public class AvroSchemaHelper extends AbstractSchemaHelper {
 
     private String getJsonString(final Object object, final Object conditionedObject) {
 
-        try (final ByteArrayOutputStream output = new ByteArrayOutputStream();) {
+        try (final ByteArrayOutputStream output = new ByteArrayOutputStream()) {
             final DatumWriter<Object> writer = new GenericDatumWriter<>(avroSchema);
             final JsonEncoder jsonEncoder = EncoderFactory.get().jsonEncoder(avroSchema, output, true);
             writer.write(conditionedObject, jsonEncoder);
index de32451..3031655 100644 (file)
@@ -101,7 +101,7 @@ public class ApexJmsConsumer implements MessageListener, ApexEventConsumer, Runn
 
             // Check if we actually got a connection factory
             if (connectionFactory == null) {
-                throw new NullPointerException(
+                throw new IllegalArgumentException(
                         "JMS context lookup of \"" + jmsConsumerProperties.getConnectionFactory() + "\" returned null");
             }
         } catch (final Exception e) {
@@ -118,7 +118,7 @@ public class ApexJmsConsumer implements MessageListener, ApexEventConsumer, Runn
 
             // Check if we actually got a topic
             if (jmsIncomingTopic == null) {
-                throw new NullPointerException(
+                throw new IllegalArgumentException(
                         "JMS context lookup of \"" + jmsConsumerProperties.getConsumerTopic() + "\" returned null");
             }
         } catch (final Exception e) {
index 0580d71..83321e4 100644 (file)
@@ -103,7 +103,7 @@ public class ApexJmsProducer implements ApexEventProducer {
 
             // Check if we actually got a connection factory
             if (connectionFactory == null) {
-                throw new NullPointerException("JMS context lookup of \"" + jmsProducerProperties.getConnectionFactory()
+                throw new IllegalArgumentException("JMS context lookup of \"" + jmsProducerProperties.getConnectionFactory()
                                 + "\" returned null for producer (" + this.name + ")");
             }
         } catch (final Exception e) {
@@ -121,7 +121,7 @@ public class ApexJmsProducer implements ApexEventProducer {
 
             // Check if we actually got a topic
             if (jmsOutgoingTopic == null) {
-                throw new NullPointerException("JMS context lookup of \"" + jmsProducerProperties.getProducerTopic()
+                throw new IllegalArgumentException("JMS context lookup of \"" + jmsProducerProperties.getProducerTopic()
                                 + "\" returned null for producer (" + this.name + ")");
             }
         } catch (final Exception e) {
index 82c3cf3..5556d03 100644 (file)
@@ -85,8 +85,8 @@ public class ApexRestClientProducer implements ApexEventProducer {
             restProducerProperties.setHttpMethod(RestClientCarrierTechnologyParameters.DEFAULT_PRODUCER_HTTP_METHOD);
         }
 
-        if (!restProducerProperties.getHttpMethod().equalsIgnoreCase("POST")
-                        && !restProducerProperties.getHttpMethod().equalsIgnoreCase("PUT")) {
+        if (!"POST".equalsIgnoreCase(restProducerProperties.getHttpMethod())
+                        && !"PUT".equalsIgnoreCase(restProducerProperties.getHttpMethod())) {
             final String errorMessage = "specified HTTP method of \"" + restProducerProperties.getHttpMethod()
                             + "\" is invalid, only HTTP methods \"POST\" and \"PUT\" are supproted "
                             + "for event sending on REST client producer (" + this.name + ")";
@@ -183,7 +183,7 @@ public class ApexRestClientProducer implements ApexEventProducer {
      */
     public Response sendEventAsRestRequest(final String event) {
         // We have already checked that it is a PUT or POST request
-        if (restProducerProperties.getHttpMethod().equalsIgnoreCase("POST")) {
+        if ("POST".equalsIgnoreCase(restProducerProperties.getHttpMethod())) {
             return client.target(restProducerProperties.getUrl()).request("application/json").post(Entity.json(event));
         } else {
             return client.target(restProducerProperties.getUrl()).request("application/json").put(Entity.json(event));
index 9e90244..aaccbeb 100644 (file)
@@ -89,7 +89,7 @@ public class JrubyStateFinalizerExecutor extends StateFinalizerExecutor {
         boolean returnValue = false;
         final IRubyObject ret = parsedjruby.run();
         if (ret != null) {
-            final Boolean retbool = (Boolean) ret.toJava(java.lang.Boolean.class);
+            final Boolean retbool = ret.toJava(java.lang.Boolean.class);
             if (retbool != null) {
                 returnValue = true;
             }
index d494234..8019259 100644 (file)
@@ -89,7 +89,7 @@ public class JrubyTaskExecutor extends TaskExecutor {
         boolean returnValue = false;
         final IRubyObject ret = parsedjruby.run();
         if (ret != null) {
-            final Boolean retbool = (Boolean) ret.toJava(java.lang.Boolean.class);
+            final Boolean retbool = ret.toJava(java.lang.Boolean.class);
             if (retbool != null) {
                 returnValue = true;
             }
index b3ce7e0..0e239f7 100644 (file)
@@ -90,7 +90,7 @@ public class JrubyTaskSelectExecutor extends TaskSelectExecutor {
         boolean returnValue = false;
         final IRubyObject ret = parsedjruby.run();
         if (ret != null) {
-            final Boolean retbool = (Boolean) ret.toJava(java.lang.Boolean.class);
+            final Boolean retbool = ret.toJava(java.lang.Boolean.class);
             if (retbool != null) {
                 returnValue = true;
             }
index 9820440..9786a36 100644 (file)
@@ -54,7 +54,7 @@ public class HeaderDelimitedTextBlockReader implements TextBlockReader, Runnable
     private boolean blockEndTokenUsed = false;
 
     // The thread used to read the text from the stream
-    Thread textConsumputionThread;
+    private Thread textConsumputionThread;
 
     // The input stream for text
     private InputStream inputStream;
index 8e4cb82..f537b57 100644 (file)
@@ -29,6 +29,7 @@ import org.onap.policy.apex.service.engine.event.ApexEvent;
  * @author Sajeevan Achuthan (sajeevan.achuthan@ericsson.com), John Keeney
  *         (john.keeney@ericsson.com)
  */
+@FunctionalInterface
 public interface EngineServiceEventInterface {
     /**
      * This method forwards an event to the APEX engine.
index 8837932..25c7fa1 100644 (file)
@@ -215,7 +215,7 @@ public class EvalDomainModelFactory {
         final AxLogicReader logicReader = new PolicyLogicReader().setLogicPackage(PACKAGE)
                         .setDefaultLogic("EvalTask_Logic");
 
-        final AxTask obTask = new AxTask(new AxArtifactKey("Task_Observe_0", "0.0.1"));
+        final AxTask obTask = new AxTask(new AxArtifactKey("Task_Observe_0", DEFAULT_VERSION));
         obTask.duplicateInputFields(event0000.getParameterMap());
         obTask.duplicateOutputFields(event0001.getParameterMap());
         final AxTaskLogic obAxLogic = new AxTaskLogic(obTask.getKey(), TASK_LOGIC,
index 5fadb22..a62414a 100644 (file)
@@ -30,7 +30,7 @@ import java.io.File;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.util.Map;
-import java.util.TreeSet;
+import java.util.SortedSet;
 
 import org.junit.BeforeClass;
 import org.junit.Rule;
@@ -106,7 +106,7 @@ public class TestConcurrentContext {
         final String hazelCastfileLocation = ResourceUtils.getFilePath4Resource(HAZELCAST_XML_FILE);
         System.setProperty(HAZELCAST_CONFIG, hazelCastfileLocation);
 
-        final TreeSet<String> ipAddressSet = NetworkUtils.getIPv4NonLoopAddresses();
+        final SortedSet<String> ipAddressSet = NetworkUtils.getIPv4NonLoopAddresses();
 
         if (ipAddressSet.size() == 0) {
             throw new Exception("cound not find real IP address for test");
index a306b53..5251cc0 100644 (file)
@@ -87,9 +87,9 @@ public class EngDepMessagingTest {
         contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
 
         ParameterService.register(contextParameters, true);
-        ParameterService.register(contextParameters.getDistributorParameters());
-        ParameterService.register(contextParameters.getLockManagerParameters());
-        ParameterService.register(contextParameters.getPersistorParameters());
+        ParameterService.register(contextParameters.getDistributorParameters(), true);
+        ParameterService.register(contextParameters.getLockManagerParameters(), true);
+        ParameterService.register(contextParameters.getPersistorParameters(), true);
 
         engineServiceParameters = new EngineServiceParameters();
         engineServiceParameters.setName("EngDepMessagingTest");
@@ -100,8 +100,8 @@ public class EngDepMessagingTest {
         engineServiceParameters.getEngineParameters().getExecutorParameterMap().put("MVEL",
                         new MvelExecutorParameters());
 
-        ParameterService.register(engineServiceParameters);
-        ParameterService.register(engineServiceParameters.getEngineParameters());
+        ParameterService.register(engineServiceParameters, true);
+        ParameterService.register(engineServiceParameters.getEngineParameters(), true);
     }
 
     /**
index 6414fa8..1361012 100644 (file)
@@ -25,7 +25,7 @@ import static org.junit.Assert.fail;
 import java.io.File;
 import java.io.IOException;
 import java.util.Arrays;
-import java.util.TreeSet;
+import java.util.SortedSet;
 
 import org.junit.BeforeClass;
 import org.junit.Rule;
@@ -62,7 +62,7 @@ public class TestMetrics {
         final String hazelCastfileLocation = ResourceUtils.getFilePath4Resource(HAZELCAST_XML_FILE);
         System.setProperty(HAZELCAST_CONFIG, hazelCastfileLocation);
 
-        final TreeSet<String> ipAddressSet = NetworkUtils.getIPv4NonLoopAddresses();
+        final SortedSet<String> ipAddressSet = NetworkUtils.getIPv4NonLoopAddresses();
 
         if (ipAddressSet.size() == 0) {
             throw new Exception("cound not find real IP address for test");
index aacc220..2675849 100644 (file)
@@ -25,8 +25,6 @@ import java.util.List;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.text.StrBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.slf4j.ext.XLoggerFactory;
 import org.slf4j.helpers.MessageFormatter;