aboutsummaryrefslogtreecommitdiffstats
path: root/model/utilities
diff options
context:
space:
mode:
Diffstat (limited to 'model/utilities')
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java50
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/CollectionUtils.java12
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryDeleteShutdownHook.java56
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryUtils.java46
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyComparer.java4
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyDifference.java6
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapComparer.java10
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapDifference.java344
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/json/JsonHandler.java (renamed from model/utilities/src/main/java/org/onap/policy/apex/model/utilities/json/JSONHandler.java)12
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/typeutils/ClassBuilder.java23
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/typeutils/TypeBuilder.java22
-rw-r--r--model/utilities/src/test/java/org/onap/policy/apex/model/utilities/AssertionsTest.java54
-rw-r--r--model/utilities/src/test/java/org/onap/policy/apex/model/utilities/CollectionUtilitiesTest.java12
-rw-r--r--model/utilities/src/test/java/org/onap/policy/apex/model/utilities/TextFileUtilsTest.java1
-rw-r--r--model/utilities/src/test/java/org/onap/policy/apex/model/utilities/TreeMapUtilsTest.java1
-rw-r--r--model/utilities/src/test/java/org/onap/policy/apex/model/utilities/json/JsonHandlerTest.java2
-rw-r--r--model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/ParserTest.java30
-rw-r--r--model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/TestKeyComparer.java1
-rw-r--r--model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/TestKeyedMapComparer.java16
19 files changed, 369 insertions, 333 deletions
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java
index 80a71f8aa..a3ecccebe 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java
@@ -41,18 +41,18 @@ public final class Assertions {
* @param pattern The regular expression
* @return null if the parameter is valid, the validation message otherwise
*/
- public static String getStringParameterValidationMessage(final String parameterName, final String parameterValue, final String pattern) {
+ public static String getStringParameterValidationMessage(final String parameterName, final String parameterValue,
+ final String pattern) {
try {
validateStringParameter(parameterName, parameterValue, pattern);
- }
- catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
// This will cause a SONAR error but eliminates all SONAR messages in callers
return e.getMessage();
}
-
+
return null;
}
-
+
/**
* Checks if a string parameter matches a regular expression.
*
@@ -61,7 +61,8 @@ public final class Assertions {
* @param pattern The regular expression
* @return the trimmed string
*/
- public static String validateStringParameter(final String parameterName, final String parameterValue, final String pattern) {
+ public static String validateStringParameter(final String parameterName, final String parameterValue,
+ final String pattern) {
argumentNotNull(parameterName, "parameter name is null");
argumentNotNull(parameterValue, "parameter \"" + parameterName + "\" is null");
argumentNotNull(pattern, "parameter pattern is null");
@@ -69,10 +70,9 @@ public final class Assertions {
final String trimmedValue = parameterValue.trim();
if (trimmedValue.matches(pattern)) {
return trimmedValue;
- }
- else {
- throw new IllegalArgumentException(
- "parameter \"" + parameterName + "\": value \"" + parameterValue + "\", does not match regular expression \"" + pattern + "\"");
+ } else {
+ throw new IllegalArgumentException("parameter \"" + parameterName + "\": value \"" + parameterValue
+ + "\", does not match regular expression \"" + pattern + "\"");
}
}
@@ -102,7 +102,8 @@ public final class Assertions {
}
/**
- * Used as a shorthand to check that method arguments are not null, throws an exception of the specified type on error.
+ * Used as a shorthand to check that method arguments are not null, throws an exception of the specified type on
+ * error.
*
* @param <T> the generic type of the argument to check
* @param <E> the exception to throw if incoming value is null
@@ -111,20 +112,21 @@ public final class Assertions {
* @param message the error message to issue
* @throws E an instance of the passed Exception Class
*/
- public static <T, E extends Exception> void argumentNotNull(final T value, final Class<E> exceptionClass, final String message) throws E {
+ public static <T, E extends Exception> void argumentOfClassNotNull(final T value, final Class<E> exceptionClass,
+ final String message) throws E {
if (value == null) {
// Instantiate the exception and throw it
try {
throw exceptionClass.getConstructor(String.class).newInstance(message);
- }
- catch (final Exception errorException) {
+ } catch (final Exception errorException) {
throw new IllegalArgumentException(message, errorException);
}
}
}
/**
- * Used as a shorthand to check that method argument is not false, throws an exception of the specified type on error.
+ * Used as a shorthand to check that method argument is not false, throws an exception of the specified type on
+ * error.
*
* @param <E> the exception to throw if incoming value is false
* @param value the value to check if false
@@ -132,20 +134,21 @@ public final class Assertions {
* @param message the error message to issue
* @throws E an instance of the passed Exception Class
*/
- public static <E extends Exception> void argumentNotFalse(final boolean value, final Class<E> exceptionClass, final String message) throws E {
+ public static <E extends Exception> void argumentOfClassNotFalse(final boolean value, final Class<E> exceptionClass,
+ final String message) throws E {
if (!value) {
// Instantiate the exception and throw it
try {
throw exceptionClass.getConstructor(String.class).newInstance(message);
- }
- catch (final Exception errorException) {
+ } catch (final Exception errorException) {
throw new IllegalArgumentException(message, errorException);
}
}
}
/**
- * Used as a shorthand to check that an object is an instance of a given class, throws IllegalArgumentException on error.
+ * Used as a shorthand to check that an object is an instance of a given class, throws IllegalArgumentException on
+ * error.
*
* @param <T> the generic type of the argument to check
* @param objectInstance the object instance for which to check the class
@@ -154,12 +157,14 @@ public final class Assertions {
*/
public static <T> void instanceOf(final Object objectInstance, final Class<T> requiredClass) {
if (!requiredClass.isAssignableFrom(objectInstance.getClass())) {
- throw new IllegalArgumentException(objectInstance.getClass().getCanonicalName() + " is not an instance of " + requiredClass.getCanonicalName());
+ throw new IllegalArgumentException(objectInstance.getClass().getCanonicalName() + " is not an instance of "
+ + requiredClass.getCanonicalName());
}
}
/**
- * Used as a shorthand to check that an instance of a class can be an instance of a given class, throws IllegalArgumentException on error.
+ * Used as a shorthand to check that an instance of a class can be an instance of a given class, throws
+ * IllegalArgumentException on error.
*
* @param <T> the generic type of the argument to check
* @param checkClass the class to check
@@ -168,7 +173,8 @@ public final class Assertions {
*/
public static <T> void assignableFrom(final Class<?> checkClass, final Class<T> requiredClass) {
if (!requiredClass.isAssignableFrom(checkClass)) {
- throw new IllegalArgumentException(checkClass.getCanonicalName() + " is not an instance of " + requiredClass.getCanonicalName());
+ throw new IllegalArgumentException(checkClass.getCanonicalName() + " is not an instance of "
+ + requiredClass.getCanonicalName());
}
}
}
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/CollectionUtils.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/CollectionUtils.java
index 7ca50a613..0d90d8ceb 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/CollectionUtils.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/CollectionUtils.java
@@ -43,7 +43,8 @@ public abstract class CollectionUtils {
* @param rightList The rightmost list
* @return an integer indicating how different the lists are
*/
- public static <T> int compareLists(final List<? extends Comparable<T>> leftList, final List<? extends Comparable<T>> rightList) {
+ public static <T> int compareLists(final List<? extends Comparable<T>> leftList,
+ final List<? extends Comparable<T>> rightList) {
// Check for nulls
if (leftList == null && rightList == null) {
return 0;
@@ -59,7 +60,7 @@ public abstract class CollectionUtils {
if (leftList.equals(rightList)) {
return 0;
}
-
+
return compareListEntries(leftList, rightList);
}
@@ -71,8 +72,9 @@ public abstract class CollectionUtils {
* @param rightList The rightmost list
* @return an integer indicating how different the lists are
*/
- private static <T> int compareListEntries(final List<? extends Comparable<T>> leftList, final List<? extends Comparable<T>> rightList) {
-
+ private static <T> int compareListEntries(final List<? extends Comparable<T>> leftList,
+ final List<? extends Comparable<T>> rightList) {
+
// Iterate down the lists till we find a difference
final ListIterator<?> leftIterator = leftList.listIterator();
final ListIterator<?> rightIterator = rightList.listIterator();
@@ -104,5 +106,5 @@ public abstract class CollectionUtils {
return comparisonResult;
}
}
- }
+ }
}
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryDeleteShutdownHook.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryDeleteShutdownHook.java
new file mode 100644
index 000000000..5f9b8aaf8
--- /dev/null
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryDeleteShutdownHook.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.model.utilities;
+
+import java.io.File;
+
+/**
+ * The Class DirectoryShutdownHook removes the contents of a directory and the directory itself at shutdown.
+ *
+ * @author Liam Fallon (liam.fallon@ericsson.com)
+ */
+final class DirectoryDeleteShutdownHook extends Thread {
+ // The directory we are acting on
+ private final File tempDir;
+
+ /**
+ * Constructor that defines the directory to act on at shutdown.
+ *
+ * @param tempDir The temporary directory to delete
+ */
+ DirectoryDeleteShutdownHook(final File tempDir) {
+ this.tempDir = tempDir;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Runnable#run()
+ */
+ @Override
+ public void run() {
+ if (tempDir.exists()) {
+ // Empty and delete the directory
+ DirectoryUtils.emptyDirectory(tempDir);
+ tempDir.delete();
+ }
+ }
+}
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryUtils.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryUtils.java
index 00e5cb4cf..7cd5228cc 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryUtils.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryUtils.java
@@ -26,8 +26,8 @@ import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/**
- * This is common utility class with static methods for handling directories. It is an abstract class to prevent any direct instantiation and private
- * constructor to prevent extending this class.
+ * This is common utility class with static methods for handling directories. It is an abstract class to prevent any
+ * direct instantiation and private constructor to prevent extending this class.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
@@ -42,9 +42,11 @@ public abstract class DirectoryUtils {
}
/**
- * Method to get an empty temporary directory in the system temporary directory on the local machine that will be deleted on (normal) shutdown.
+ * Method to get an empty temporary directory in the system temporary directory on the local machine that will be
+ * deleted on (normal) shutdown.
*
- * @param nameprefix The prefix of the filename. System.nanoTime() will be appended to the pattern to create a unique file pattern
+ * @param nameprefix The prefix of the filename. System.nanoTime() will be appended to the pattern to create a
+ * unique file pattern
* @return The temporary directory
*/
public static File getLocalTempDirectory(final String nameprefix) {
@@ -66,8 +68,7 @@ public abstract class DirectoryUtils {
LOGGER.trace("creating temp directory\"{}\" : ", tempDir.getAbsolutePath());
return tempDir;
- }
- catch (final Exception e) {
+ } catch (final Exception e) {
LOGGER.debug("error creating temp directory\"{}\" : " + e.getMessage(), e);
return null;
}
@@ -103,36 +104,3 @@ public abstract class DirectoryUtils {
return true;
}
}
-
-/**
- * The Class DirectoryShutdownHook removes the contents of a directory and the directory itself at shutdown.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-final class DirectoryDeleteShutdownHook extends Thread {
- // The directory we are acting on
- private final File tempDir;
-
- /**
- * Constructor that defines the directory to act on at shutdown.
- *
- * @param tempDir The temporary directory to delete
- */
- DirectoryDeleteShutdownHook(final File tempDir) {
- this.tempDir = tempDir;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Runnable#run()
- */
- @Override
- public void run() {
- if (tempDir.exists()) {
- // Empty and delete the directory
- DirectoryUtils.emptyDirectory(tempDir);
- tempDir.delete();
- }
- }
-}
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyComparer.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyComparer.java
index 8903ea803..f4d628405 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyComparer.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyComparer.java
@@ -21,8 +21,8 @@
package org.onap.policy.apex.model.utilities.comparison;
/**
- * This class compares two keys and returns their differences. It is used in bulk comparisons in models where maps of keys are being compared. The
- * {@link KeyComparer} that is returned does the actual comparison
+ * This class compares two keys and returns their differences. It is used in bulk comparisons in models where maps of
+ * keys are being compared. The {@link KeyComparer} that is returned does the actual comparison
*
* @author Liam Fallon (liam.fallon@ericsson.com)
* @param <K> the type of key being compared
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyDifference.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyDifference.java
index 43c44aefe..2eb6af894 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyDifference.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyDifference.java
@@ -21,7 +21,8 @@
package org.onap.policy.apex.model.utilities.comparison;
/**
- * This class is used to template key differences for bulk key comparisons in models. It performs a difference check between two keys.
+ * This class is used to template key differences for bulk key comparisons in models. It performs a difference check
+ * between two keys.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
* @param <K> the generic type
@@ -86,8 +87,7 @@ public class KeyDifference<K> {
builder.append(rightKey);
builder.append('\n');
}
- }
- else {
+ } else {
builder.append("left key ");
builder.append(leftKey);
builder.append(" and right key ");
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapComparer.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapComparer.java
index b11f77a0f..24ff55263 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapComparer.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapComparer.java
@@ -27,9 +27,10 @@ import java.util.Set;
import java.util.TreeSet;
/**
- * Compare two maps and returns their differences. The types of the keys and the values in the two maps being comapred must be the same. The class returns
- * entries that are only in the left map, only in the right map, entries that have identical keys and different values and entries that have different keys and
- * different values in a {@link KeyedMapDifference} instance.
+ * Compare two maps and returns their differences. The types of the keys and the values in the two maps being comapred
+ * must be the same. The class returns entries that are only in the left map, only in the right map, entries that have
+ * identical keys and different values and entries that have different keys and different values in a
+ * {@link KeyedMapDifference} instance.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
* @param <K> the type of the keys in the maps being compared
@@ -79,8 +80,7 @@ public class KeyedMapComparer<K, V> {
// Store as appropriate
if (leftValue.equals(rightValue)) {
result.getIdenticalValues().put(key, leftValue);
- }
- else {
+ } else {
// Store the two values
List<V> valueList = new ArrayList<>();
valueList.add(leftValue);
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapDifference.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapDifference.java
index 0f9d6ca50..a7022d84d 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapDifference.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapDifference.java
@@ -26,181 +26,183 @@ import java.util.Map.Entry;
import java.util.TreeMap;
/**
- * This class holds the result of a difference check between two keyed maps. Four results are returned in the class. The {@code leftOnly} result is the entries
- * that appear only in the left map. the {@code rightOnly} result is the entries that appear only in the right map. The {@code differentValues} result are the
- * entries that have the same key but different values in the maps being compared. The {@code identicalValues} result are the entries with identical keys and
- * values in both maps being compared.
+ * This class holds the result of a difference check between two keyed maps. Four results are returned in the class. The
+ * {@code leftOnly} result is the entries that appear only in the left map. the {@code rightOnly} result is the entries
+ * that appear only in the right map. The {@code differentValues} result are the entries that have the same key but
+ * different values in the maps being compared. The {@code identicalValues} result are the entries with identical keys
+ * and values in both maps being compared.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
* @param <K> the generic type
* @param <V> the generic type
*/
public class KeyedMapDifference<K, V> {
- private static final String KEY = "key=";
- private static final String VALUE = ",value=";
-
- // Three maps to hold the comparison result
- private Map<K, V> leftOnly = new TreeMap<>();
- private Map<K, V> rightOnly = new TreeMap<>();
- private Map<K, V> identicalValues = new TreeMap<>();
- private Map<K, List<V>> differentValues = new TreeMap<>();
-
- /**
- * Gets the entries that were found only in the left map.
- *
- * @return the entries only in the left map
- */
- public Map<K, V> getLeftOnly() {
- return leftOnly;
- }
-
- /**
- * Gets the entries that were found only in the right map.
- *
- * @return the entries only in the right map
- */
- public Map<K, V> getRightOnly() {
- return rightOnly;
- }
-
- /**
- * Gets the entries that were identical (keys and values the same) in both maps.
- *
- * @return the identical entries
- */
- public Map<K, V> getIdenticalValues() {
- return identicalValues;
- }
-
- /**
- * Gets the entries that had the same key but different values in both maps.
- *
- * @return the entries that were different. There are two values in the list of values for each entry. The first value is the value that was in the left map
- * and the second value is the value that was in the right map.
- */
- public Map<K, List<V>> getDifferentValues() {
- return differentValues;
- }
-
- /**
- * Return a string representation of the differences.
- *
- * @param diffsOnly if set, then a blank string is returned if the maps are equal
- * @param keysOnly if set, then a terse string that prints only the keys is returned, otherwise both keys and values are printed
- * @return the string
- */
- public String asString(final boolean diffsOnly, final boolean keysOnly) {
- StringBuilder builder = new StringBuilder();
-
- if (leftOnly.isEmpty()) {
- if (!diffsOnly) {
- builder.append("*** all left keys in right\n");
- }
- }
- else {
- builder.append(getInOneSideOnlyAsString(leftOnly, "left", keysOnly));
- }
-
- if (leftOnly.isEmpty()) {
- if (!diffsOnly) {
- builder.append("*** all right keys in left\n");
- }
- }
- else {
- builder.append(getInOneSideOnlyAsString(rightOnly, "right", keysOnly));
- }
-
- if (differentValues.isEmpty()) {
- if (!diffsOnly) {
- builder.append("*** all values in left and right are identical\n");
- }
- }
- else {
- builder.append(getDifferencesAsString(keysOnly));
- }
-
- if (!diffsOnly) {
- builder.append(getIdenticalsAsString(keysOnly));
- }
-
- return builder.toString();
- }
-
- /**
- * Output the entries in a map with entries that are in one side only as a string
- * @param sideMap the map for the side being checked
- * @param sideMapString the string that represents the map in output strings
- * @param keysOnly if true, just add key information and not entries
- * @return the entries as a string
- */
- private Object getInOneSideOnlyAsString(final Map<K, V> sideMap, final String sideMapString, final boolean keysOnly) {
- StringBuilder builder = new StringBuilder();
-
- builder.append("*** list of keys on " + sideMapString + " only\n");
- for (Entry<K, V> leftEntry : sideMap.entrySet()) {
- builder.append(KEY);
- builder.append(leftEntry.getKey());
- if (!keysOnly) {
- builder.append(VALUE);
- builder.append(leftEntry.getValue());
- }
- builder.append('\n');
- }
-
- return builder.toString();
- }
-
- /**
- * Output the differences between two the maps as a string
- * @param keysOnly if true, just add key information and not entries
- * @return the differences as a string
- */
- private String getDifferencesAsString(final boolean keysOnly) {
- StringBuilder builder = new StringBuilder();
-
- builder.append("*** list of differing entries between left and right\n");
- for (Entry<K, List<V>> differentEntry : differentValues.entrySet()) {
- builder.append(KEY);
- builder.append(differentEntry.getKey());
- if (!keysOnly) {
- builder.append(",values={");
- boolean first = true;
- for (V differentEntryValue : differentEntry.getValue()) {
- builder.append(differentEntryValue);
- if (first) {
- first = false;
- }
- else {
- builder.append(',');
- }
- }
- builder.append("}");
- }
- builder.append('\n');
- }
-
- return builder.toString();
- }
-
- /**
- * Output the identical entries in the maps as a string
- * @param keysOnly if true, just add key information and not entries
- * @return the identical entries as a string
- */
- private String getIdenticalsAsString(final boolean keysOnly) {
- StringBuilder builder = new StringBuilder();
-
- builder.append("*** list of identical entries in left and right\n");
- for (Entry<K, V> identicalEntry : identicalValues.entrySet()) {
- builder.append(KEY);
- builder.append(identicalEntry.getKey());
- if (!keysOnly) {
- builder.append(VALUE);
- builder.append(identicalEntry.getValue());
- }
- builder.append('\n');
- }
-
- return builder.toString();
- }
+ private static final String KEY = "key=";
+ private static final String VALUE = ",value=";
+
+ // Three maps to hold the comparison result
+ private Map<K, V> leftOnly = new TreeMap<>();
+ private Map<K, V> rightOnly = new TreeMap<>();
+ private Map<K, V> identicalValues = new TreeMap<>();
+ private Map<K, List<V>> differentValues = new TreeMap<>();
+
+ /**
+ * Gets the entries that were found only in the left map.
+ *
+ * @return the entries only in the left map
+ */
+ public Map<K, V> getLeftOnly() {
+ return leftOnly;
+ }
+
+ /**
+ * Gets the entries that were found only in the right map.
+ *
+ * @return the entries only in the right map
+ */
+ public Map<K, V> getRightOnly() {
+ return rightOnly;
+ }
+
+ /**
+ * Gets the entries that were identical (keys and values the same) in both maps.
+ *
+ * @return the identical entries
+ */
+ public Map<K, V> getIdenticalValues() {
+ return identicalValues;
+ }
+
+ /**
+ * Gets the entries that had the same key but different values in both maps.
+ *
+ * @return the entries that were different. There are two values in the list of values for each entry. The first
+ * value is the value that was in the left map and the second value is the value that was in the right map.
+ */
+ public Map<K, List<V>> getDifferentValues() {
+ return differentValues;
+ }
+
+ /**
+ * Return a string representation of the differences.
+ *
+ * @param diffsOnly if set, then a blank string is returned if the maps are equal
+ * @param keysOnly if set, then a terse string that prints only the keys is returned, otherwise both keys and values
+ * are printed
+ * @return the string
+ */
+ public String asString(final boolean diffsOnly, final boolean keysOnly) {
+ StringBuilder builder = new StringBuilder();
+
+ if (leftOnly.isEmpty()) {
+ if (!diffsOnly) {
+ builder.append("*** all left keys in right\n");
+ }
+ } else {
+ builder.append(getInOneSideOnlyAsString(leftOnly, "left", keysOnly));
+ }
+
+ if (leftOnly.isEmpty()) {
+ if (!diffsOnly) {
+ builder.append("*** all right keys in left\n");
+ }
+ } else {
+ builder.append(getInOneSideOnlyAsString(rightOnly, "right", keysOnly));
+ }
+
+ if (differentValues.isEmpty()) {
+ if (!diffsOnly) {
+ builder.append("*** all values in left and right are identical\n");
+ }
+ } else {
+ builder.append(getDifferencesAsString(keysOnly));
+ }
+
+ if (!diffsOnly) {
+ builder.append(getIdenticalsAsString(keysOnly));
+ }
+
+ return builder.toString();
+ }
+
+ /**
+ * Output the entries in a map with entries that are in one side only as a string.
+ *
+ * @param sideMap the map for the side being checked
+ * @param sideMapString the string that represents the map in output strings
+ * @param keysOnly if true, just add key information and not entries
+ * @return the entries as a string
+ */
+ private Object getInOneSideOnlyAsString(final Map<K, V> sideMap, final String sideMapString,
+ final boolean keysOnly) {
+ StringBuilder builder = new StringBuilder();
+
+ builder.append("*** list of keys on " + sideMapString + " only\n");
+ for (Entry<K, V> leftEntry : sideMap.entrySet()) {
+ builder.append(KEY);
+ builder.append(leftEntry.getKey());
+ if (!keysOnly) {
+ builder.append(VALUE);
+ builder.append(leftEntry.getValue());
+ }
+ builder.append('\n');
+ }
+
+ return builder.toString();
+ }
+
+ /**
+ * Output the differences between two the maps as a string.
+ *
+ * @param keysOnly if true, just add key information and not entries
+ * @return the differences as a string
+ */
+ private String getDifferencesAsString(final boolean keysOnly) {
+ StringBuilder builder = new StringBuilder();
+
+ builder.append("*** list of differing entries between left and right\n");
+ for (Entry<K, List<V>> differentEntry : differentValues.entrySet()) {
+ builder.append(KEY);
+ builder.append(differentEntry.getKey());
+ if (!keysOnly) {
+ builder.append(",values={");
+ boolean first = true;
+ for (V differentEntryValue : differentEntry.getValue()) {
+ builder.append(differentEntryValue);
+ if (first) {
+ first = false;
+ } else {
+ builder.append(',');
+ }
+ }
+ builder.append("}");
+ }
+ builder.append('\n');
+ }
+
+ return builder.toString();
+ }
+
+ /**
+ * Output the identical entries in the maps as a string.
+ *
+ * @param keysOnly if true, just add key information and not entries
+ * @return the identical entries as a string
+ */
+ private String getIdenticalsAsString(final boolean keysOnly) {
+ StringBuilder builder = new StringBuilder();
+
+ builder.append("*** list of identical entries in left and right\n");
+ for (Entry<K, V> identicalEntry : identicalValues.entrySet()) {
+ builder.append(KEY);
+ builder.append(identicalEntry.getKey());
+ if (!keysOnly) {
+ builder.append(VALUE);
+ builder.append(identicalEntry.getValue());
+ }
+ builder.append('\n');
+ }
+
+ return builder.toString();
+ }
}
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/json/JSONHandler.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/json/JsonHandler.java
index eb42a4efa..9ec5f590e 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/json/JSONHandler.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/json/JsonHandler.java
@@ -20,20 +20,20 @@
package org.onap.policy.apex.model.utilities.json;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
/**
* This class reads objects of the given class from an input stream.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
- * @param <TYPE> the generic type
+ * @param <P> the generic type
*/
-public class JSONHandler<TYPE> {
+public class JsonHandler<P> {
/**
* This method reads objects of a given class from an input stream.
@@ -42,7 +42,7 @@ public class JSONHandler<TYPE> {
* @param inputStream the input stream to read from
* @return the object read
*/
- public TYPE read(final Class<TYPE> inputClass, final InputStream inputStream) {
+ public P read(final Class<P> inputClass, final InputStream inputStream) {
// Register the adapters for our carrier technologies and event protocols with GSON
final GsonBuilder gsonBuilder = new GsonBuilder();
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/typeutils/ClassBuilder.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/typeutils/ClassBuilder.java
index e806bd7a0..ffebc405f 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/typeutils/ClassBuilder.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/typeutils/ClassBuilder.java
@@ -29,9 +29,9 @@ import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
//CHECKSTYLE:ON: checkstyle:IllegalImport
/**
- * This class is a utility class that builds a class with a set of user defined fields. It is used to get the Type of fields in Java schemas<br>
- * For more information see:<br>
- * <a href="http://stackoverflow.com/questions/39401083/class-forname-equivalent-for-creating-parameterizedtypes-from-string">
+ * This class is a utility class that builds a class with a set of user defined fields. It is used to get the Type of
+ * fields in Java schemas<br> For more information see:<br> <a
+ * href="http://stackoverflow.com/questions/39401083/class-forname-equivalent-for-creating-parameterizedtypes-from-string">
* http://stackoverflow.com/questions/39401083/class-forname-equivalent-for-creating-parameterizedtypes-from-string</a><br>
* <a href="https://github.com/KetothXupack/stackoverflow-answers/tree/master/q39401083">
* https://github.com/KetothXupack/stackoverflow-answers/tree/master/q39401083</a><br>
@@ -59,13 +59,12 @@ public class ClassBuilder {
public static ClassBuilder parse(final String className) {
try {
return new ClassBuilder(Class.forName(className));
- }
- catch (ClassNotFoundException e) {
+ } catch (ClassNotFoundException e) {
try {
return new ClassBuilder(Class.forName("java.lang." + className));
- }
- catch (Exception ignore) {
- throw new IllegalArgumentException("Class '" + className + "' not found. Also looked for a class called 'java.lang." + className + "'", e);
+ } catch (Exception ignore) {
+ throw new IllegalArgumentException("Class '" + className
+ + "' not found. Also looked for a class called 'java.lang." + className + "'", e);
}
}
}
@@ -89,11 +88,11 @@ public class ClassBuilder {
if (parameters.isEmpty()) {
return clazz;
}
- Type[] paramtypes = new Type[parameters.size()];
- int i = 0;
+ Type[] paramTypes = new Type[parameters.size()];
+ int paramTypeIndex = 0;
for (ClassBuilder classBuilder : parameters) {
- paramtypes[i++] = classBuilder.build();
+ paramTypes[paramTypeIndex++] = classBuilder.build();
}
- return ParameterizedTypeImpl.make(clazz, paramtypes, null);
+ return ParameterizedTypeImpl.make(clazz, paramTypes, null);
}
}
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/typeutils/TypeBuilder.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/typeutils/TypeBuilder.java
index 0e3851519..ecda86f59 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/typeutils/TypeBuilder.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/typeutils/TypeBuilder.java
@@ -47,7 +47,8 @@ public final class TypeBuilder {
*/
public static Type build(final String type) {
if (type == null || type.length() == 0) {
- throw new IllegalArgumentException("Blank type string passed to " + TypeBuilder.class.getCanonicalName() + ".build(String type)");
+ throw new IllegalArgumentException("Blank type string passed to " + TypeBuilder.class.getCanonicalName()
+ + ".build(String type)");
}
try {
@@ -59,8 +60,7 @@ public final class TypeBuilder {
parser.setErrorHandler(new BailErrorStrategy());
parser.setBuildParseTree(true);
return parser.type().value.build();
- }
- catch (final Exception e) {
+ } catch (final Exception e) {
throw new IllegalArgumentException("Failed to build type '" + type + "': " + e, e);
}
}
@@ -84,16 +84,16 @@ public final class TypeBuilder {
public static Class<?> getJavaTypeClass(final Type type) {
if (type instanceof Class<?>) {
return (Class<?>) type;
- }
- else if (type instanceof ParameterizedType) {
+ } else if (type instanceof ParameterizedType) {
final Type raw = ((ParameterizedType) type).getRawType();
if (!(raw instanceof Class<?>)) {
- throw new IllegalArgumentException(
- "The Parameterised javatype " + type + " with base type " + raw + " is not a Java 'Class' that can be instantiated");
+ throw new IllegalArgumentException("The Parameterised javatype " + type + " with base type " + raw
+ + " is not a Java 'Class' that can be instantiated");
}
return (Class<?>) raw;
}
- throw new IllegalArgumentException("The Parameterised javatype " + type + " is not a Java 'Type' that has a 'Class'");
+ throw new IllegalArgumentException(
+ "The Parameterised javatype " + type + " is not a Java 'Type' that has a 'Class'");
}
/**
@@ -105,10 +105,10 @@ public final class TypeBuilder {
public static Type[] getJavaTypeParameters(final Type type) {
if (type instanceof Class<?>) {
return new Type[0];
- }
- else if (type instanceof ParameterizedType) {
+ } else if (type instanceof ParameterizedType) {
return ((ParameterizedType) type).getActualTypeArguments();
}
- throw new IllegalArgumentException("\"The Parameterised javatype \" + type + \" is not a Java 'Type' that has parameter types");
+ throw new IllegalArgumentException(
+ "\"The Parameterised javatype \" + type + \" is not a Java 'Type' that has parameter types");
}
}
diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/AssertionsTest.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/AssertionsTest.java
index db25147c3..d1040b64b 100644
--- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/AssertionsTest.java
+++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/AssertionsTest.java
@@ -34,66 +34,60 @@ public class AssertionsTest {
@Test
public void testAssertions() {
Assertions.argumentNotFalse(true, "it is true");
-
+
try {
Assertions.argumentNotFalse(false, "it is false");
- }
- catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
assertEquals("it is false", e.getMessage());
}
-
- Assertions.argumentNotFalse(true, ArithmeticException.class, "it is true");
-
+
+ Assertions.argumentOfClassNotFalse(true, ArithmeticException.class, "it is true");
+
try {
- Assertions.argumentNotFalse(false, ArithmeticException.class, "it is false");
- }
- catch (Exception e) {
+ Assertions.argumentOfClassNotFalse(false, ArithmeticException.class, "it is false");
+ } catch (Exception e) {
assertEquals("it is false", e.getMessage());
}
-
+
Assertions.argumentNotNull("Hello", "it is OK");
-
+
try {
Assertions.argumentNotNull(null, "it is null");
- }
- catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
assertEquals("it is null", e.getMessage());
}
- Assertions.argumentNotNull(true, ArithmeticException.class, "it is OK");
-
+ Assertions.argumentOfClassNotNull(true, ArithmeticException.class, "it is OK");
+
try {
- Assertions.argumentNotNull(null, ArithmeticException.class, "it is null");
- }
- catch (Exception e) {
+ Assertions.argumentOfClassNotNull(null, ArithmeticException.class, "it is null");
+ } catch (Exception e) {
assertEquals("it is null", e.getMessage());
}
-
+
Assertions.assignableFrom(java.util.TreeMap.class, java.util.Map.class);
-
+
try {
Assertions.assignableFrom(java.util.Map.class, java.util.TreeMap.class);
- }
- catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
assertEquals("java.util.Map is not an instance of java.util.TreeMap", e.getMessage());
}
-
+
Assertions.instanceOf("Hello", String.class);
-
+
try {
Assertions.instanceOf(100, String.class);
- }
- catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
assertEquals("java.lang.Integer is not an instance of java.lang.String", e.getMessage());
}
-
+
Assertions.validateStringParameter("name", "MyName", "^M.*e$");
try {
Assertions.validateStringParameter("name", "MyName", "^M.*f$");
- }
- catch (IllegalArgumentException e) {
- assertEquals("parameter \"name\": value \"MyName\", does not match regular expression \"^M.*f$\"", e.getMessage());
+ } catch (IllegalArgumentException e) {
+ assertEquals("parameter \"name\": value \"MyName\", does not match regular expression \"^M.*f$\"",
+ e.getMessage());
}
}
}
diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/CollectionUtilitiesTest.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/CollectionUtilitiesTest.java
index e9ddc11bc..22c630bbf 100644
--- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/CollectionUtilitiesTest.java
+++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/CollectionUtilitiesTest.java
@@ -20,7 +20,7 @@
package org.onap.policy.apex.model.utilities;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
@@ -33,17 +33,17 @@ public class CollectionUtilitiesTest {
@Test
public void testNullLists() {
int result = 0;
-
+
result = CollectionUtils.compareLists(null, null);
assertEquals(0, result);
- List<String> leftList = new ArrayList<String>();
+ List<String> leftList = new ArrayList<String>();
result = CollectionUtils.compareLists(leftList, null);
assertEquals(-1, result);
List<String> rightList = new ArrayList<String>();
-
+
result = CollectionUtils.compareLists(null, rightList);
assertEquals(1, result);
@@ -70,7 +70,7 @@ public class CollectionUtilitiesTest {
rightList.add("CCB");
result = CollectionUtils.compareLists(leftList, rightList);
assertEquals(-1, result);
-
+
leftList.remove(leftList.size() - 1);
rightList.remove(rightList.size() - 1);
result = CollectionUtils.compareLists(leftList, rightList);
@@ -80,7 +80,7 @@ public class CollectionUtilitiesTest {
rightList.add("CCA");
result = CollectionUtils.compareLists(leftList, rightList);
assertEquals(1, result);
-
+
leftList.remove(leftList.size() - 1);
rightList.remove(rightList.size() - 1);
result = CollectionUtils.compareLists(leftList, rightList);
diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/TextFileUtilsTest.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/TextFileUtilsTest.java
index c84ee8618..d03dc7135 100644
--- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/TextFileUtilsTest.java
+++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/TextFileUtilsTest.java
@@ -29,6 +29,7 @@ import java.io.IOException;
import org.junit.Test;
/**
+ * Test text file utilities.
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TextFileUtilsTest {
diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/TreeMapUtilsTest.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/TreeMapUtilsTest.java
index 10a31e3b9..791a4dcf9 100644
--- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/TreeMapUtilsTest.java
+++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/TreeMapUtilsTest.java
@@ -30,6 +30,7 @@ import org.junit.Test;
import org.onap.policy.apex.model.utilities.TreeMapUtils;
/**
+ * Test the tree map utilities.
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TreeMapUtilsTest {
diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/json/JsonHandlerTest.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/json/JsonHandlerTest.java
index c9db6c395..5242a4a04 100644
--- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/json/JsonHandlerTest.java
+++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/json/JsonHandlerTest.java
@@ -43,7 +43,7 @@ public class JsonHandlerTest {
final byte[] bytes = jsonString.getBytes(StandardCharsets.UTF_8);
try (final InputStream inputStream = new ByteArrayInputStream(bytes);) {
- final JSONHandler<OverTheMoonObject> objUnderTest = new JSONHandler<>();
+ final JsonHandler<OverTheMoonObject> objUnderTest = new JsonHandler<>();
final OverTheMoonObject actualObject = objUnderTest.read(OverTheMoonObject.class, inputStream);
assertEquals(VALUE, actualObject.name);
diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/ParserTest.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/ParserTest.java
index a979afddc..892f68ce1 100644
--- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/ParserTest.java
+++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/ParserTest.java
@@ -32,14 +32,14 @@ import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.TokenStream;
import org.junit.Test;
-
/**
+ * Test Java parsing.
*/
public class ParserTest {
@Test
public void testParser() {
- final CharStream stream = CharStreams.fromString(
- "java.util.Map<java.util.List<java.lang.Integer>,java.util.Set<java.lang.String>>");
+ final CharStream stream = CharStreams
+ .fromString("java.util.Map<java.util.List<java.lang.Integer>,java.util.Set<java.lang.String>>");
final TokenStream tokenStream = new CommonTokenStream(new ParametrizedTypeLexer(stream));
final ParametrizedTypeParser parser = new ParametrizedTypeParser(tokenStream);
@@ -47,23 +47,23 @@ public class ParserTest {
parser.setErrorHandler(new BailErrorStrategy());
parser.setBuildParseTree(true);
assertEquals("java.util.Map<java.util.List<java.lang.Integer>, java.util.Set<java.lang.String>>",
- parser.type().value.build().getTypeName());
+ parser.type().value.build().getTypeName());
}
@Test
public void testBuilder() throws IllegalArgumentException {
- String t = "java.util.Map<java.util.List<java.lang.Integer>,java.util.Set<java.lang.String>>";
- Type ret = TypeBuilder.build(t);
+ String typeString = "java.util.Map<java.util.List<java.lang.Integer>,java.util.Set<java.lang.String>>";
+ Type ret = TypeBuilder.build(typeString);
assertEquals("java.util.Map<java.util.List<java.lang.Integer>, java.util.Set<java.lang.String>>",
- ret.getTypeName());
+ ret.getTypeName());
assertEquals(java.util.Map.class, TypeBuilder.getJavaTypeClass(ret));
final Type[] args = TypeBuilder.getJavaTypeParameters(ret);
assertEquals("java.util.List<java.lang.Integer>", args[0].getTypeName());
assertEquals("java.util.Set<java.lang.String>", args[1].getTypeName());
- t = "java.lang.Integer";
- ret = TypeBuilder.build(t);
+ typeString = "java.lang.Integer";
+ ret = TypeBuilder.build(typeString);
assertEquals(java.lang.Integer.class, TypeBuilder.getJavaTypeClass(ret));
}
@@ -74,17 +74,19 @@ public class ParserTest {
TypeBuilder.build(null);
fail("Test should throw exception");
} catch (final IllegalArgumentException e) {
- assertEquals(
- "Blank type string passed to org.onap.policy.apex.model.utilities.typeutils.TypeBuilder.build(String type)",
- e.getMessage());
+ assertEquals("Blank type string passed to "
+ + "org.onap.policy.apex.model.utilities.typeutils.TypeBuilder.build(String type)",
+ e.getMessage());
}
try {
TypeBuilder.build("org.zooby.Wooby");
fail("Test should throw exception");
} catch (final IllegalArgumentException e) {
- assertEquals(e.getMessage(), "Failed to build type 'org.zooby.Wooby': java.lang.IllegalArgumentException: "
- + "Class 'org.zooby.Wooby' not found. Also looked for a class called 'java.lang.org.zooby.Wooby'");
+ assertEquals(e.getMessage(),
+ "Failed to build type 'org.zooby.Wooby': java.lang.IllegalArgumentException: "
+ + "Class 'org.zooby.Wooby' not found. "
+ + "Also looked for a class called 'java.lang.org.zooby.Wooby'");
}
assertEquals(TypeBuilder.getJavaTypeClass("java.lang.String"), String.class);
diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/TestKeyComparer.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/TestKeyComparer.java
index c2e84c6fb..538028de0 100644
--- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/TestKeyComparer.java
+++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/TestKeyComparer.java
@@ -28,6 +28,7 @@ import org.onap.policy.apex.model.utilities.comparison.KeyComparer;
import org.onap.policy.apex.model.utilities.comparison.KeyDifference;
/**
+ * Test key comparisons.
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestKeyComparer {
diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/TestKeyedMapComparer.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/TestKeyedMapComparer.java
index 33b8101a1..de71ea164 100644
--- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/TestKeyedMapComparer.java
+++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/typeutils/TestKeyedMapComparer.java
@@ -31,6 +31,8 @@ import org.onap.policy.apex.model.utilities.comparison.KeyedMapComparer;
import org.onap.policy.apex.model.utilities.comparison.KeyedMapDifference;
/**
+ * Test key map comparisons.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestKeyedMapComparer {
@@ -50,21 +52,23 @@ public class TestKeyedMapComparer {
rightMap.put("E", "EEEEE");
rightMap.put("F", "FFFFF");
rightMap.put("G", "G");
-
- KeyedMapDifference<String, String> kmComparedSame = new KeyedMapComparer<String, String>().compareMaps(leftMap, leftMap);
- KeyedMapDifference<String, String> kmComparedDiff = new KeyedMapComparer<String, String>().compareMaps(leftMap, rightMap);
-
+
+ KeyedMapDifference<String, String> kmComparedSame = new KeyedMapComparer<String, String>().compareMaps(leftMap,
+ leftMap);
+ KeyedMapDifference<String, String> kmComparedDiff = new KeyedMapComparer<String, String>().compareMaps(leftMap,
+ rightMap);
+
assertTrue(kmComparedSame.getIdenticalValues().equals(leftMap));
assertEquals(1, kmComparedDiff.getLeftOnly().size());
assertEquals(3, kmComparedDiff.getRightOnly().size());
assertEquals(2, kmComparedDiff.getDifferentValues().size());
assertEquals(1, kmComparedDiff.getIdenticalValues().size());
-
+
assertNotNull(kmComparedSame.asString(true, true));
assertNotNull(kmComparedSame.asString(true, false));
assertNotNull(kmComparedSame.asString(false, false));
assertNotNull(kmComparedSame.asString(false, true));
-
+
assertNotNull(kmComparedDiff.asString(true, true));
assertNotNull(kmComparedDiff.asString(true, false));
assertNotNull(kmComparedDiff.asString(false, false));