summaryrefslogtreecommitdiffstats
path: root/common-parameters
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2018-08-29 11:54:54 +0000
committerGerrit Code Review <gerrit@onap.org>2018-08-29 11:54:54 +0000
commit5443573fe9f8a183f968aa63d08dc3543e73c305 (patch)
tree9101a6a8f3f44d1c8cadadbd7410b4d16c941940 /common-parameters
parent8ae625423fbf11fa031946caa3f86d552854b893 (diff)
parent655d6f798878cd69b6c02c54d4bbed83d01fd937 (diff)
Merge "Improvements to Parameter Srvice"
Diffstat (limited to 'common-parameters')
-rw-r--r--common-parameters/src/main/java/org/onap/policy/common/parameters/GroupMapValidationResult.java23
-rw-r--r--common-parameters/src/main/java/org/onap/policy/common/parameters/GroupValidationResult.java84
-rw-r--r--common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterException.java2
-rw-r--r--common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterGroup.java7
-rw-r--r--common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterService.java28
-rw-r--r--common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResult.java9
-rw-r--r--common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationStatus.java8
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/TestParameterService.java25
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidation.java2
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationErrors.java10
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResults.java38
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/EmptyParameterGroup.java5
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithArray.java9
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithCollection.java5
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapKey.java5
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapValue.java5
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullCollection.java9
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullMapValue.java9
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullSubGroup.java56
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithParameterGroupCollection.java5
20 files changed, 300 insertions, 44 deletions
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupMapValidationResult.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupMapValidationResult.java
index e607ff98..3baacb1f 100644
--- a/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupMapValidationResult.java
+++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupMapValidationResult.java
@@ -89,7 +89,7 @@ public class GroupMapValidationResult implements ValidationResult {
* @param message The validation message explaining the validation status
*/
@Override
- public void setResult(ValidationStatus status, String message) {
+ public void setResult(final ValidationStatus status, final String message) {
setResult(status);
this.message = message;
}
@@ -112,9 +112,28 @@ public class GroupMapValidationResult implements ValidationResult {
* Set the validation result on a parameter map entry.
*
* @param entryName The name of the parameter map entry
+ * @param status The validation status for the entry
+ * @param message The validation message for the entry
+ */
+ public void setResult(final String entryName, final ValidationStatus status, final String message) {
+ ValidationResult validationResult = validationResultMap.get(entryName);
+ if (validationResult == null) {
+ throw new ParameterRuntimeException("no entry with name \"" + entryName + "\" exists");
+ }
+
+ // Set the status of the parameter group and replace the field result
+ validationResult.setResult(status, message);
+ this.setResult(status);
+ }
+
+
+ /**
+ * Set the validation result on a parameter map entry.
+ *
+ * @param entryName The name of the parameter map entry
* @param mapEntryValidationResult The validation result for the entry
*/
- public void setResult(String entryName, ValidationResult mapEntryValidationResult) {
+ public void setResult(final String entryName, final ValidationResult mapEntryValidationResult) {
ValidationResult validationResult = validationResultMap.get(entryName);
if (validationResult == null) {
throw new ParameterRuntimeException("no entry with name \"" + entryName + "\" exists");
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupValidationResult.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupValidationResult.java
index ac9dc7ba..fc2f6ca5 100644
--- a/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupValidationResult.java
+++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupValidationResult.java
@@ -48,6 +48,11 @@ public class GroupValidationResult implements ValidationResult {
public GroupValidationResult(final ParameterGroup parameterGroup) {
this.parameterGroup = parameterGroup;
+ // Parameter group definitions may be optional
+ if (parameterGroup == null) {
+ return;
+ }
+
// Add a validation result per field
for (Field field : parameterGroup.getClass().getDeclaredFields()) {
// Exclude system fields
@@ -86,15 +91,15 @@ public class GroupValidationResult implements ValidationResult {
// Nested parameter groups are allowed
if (ParameterGroup.class.isAssignableFrom(fieldType)) {
- return new GroupValidationResult((ParameterGroup) field.get(parameterGroup));
+ return new GroupValidationResult((ParameterGroup) fieldObject);
}
-
+
// Nested maps of parameter groups are allowed
if (Map.class.isAssignableFrom(field.getType())) {
checkMapIsParameterGroupMap(fieldName, fieldObject);
return new GroupMapValidationResult(field, fieldObject);
}
-
+
// Collections of parameter groups are not allowed
if (Collection.class.isAssignableFrom(field.getType())) {
checkCollection4ParameterGroups(fieldName, fieldObject);
@@ -115,7 +120,7 @@ public class GroupValidationResult implements ValidationResult {
if (mapObject == null) {
throw new ParameterRuntimeException("map parameter \"" + fieldName + "\" is null");
}
-
+
Map<?, ?> incomingMap = (Map<?, ?>) mapObject;
for (Entry<?, ?> mapEntry : incomingMap.entrySet()) {
@@ -184,7 +189,7 @@ public class GroupValidationResult implements ValidationResult {
}
/**
- * Set the validation result on on a parameter group.
+ * Set the validation result on a parameter group.
*
* @param status The validation status the parameter group is receiving
* @param message The validation message explaining the validation status
@@ -196,9 +201,8 @@ public class GroupValidationResult implements ValidationResult {
}
/**
- * Set the validation result on on a parameter group.
- * On a sequence of calls, the most serious validation status is recorded, assuming the status enum ordinal increase
- * in order of severity
+ * Set the validation result on a parameter group. On a sequence of calls, the most serious validation status is
+ * recorded, assuming the status enum ordinal increase in order of severity
*
* @param status The validation status the parameter group is receiving
*/
@@ -211,27 +215,23 @@ public class GroupValidationResult implements ValidationResult {
}
/**
- * Set the validation result on a parameter group.
+ * Set the validation result on a parameter in a parameter group.
*
- * @param parameterGroupName The name of the parameter group
+ * @param parameterName The name of the parameter
* @param status The validation status the field is receiving
* @param message The validation message explaining the validation status
*/
- public void setResult(final String parameterGroupName, final ValidationStatus status, final String message) {
- ParameterValidationResult parameterValidationResult;
- try {
- parameterValidationResult = (ParameterValidationResult) validationResultMap.get(parameterGroupName);
- } catch (ClassCastException e) {
- throw new ParameterRuntimeException("parameter not a regular parameter: " + parameterGroupName, e);
- }
+ public void setResult(final String parameterName, final ValidationStatus status, final String message) {
+ ValidationResult validationResult = validationResultMap.get(parameterName);
- if (parameterValidationResult == null) {
- throw new ParameterRuntimeException(
- "no regular parameter field exists for parameter: " + parameterGroupName);
+ if (validationResult == null) {
+ throw new ParameterRuntimeException("no parameter field exists for parameter: " + parameterName);
}
- // Set the status of the parameter group and the field
- parameterValidationResult.setResult(status, message);
+ // Set the status and the message on the result irrespective of validation result type
+ validationResult.setResult(status, message);
+
+ // Set the status of this result
this.setResult(status);
}
@@ -241,7 +241,7 @@ public class GroupValidationResult implements ValidationResult {
* @param parameterName The name of the parameter field
* @param nestedValidationResult The validation result from a nested field
*/
- public void setResult(String parameterName, ValidationResult nestedValidationResult) {
+ public void setResult(final String parameterName, final ValidationResult nestedValidationResult) {
GroupValidationResult groupValidationResult;
try {
groupValidationResult = (GroupValidationResult) validationResultMap.get(parameterName);
@@ -284,6 +284,32 @@ public class GroupValidationResult implements ValidationResult {
}
/**
+ * Set the validation status on a group map entry.
+ *
+ * @param parameterName The name of the parameter field
+ * @param key The key of the map entry
+ * @param status The validation status of the entry
+ * @param message The message for the parameter group
+ */
+ public void setResult(final String parameterName, final String key, final ValidationStatus status,
+ final String message) {
+ GroupMapValidationResult groupMapValidationResult;
+ try {
+ groupMapValidationResult = (GroupMapValidationResult) validationResultMap.get(parameterName);
+ } catch (ClassCastException e) {
+ throw new ParameterRuntimeException("parameter is not a nested group map parameter: " + parameterName, e);
+ }
+
+ if (groupMapValidationResult == null) {
+ throw new ParameterRuntimeException("no group map parameter field exists for parameter: " + parameterName);
+ }
+
+ // Set the status of the parameter group and the field
+ groupMapValidationResult.setResult(key, status, message);
+ this.setResult(status);
+ }
+
+ /**
* Gets the validation result.
*
* @param initialIndentation the indentation to use on the main result output
@@ -301,9 +327,15 @@ public class GroupValidationResult implements ValidationResult {
validationResultBuilder.append(initialIndentation);
validationResultBuilder.append("parameter group \"");
- validationResultBuilder.append(parameterGroup.getName());
- validationResultBuilder.append("\" type \"");
- validationResultBuilder.append(parameterGroup.getClass().getCanonicalName());
+
+ if (parameterGroup != null) {
+ validationResultBuilder.append(parameterGroup.getName());
+ validationResultBuilder.append("\" type \"");
+ validationResultBuilder.append(parameterGroup.getClass().getCanonicalName());
+ }
+ else {
+ validationResultBuilder.append("UNDEFINED");
+ }
validationResultBuilder.append("\" ");
validationResultBuilder.append(status);
validationResultBuilder.append(", ");
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterException.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterException.java
index 3a6e17e8..0b29a4e6 100644
--- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterException.java
+++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterException.java
@@ -88,7 +88,7 @@ public class ParameterException extends Exception {
* @param throwable the top level exception
* @return cascaded message string
*/
- public static String buildCascadedMessage(Throwable throwable) {
+ public static String buildCascadedMessage(final Throwable throwable) {
final StringBuilder builder = new StringBuilder();
builder.append(throwable.getMessage());
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterGroup.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterGroup.java
index 48e8379f..8bfa183b 100644
--- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterGroup.java
+++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterGroup.java
@@ -35,6 +35,13 @@ public interface ParameterGroup {
public String getName();
/**
+ * Set the group name.
+ *
+ * @param name the group name
+ */
+ public void setName(final String name);
+
+ /**
* Validate parameters.
*
* @return the result of the parameter validation
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterService.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterService.java
index db6995c5..358e5535 100644
--- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterService.java
+++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterService.java
@@ -61,6 +61,20 @@ public abstract class ParameterService {
}
/**
+ * Register a parameter group with the parameter service.
+ *
+ * @param parameterGroup the parameter group
+ * @param overwrite if true, overwrite the current value if set
+ */
+ public static void register(final ParameterGroup parameterGroup, final boolean overwrite) {
+ if (overwrite && parameterGroupMap.containsKey(parameterGroup.getName())) {
+ deregister(parameterGroup);
+ }
+
+ register(parameterGroup);
+ }
+
+ /**
* Remove a parameter group from the parameter service.
*
* @param parameterGroupName the name of the parameter group
@@ -74,13 +88,23 @@ public abstract class ParameterService {
}
/**
+ * Remove a parameter group from the parameter service.
+ *
+ * @param parameterGroup the parameter group
+ */
+ public static void deregister(final ParameterGroup parameterGroup) {
+ deregister(parameterGroup.getName());
+ }
+
+ /**
* Get a parameter group from the parameter service.
*
* @param parameterGroupName the name of the parameter group
* @return The parameter group
*/
- public static ParameterGroup get(final String parameterGroupName) {
- final ParameterGroup parameterGroup = parameterGroupMap.get(parameterGroupName);
+ public static <T extends ParameterGroup> T get(final String parameterGroupName) {
+ @SuppressWarnings("unchecked")
+ final T parameterGroup = (T) parameterGroupMap.get(parameterGroupName);
if (parameterGroup == null) {
throw new ParameterRuntimeException("\"" + parameterGroupName + "\" not found in parameter service");
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResult.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResult.java
index b97ccda0..309fd001 100644
--- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResult.java
+++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResult.java
@@ -48,6 +48,15 @@ public interface ValidationResult {
}
/**
+ * Checks if the result is clean.
+ *
+ * @return true, if is clean
+ */
+ default boolean isClean() {
+ return getStatus().isClean();
+ }
+
+ /**
* Gets the validation result.
*
* @return the full validation result
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationStatus.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationStatus.java
index ff453a1b..8692506f 100644
--- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationStatus.java
+++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationStatus.java
@@ -33,4 +33,12 @@ public enum ValidationStatus {
public boolean isValid() {
return !this.equals(INVALID);
}
+
+ /**
+ * Check if the validation was clean.
+ * @return true if the validation is clean
+ */
+ public boolean isClean() {
+ return this.equals(CLEAN);
+ }
}
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestParameterService.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestParameterService.java
index 0b7e46ca..2dad4283 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestParameterService.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestParameterService.java
@@ -57,9 +57,34 @@ public class TestParameterService {
assertEquals("\"Empty Group\" already registered in parameter service", e.getMessage());
}
+ try {
+ ParameterService.register(new EmptyParameterGroup("Empty Group"), false);
+ fail("this test should throw an exception");
+ }
+ catch (ParameterRuntimeException e) {
+ assertEquals("\"Empty Group\" already registered in parameter service", e.getMessage());
+ }
+
+ ParameterService.register(new EmptyParameterGroup("Empty Group"), true);
+ assertTrue(ParameterService.contains("Empty Group"));
+
ParameterService.deregister("Empty Group");
assertFalse(ParameterService.contains("Empty Group"));
+ ParameterService.register(new EmptyParameterGroup("Empty Group"), true);
+ assertTrue(ParameterService.contains("Empty Group"));
+
+ ParameterService.deregister("Empty Group");
+ assertFalse(ParameterService.contains("Empty Group"));
+
+ EmptyParameterGroup epg = new EmptyParameterGroup("Empty Group");
+ ParameterService.register(epg);
+ assertTrue(ParameterService.contains("Empty Group"));
+ assertNotNull(ParameterService.get("Empty Group"));
+
+ ParameterService.deregister(epg);
+ assertFalse(ParameterService.contains("Empty Group"));
+
try {
ParameterService.deregister("Empty Group");
fail("this test should throw an exception");
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidation.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidation.java
index 2ca24a05..fe750b2c 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidation.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidation.java
@@ -39,6 +39,7 @@ public class TestValidation {
GroupValidationResult validationResult = l0Parameters.validate();
assertTrue(validationResult.isValid());
+ assertTrue(validationResult.isClean());
assertNull(validationResult.getResult());
assertEquals(l0Parameters, validationResult.getParameterGroup());
assertEquals(l0Parameters.getName(), validationResult.getName());
@@ -61,6 +62,7 @@ public class TestValidation {
GroupValidationResult validationResult = l0Parameters.validate();
assertTrue(validationResult.isValid());
+ assertFalse(validationResult.isClean());
assertEquals(expectedResult, validationResult.getResult().replaceAll("\\s+", ""));
l0Parameters.triggerValidationStatus(ValidationStatus.CLEAN, 3);
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationErrors.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationErrors.java
index 6b781472..a489cc3f 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationErrors.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationErrors.java
@@ -21,6 +21,7 @@
package org.onap.policy.common.parameters;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -31,6 +32,7 @@ import org.onap.policy.common.parameters.testclasses.ParameterGroupWithIllegalMa
import org.onap.policy.common.parameters.testclasses.ParameterGroupWithIllegalMapValue;
import org.onap.policy.common.parameters.testclasses.ParameterGroupWithNullCollection;
import org.onap.policy.common.parameters.testclasses.ParameterGroupWithNullMapValue;
+import org.onap.policy.common.parameters.testclasses.ParameterGroupWithNullSubGroup;
import org.onap.policy.common.parameters.testclasses.ParameterGroupWithParameterGroupCollection;
public class TestValidationErrors {
@@ -69,6 +71,14 @@ public class TestValidationErrors {
}
@Test
+ public void testMapNullSubGroupValidation() {
+ ParameterGroupWithNullSubGroup nullSub = new ParameterGroupWithNullSubGroup("Null sub group value");
+
+ nullSub.isValid();
+ assertNull(nullSub.getSubGroup());
+ }
+
+ @Test
public void testMapNullValueValidation() {
ParameterGroupWithNullMapValue nullMap = new ParameterGroupWithNullMapValue("Null Map value");
try {
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResults.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResults.java
index 8f22765b..f7451051 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResults.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResults.java
@@ -103,15 +103,11 @@ public class TestValidationResults {
result.setResult("nonExistantParameter", ValidationStatus.OBSERVATION, "Something was observed");
fail("test shold throw an exception here");
} catch (Exception e) {
- assertEquals("no regular parameter field exists for parameter: nonExistantParameter", e.getMessage());
+ assertEquals("no parameter field exists for parameter: nonExistantParameter", e.getMessage());
}
- try {
- result.setResult("l10LGenericNestedMap", ValidationStatus.OBSERVATION, "Something was observed");
- fail("test shold throw an exception here");
- } catch (Exception e) {
- assertEquals("parameter not a regular parameter: l10LGenericNestedMap", e.getMessage());
- }
+ result.setResult("l10IntField", ValidationStatus.OBSERVATION, "Something was observed");
+ assertTrue(result.isValid());
try {
result.setResult("nonExistantParameter", new GroupValidationResult(pg));
@@ -143,5 +139,33 @@ public class TestValidationResults {
} catch (Exception e) {
assertEquals("parameter is not a nested group map parameter: l10IntField", e.getMessage());
}
+
+ result.setResult("l10LGenericNestedMap", "l10LGenericNestedMapVal0", ValidationStatus.INVALID,
+ "This value is invalid");
+ assertEquals(ValidationStatus.INVALID, result.getStatus());
+
+ try {
+ result.setResult("l10IntField", "l10LGenericNestedMapVal0", ValidationStatus.INVALID,
+ "This value is invalid");
+ fail("test shold throw an exception here");
+ } catch (Exception e) {
+ assertEquals("parameter is not a nested group map parameter: l10IntField", e.getMessage());
+ }
+
+ try {
+ result.setResult("nonExistantParameter", "l10LGenericNestedMapVal0", ValidationStatus.INVALID,
+ "This value is invalid");
+ fail("test shold throw an exception here");
+ } catch (Exception e) {
+ assertEquals("no group map parameter field exists for parameter: nonExistantParameter", e.getMessage());
+ }
+
+ try {
+ result.setResult("l10LGenericNestedMap", "NonExistantKey", ValidationStatus.INVALID,
+ "This value is invalid");
+ fail("test shold throw an exception here");
+ } catch (Exception e) {
+ assertEquals("no entry with name \"NonExistantKey\" exists", e.getMessage());
+ }
}
}
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/EmptyParameterGroup.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/EmptyParameterGroup.java
index 681eb693..505b2ce4 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/EmptyParameterGroup.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/EmptyParameterGroup.java
@@ -36,6 +36,11 @@ public class EmptyParameterGroup implements ParameterGroup {
}
@Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
public GroupValidationResult validate() {
return new GroupValidationResult(this);
}
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithArray.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithArray.java
index fcb2bb1b..c448cea1 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithArray.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithArray.java
@@ -34,12 +34,17 @@ public class ParameterGroupWithArray implements ParameterGroup {
public int[] getIntArray() {
return intArray;
}
-
+
@Override
public String getName() {
return name;
}
-
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
@Override
public GroupValidationResult validate() {
return new GroupValidationResult(this);
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithCollection.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithCollection.java
index 75ae45b8..7f2c0ab5 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithCollection.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithCollection.java
@@ -53,6 +53,11 @@ public class ParameterGroupWithCollection implements ParameterGroup {
}
@Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
public GroupValidationResult validate() {
return new GroupValidationResult(this);
}
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapKey.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapKey.java
index ca441060..57a5a110 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapKey.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapKey.java
@@ -52,6 +52,11 @@ public class ParameterGroupWithIllegalMapKey implements ParameterGroup {
}
@Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
public GroupValidationResult validate() {
return new GroupValidationResult(this);
}
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapValue.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapValue.java
index 9253f158..39e35d9c 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapValue.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapValue.java
@@ -52,6 +52,11 @@ public class ParameterGroupWithIllegalMapValue implements ParameterGroup {
}
@Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
public GroupValidationResult validate() {
return new GroupValidationResult(this);
}
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullCollection.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullCollection.java
index 0d113dc6..9b661bd5 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullCollection.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullCollection.java
@@ -40,12 +40,17 @@ public class ParameterGroupWithNullCollection implements ParameterGroup {
public List<Integer> getNullList() {
return nullList;
}
-
+
@Override
public String getName() {
return name;
}
-
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
@Override
public GroupValidationResult validate() {
return new GroupValidationResult(this);
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullMapValue.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullMapValue.java
index 9e1601c3..ac863a42 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullMapValue.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullMapValue.java
@@ -40,12 +40,17 @@ public class ParameterGroupWithNullMapValue implements ParameterGroup {
public Map<String, Integer> getNullMap() {
return nullMap;
}
-
+
@Override
public String getName() {
return name;
}
-
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
@Override
public GroupValidationResult validate() {
return new GroupValidationResult(this);
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullSubGroup.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullSubGroup.java
new file mode 100644
index 00000000..830c8117
--- /dev/null
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullSubGroup.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.common.parameters.testclasses;
+
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
+
+public class ParameterGroupWithNullSubGroup implements ParameterGroup {
+ private String name;
+ private ParameterGroup subGroup = null;
+
+ /**
+ * Create a test parameter group.
+ * @param name the parameter group name
+ */
+ public ParameterGroupWithNullSubGroup(final String name) {
+ this.name = name;
+ }
+
+ public ParameterGroup getSubGroup() {
+ return subGroup;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
+ }
+}
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithParameterGroupCollection.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithParameterGroupCollection.java
index 5ece07b4..dadf7273 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithParameterGroupCollection.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithParameterGroupCollection.java
@@ -52,6 +52,11 @@ public class ParameterGroupWithParameterGroupCollection implements ParameterGrou
}
@Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
public GroupValidationResult validate() {
return new GroupValidationResult(this);
}