From 3b00f1c32b89282dcbb74d3d3645e263f005319e Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Mon, 26 Apr 2021 17:41:25 -0400 Subject: Remove GroupValidationResult Removed GroupValidationResult, replacing it with BeanValidationResult. Modified the ParameterGroup subclasses to use BeanValidator, adding annotations where needed to trigger the validations that had been automatically performed by GroupValidationResult. Added Size annotation, used to verify minimum lengths of maps and collections. Added ClassName annotation, used to verify that a property contains the name of a class that is actually in the classpath. Added another addResult() method to make it easier when replacing calls to GroupValidationResult setResult() method with BeanValidationResult. Issue-ID: POLICY-2059 Change-Id: Id4da24886908723006624c5d53edeb034102299d Signed-off-by: Jim Hahn --- .../common/parameters/BeanValidationResult.java | 17 +- .../policy/common/parameters/BeanValidator.java | 78 ++++- .../parameters/CommonGroupValidationResult.java | 138 -------- .../parameters/GroupMapValidationResult.java | 112 ------ .../common/parameters/GroupValidationResult.java | 390 --------------------- .../common/parameters/ObjectValidationResult.java | 4 +- .../policy/common/parameters/ParameterGroup.java | 17 +- .../common/parameters/ParameterGroupImpl.java | 30 +- .../common/parameters/annotations/ClassName.java | 37 ++ .../policy/common/parameters/annotations/Size.java | 43 +++ .../common/parameters/TestAbstractParameters.java | 35 -- .../parameters/TestBeanValidationResult.java | 7 +- .../common/parameters/TestBeanValidator.java | 105 ++++++ .../policy/common/parameters/TestJsonInput.java | 57 --- .../common/parameters/TestParameterService.java | 93 ----- .../policy/common/parameters/TestValidation.java | 183 +--------- .../common/parameters/TestValidationErrors.java | 117 ------- .../common/parameters/TestValidationResults.java | 143 -------- .../policy/common/parameters/TestYamlInput.java | 54 --- .../testclasses/EmptyParameterGroup.java | 31 -- .../testclasses/ParameterGroupMissingGetter.java | 40 --- .../testclasses/ParameterGroupPrivateGetter.java | 44 --- .../testclasses/ParameterGroupWithArray.java | 36 -- .../testclasses/ParameterGroupWithCollection.java | 47 --- .../ParameterGroupWithIllegalMapKey.java | 47 --- .../ParameterGroupWithIllegalMapValue.java | 46 --- .../ParameterGroupWithNullCollection.java | 41 --- .../ParameterGroupWithNullMapValue.java | 41 --- .../ParameterGroupWithNullSubGroup.java | 41 --- ...ParameterGroupWithParameterGroupCollection.java | 47 --- .../parameters/testclasses/TestParametersL00.java | 208 ----------- .../parameters/testclasses/TestParametersL10.java | 188 ---------- .../testclasses/TestParametersLGeneric.java | 129 ------- .../TestJsonYamlValidationResult.txt | 41 --- .../TestParametersL0_0_OK.txt | 41 --- .../TestParametersL0_1_Invalid.txt | 3 - .../TestParametersL0_1_Observation.txt | 3 - .../TestParametersL0_1_Warning.txt | 3 - .../TestParametersL0_2_Invalid.txt | 16 - .../TestParametersL0_2_Observation.txt | 16 - .../TestParametersL0_2_Warning.txt | 16 - .../TestParametersL0_3_Invalid.txt | 29 -- .../TestParametersL0_3_Observation.txt | 29 -- .../TestParametersL0_3_Warning.txt | 29 -- 44 files changed, 299 insertions(+), 2573 deletions(-) delete mode 100644 common-parameters/src/main/java/org/onap/policy/common/parameters/CommonGroupValidationResult.java delete mode 100644 common-parameters/src/main/java/org/onap/policy/common/parameters/GroupMapValidationResult.java delete mode 100644 common-parameters/src/main/java/org/onap/policy/common/parameters/GroupValidationResult.java create mode 100644 common-parameters/src/main/java/org/onap/policy/common/parameters/annotations/ClassName.java create mode 100644 common-parameters/src/main/java/org/onap/policy/common/parameters/annotations/Size.java delete mode 100644 common-parameters/src/test/java/org/onap/policy/common/parameters/TestAbstractParameters.java delete mode 100644 common-parameters/src/test/java/org/onap/policy/common/parameters/TestJsonInput.java delete mode 100644 common-parameters/src/test/java/org/onap/policy/common/parameters/TestParameterService.java delete mode 100644 common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationErrors.java delete mode 100644 common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResults.java delete mode 100644 common-parameters/src/test/java/org/onap/policy/common/parameters/TestYamlInput.java delete mode 100644 common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/EmptyParameterGroup.java delete mode 100644 common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupMissingGetter.java delete mode 100644 common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupPrivateGetter.java delete mode 100644 common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithArray.java delete mode 100644 common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithCollection.java delete mode 100644 common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapKey.java delete mode 100644 common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapValue.java delete mode 100644 common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullCollection.java delete mode 100644 common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullMapValue.java delete mode 100644 common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullSubGroup.java delete mode 100644 common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithParameterGroupCollection.java delete mode 100644 common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersL00.java delete mode 100644 common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersL10.java delete mode 100644 common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersLGeneric.java delete mode 100644 common-parameters/src/test/resources/expectedValidationResults/TestJsonYamlValidationResult.txt delete mode 100644 common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_0_OK.txt delete mode 100644 common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_1_Invalid.txt delete mode 100644 common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_1_Observation.txt delete mode 100644 common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_1_Warning.txt delete mode 100644 common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Invalid.txt delete mode 100644 common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Observation.txt delete mode 100644 common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Warning.txt delete mode 100644 common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Invalid.txt delete mode 100644 common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Observation.txt delete mode 100644 common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Warning.txt (limited to 'common-parameters') diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/BeanValidationResult.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/BeanValidationResult.java index 752e4d40..fa0c66c0 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/BeanValidationResult.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/BeanValidationResult.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,6 +67,19 @@ public class BeanValidationResult extends ValidationResultImpl { return result.isValid(); } + /** + * Adds a result to this result. + * @param name name of the object of this result + * @param object object being validated + * @param status status of the new result + * @param message new result message + * @return {@code true} if the status is {@code null} or valid, {@code false} if the + * status is invalid + */ + public boolean addResult(String name, Object object, ValidationStatus status, String message) { + return addResult(new ObjectValidationResult(name, object, status, message)); + } + /** * Validates that a sub-object within the bean is not {@code null}. * @@ -116,7 +129,7 @@ public class BeanValidationResult extends ValidationResultImpl { BeanValidationResult result = new BeanValidationResult(listName, null); for (T item : list) { if (item == null) { - result.addResult(new ObjectValidationResult("item", item, ValidationStatus.INVALID, "null")); + result.addResult("item", item, ValidationStatus.INVALID, "null"); } else { result.addResult(itemValidator.apply(item)); } diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/BeanValidator.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/BeanValidator.java index 68455ac3..947def42 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/BeanValidator.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/BeanValidator.java @@ -25,11 +25,13 @@ import java.util.Collection; import java.util.Map; import java.util.Map.Entry; import org.apache.commons.lang3.StringUtils; +import org.onap.policy.common.parameters.annotations.ClassName; import org.onap.policy.common.parameters.annotations.Max; import org.onap.policy.common.parameters.annotations.Min; import org.onap.policy.common.parameters.annotations.NotBlank; import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.common.parameters.annotations.Pattern; +import org.onap.policy.common.parameters.annotations.Size; import org.onap.policy.common.parameters.annotations.Valid; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -74,9 +76,11 @@ public class BeanValidator { protected void addValidators(ValueValidator validator) { validator.addAnnotation(NotNull.class, this::verNotNull); validator.addAnnotation(NotBlank.class, this::verNotBlank); + validator.addAnnotation(Size.class, this::verSize); validator.addAnnotation(Max.class, this::verMax); validator.addAnnotation(Min.class, this::verMin); validator.addAnnotation(Pattern.class, this::verRegex); + validator.addAnnotation(ClassName.class, this::verClassName); validator.addAnnotation(Valid.class, this::verCascade); } @@ -105,9 +109,7 @@ public class BeanValidator { */ public boolean verNotNull(BeanValidationResult result, String fieldName, Object value) { if (value == null) { - ObjectValidationResult result2 = - new ObjectValidationResult(fieldName, xlate(value), ValidationStatus.INVALID, "is null"); - result.addResult(result2); + result.addResult(fieldName, xlate(value), ValidationStatus.INVALID, "is null"); return false; } @@ -125,9 +127,38 @@ public class BeanValidator { */ public boolean verNotBlank(BeanValidationResult result, String fieldName, Object value) { if (value instanceof String && StringUtils.isBlank(value.toString())) { - ObjectValidationResult result2 = - new ObjectValidationResult(fieldName, xlate(value), ValidationStatus.INVALID, "is blank"); - result.addResult(result2); + result.addResult(fieldName, xlate(value), ValidationStatus.INVALID, "is blank"); + return false; + } + + return true; + } + + /** + * Verifies that the value has the specified number of elements. + * + * @param result where to add the validation result + * @param fieldName field whose value is being verified + * @param annot annotation against which the value is being verified + * @param value value to be verified + * @return {@code true} if the next check should be performed, {@code false} otherwise + */ + public boolean verSize(BeanValidationResult result, String fieldName, Size annot, Object value) { + int size; + if (value instanceof Collection) { + size = ((Collection) value).size(); + + } else if (value instanceof Map) { + size = ((Map) value).size(); + + } else { + return true; + } + + + if (size < annot.min()) { + result.addResult(fieldName, xlate(value), ValidationStatus.INVALID, + "minimum number of elements: " + annot.min()); return false; } @@ -153,9 +184,8 @@ public class BeanValidator { logger.warn("validation error for regular expression: {}", annot.regexp(), e); } - ObjectValidationResult result2 = new ObjectValidationResult(fieldName, xlate(value), ValidationStatus.INVALID, + result.addResult(fieldName, xlate(value), ValidationStatus.INVALID, "does not match regular expression " + annot.regexp()); - result.addResult(result2); return false; } @@ -188,9 +218,8 @@ public class BeanValidator { return true; } - ObjectValidationResult result2 = new ObjectValidationResult(fieldName, xlate(value), ValidationStatus.INVALID, + result.addResult(fieldName, xlate(value), ValidationStatus.INVALID, "exceeds the maximum value: " + annot.value()); - result.addResult(result2); return false; } @@ -236,12 +265,34 @@ public class BeanValidator { return true; } - ObjectValidationResult result2 = new ObjectValidationResult(fieldName, xlate(value), ValidationStatus.INVALID, + result.addResult(fieldName, xlate(value), ValidationStatus.INVALID, "is below the minimum value: " + min); - result.addResult(result2); return false; } + /** + * Verifies that the value is a valid class name. + * + * @param result where to add the validation result + * @param fieldName field whose value is being verified + * @param value value to be verified + * @return {@code true} if the next check should be performed, {@code false} otherwise + */ + public boolean verClassName(BeanValidationResult result, String fieldName, Object value) { + if (!(value instanceof String)) { + return true; + } + + try { + Class.forName(value.toString()); + return true; + + } catch (final ClassNotFoundException exp) { + result.addResult(fieldName, value, ValidationStatus.INVALID, "class is not in the classpath"); + return false; + } + } + /** * Verifies that the value is valid by recursively invoking * {@link #validateTop(String, Object)}. @@ -256,7 +307,8 @@ public class BeanValidator { return true; } - BeanValidationResult result2 = validateTop(fieldName, value); + BeanValidationResult result2 = (value instanceof ParameterGroup ? ((ParameterGroup) value).validate() + : validateTop(fieldName, value)); if (result2.isClean()) { return true; diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/CommonGroupValidationResult.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/CommonGroupValidationResult.java deleted file mode 100644 index ba31698a..00000000 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/CommonGroupValidationResult.java +++ /dev/null @@ -1,138 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2020 Bell Canada. 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; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * This class holds the result of the validation of a parameter group. - */ -public abstract class CommonGroupValidationResult implements ValidationResult { - - - private final String messagePrefix; - - /** - * Validation status for the entire class. - */ - protected ValidationStatus status = ValidationStatus.CLEAN; - - /** - * Status message. - */ - protected String message; - - /** - * Validation results for each parameter in the group. - */ - protected final Map validationResultMap = new LinkedHashMap<>(); - - - /** - * Constructs the object. - * - * @param messagePrefix status message prefix - */ - protected CommonGroupValidationResult(String messagePrefix) { - this.messagePrefix = messagePrefix; - this.message = messagePrefix + status.toString(); - } - - /** - * Gets the status of validation. - * - * @return the status - */ - @Override - public ValidationStatus getStatus() { - return status; - } - - /** - * 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 - */ - @Override - public void setResult(ValidationStatus status, String message) { - setResult(status); - this.message = message; - } - - /** - * 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 - */ - public void setResult(final ValidationStatus status) { - if (this.status.ordinal() < status.ordinal()) { - this.status = status; - this.message = messagePrefix + status; - } - } - - /** - * Gets the validation result. - * - * @param initialIndentation the indentation to use on the main result output - * @param subIndentation the indentation to use on sub parts of the result output - * @param showClean output information on clean fields - * @return the result - */ - @Override - public String getResult(final String initialIndentation, final String subIndentation, final boolean showClean) { - if (status == ValidationStatus.CLEAN && !showClean) { - return null; - } - - StringBuilder result = new StringBuilder(); - - result.append(initialIndentation); - - addGroupTypeName(result); - - result.append(status); - result.append(", "); - result.append(message); - result.append('\n'); - - for (ValidationResult fieldResult : validationResultMap.values()) { - String msg = fieldResult.getResult(initialIndentation + subIndentation, subIndentation, showClean); - if (msg != null) { - result.append(msg); - } - } - - return result.toString(); - } - - /** - * Adds the group type and name to the result string. - * - * @param result result string - */ - protected abstract void addGroupTypeName(StringBuilder result); -} 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 deleted file mode 100644 index 2a616dba..00000000 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupMapValidationResult.java +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.common.parameters; - -import java.lang.reflect.Field; -import java.util.Map; -import java.util.Map.Entry; - -/** - * This class holds the result of the validation of a map of parameter groups. - */ -public class GroupMapValidationResult extends CommonGroupValidationResult { - // The name of the parameter group map - final String mapParameterName; - - /** - * Constructor, create the group map validation result. - * - * @param field the map parameter field - * @param mapObject the value of the map parameter field - */ - protected GroupMapValidationResult(final Field field, final Object mapObject) { - super(ParameterConstants.PARAMETER_GROUP_MAP_HAS_STATUS_MESSAGE); - - this.mapParameterName = field.getName(); - - // Cast the map object to a map of parameter groups keyed by string, we can't type check maps - // due to restrictions on generics so we have to check each entry key is a string and each entry - // value is a parameter group - @SuppressWarnings("unchecked") - Map parameterGroupMap = (Map) mapObject; - - // Add a validation result per map entry - for (Entry parameterGroupMapEntry : parameterGroupMap.entrySet()) { - // Create a validation status entry for the map - validationResultMap.put(parameterGroupMapEntry.getKey(), - new GroupValidationResult(parameterGroupMapEntry.getValue())); - } - } - - /** - * Gets the name of the parameter being validated. - * - * @return the name - */ - @Override - public String getName() { - return mapParameterName; - } - - /** - * 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(final String entryName, final ValidationResult mapEntryValidationResult) { - 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 - validationResultMap.put(entryName, mapEntryValidationResult); - this.setResult(mapEntryValidationResult.getStatus()); - } - - @Override - protected void addGroupTypeName(StringBuilder result) { - result.append("parameter group map \""); - result.append(mapParameterName); - result.append("\" "); - } -} \ No newline at end of file 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 deleted file mode 100644 index 1fe560d8..00000000 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupValidationResult.java +++ /dev/null @@ -1,390 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.common.parameters; - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import org.apache.commons.lang3.StringUtils; - -/** - * This class holds the result of the validation of a parameter group. - */ -public class GroupValidationResult extends CommonGroupValidationResult { - // The parameter group which the validation result applies - private final ParameterGroup parameterGroup; - - /** - * Constructor, create the field validation result with default arguments. - * - * @param parameterGroup the parameter group being validated - */ - public GroupValidationResult(final ParameterGroup parameterGroup) { - super(ParameterConstants.PARAMETER_GROUP_HAS_STATUS_MESSAGE); - - this.parameterGroup = parameterGroup; - - // Parameter group definitions may be optional - if (parameterGroup == null) { - return; - } - - // Add a validation result for all fields in the declared class - for (Field field : parameterGroup.getClass().getDeclaredFields()) { - // Check if a validation result should be added for this declared field - if (isIncludedField(field)) { - // Set a validation result for the field - validationResultMap.put(field.getName(), getSetValidationResult(field, parameterGroup)); - } - } - - // Add a validation result for protected and public fields in super classes - for (Field field : getSuperclassFields(parameterGroup.getClass().getSuperclass())) { - // Check if a validation result should be added for this declared field - if (isIncludedField(field)) { - // Set a validation result for the field - validationResultMap.putIfAbsent(field.getName(), getSetValidationResult(field, parameterGroup)); - } - } - } - - /** - * Construct a validation result for a field, updating "this" status. - * - * @param field The parameter field - * @param ParameterGroup The parameter group containing the field - * @return the validation result - * @throws Exception on accessing private fields - */ - private ValidationResult getSetValidationResult(Field field, ParameterGroup parameterGroup) { - ValidationResult result = getValidationResult(field, parameterGroup); - setResult(result.getStatus()); - - return result; - } - - /** - * Construct a validation result for a field. - * - * @param field The parameter field - * @param ParameterGroup The parameter group containing the field - * @return the validation result - * @throws Exception on accessing private fields - */ - private ValidationResult getValidationResult(final Field field, final ParameterGroup parameterGroup) { - final String fieldName = field.getName(); - final Class fieldType = field.getType(); - final Object fieldObject = getObjectField(parameterGroup, field); - - // perform null checks - ParameterValidationResult result = new ParameterValidationResult(field, fieldObject); - if (!result.isValid()) { - return result; - } - - // Nested parameter groups are allowed - if (ParameterGroup.class.isAssignableFrom(fieldType)) { - if (null != fieldObject) { - return ((ParameterGroup) fieldObject).validate(); - } else { - 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); - return result; - } - - // It's a regular parameter - return result; - } - - /** - * Get the value of a field in an object using a getter found with reflection. - * - * @param targetObject The object on which to read the field value - * @param fieldName The name of the field - * @return The field value - */ - private Object getObjectField(final Object targetObject, final Field field) { - String getterMethodName; - - // Check for Boolean fields, the convention for boolean getters is that they start with "is" - // If the field name already starts with "is" then the getter has the field name otherwise - // the field name is prepended with "is" - if (boolean.class.equals(field.getType())) { - if (field.getName().startsWith("is")) { - getterMethodName = field.getName(); - } else { - getterMethodName = "is" + StringUtils.capitalize(field.getName()); - } - } else { - getterMethodName = "get" + StringUtils.capitalize(field.getName()); - } - - // Look up the getter method for the field - Method getterMethod; - try { - getterMethod = targetObject.getClass().getMethod(getterMethodName, (Class[]) null); - } catch (NoSuchMethodException | SecurityException e) { - throw new ParameterRuntimeException("could not get getter method for parameter \"" + field.getName() + "\"", - e); - } - - // Invoke the getter - try { - return getterMethod.invoke(targetObject, (Object[]) null); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - throw new ParameterRuntimeException("error calling getter method for parameter \"" + field.getName() + "\"", - e); - } - } - - /** - * Check if this field is a map of parameter groups indexed by string keys. - * - * @param fieldName the name of the collection field. - * @param mapObject the map object to check - */ - private void checkMapIsParameterGroupMap(String fieldName, Object mapObject) { - if (mapObject == null) { - throw new ParameterRuntimeException("map parameter \"" + fieldName + "\" is null"); - } - - Map incomingMap = (Map) mapObject; - - for (Entry mapEntry : incomingMap.entrySet()) { - // Check the key is a string - if (!String.class.isAssignableFrom(mapEntry.getKey().getClass())) { - throw new ParameterRuntimeException("map entry is not a parameter group keyed by a string, key \"" - + mapEntry.getKey() + "\" in map \"" + fieldName + "\" is not a string"); - } - - // Check the value is a parameter group - if (!ParameterGroup.class.isAssignableFrom(mapEntry.getValue().getClass())) { - throw new ParameterRuntimeException("map entry is not a parameter group keyed by a string, value \"" - + mapEntry.getValue() + "\" in map \"" + fieldName + "\" is not a parameter group"); - } - } - } - - /** - * Check if this field contains parameter groups. - * - * @param fieldName the name of the collection field. - * @param collectionObject the collection object to check - */ - private void checkCollection4ParameterGroups(final String fieldName, final Object collectionObject) { - if (collectionObject == null) { - throw new ParameterRuntimeException("collection parameter \"" + fieldName + "\" is null"); - } - - Collection collection2Check = (Collection) collectionObject; - - for (Object collectionMember : collection2Check) { - if (ParameterGroup.class.isAssignableFrom(collectionMember.getClass())) { - throw new ParameterRuntimeException("collection parameter \"" + fieldName + "\" is illegal," - + " parameter groups are not allowed as collection members"); - } - } - } - - /** - * Gets the parameter group for this validation result. - * - * @return the parameter class - */ - public ParameterGroup getParameterGroup() { - return parameterGroup; - } - - /** - * Gets the name of the parameter group being validated. - * - * @return the name - */ - @Override - public String getName() { - return parameterGroup.getName(); - } - - /** - * Set the validation result on a parameter in a 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 parameterName, final ValidationStatus status, final String message) { - ValidationResult validationResult = validationResultMap.get(parameterName); - - if (validationResult == null) { - throw new ParameterRuntimeException("no parameter field exists for parameter: " + parameterName); - } - - // 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); - } - - /** - * Set the validation result on a nested parameter group. - * - * @param parameterName The name of the parameter field - * @param nestedValidationResult The validation result from a nested field - */ - public void setResult(final String parameterName, final ValidationResult nestedValidationResult) { - GroupValidationResult groupValidationResult; - try { - groupValidationResult = (GroupValidationResult) validationResultMap.get(parameterName); - } catch (ClassCastException e) { - throw new ParameterRuntimeException("parameter is not a nested group parameter: " + parameterName, e); - } - - if (groupValidationResult == null) { - throw new ParameterRuntimeException("no nested parameter field exists for parameter: " + parameterName); - } - - // Set the status of the parameter group and replace the field result - validationResultMap.put(parameterName, nestedValidationResult); - this.setResult(nestedValidationResult.getStatus()); - } - - /** - * Set the validation result on a nested parameter group map entry. - * - * @param parameterName The name of the parameter field - * @param key The key of the map entry - * @param nestedMapValidationResult The validation result from a nested map entry - */ - public void setResult(final String parameterName, final String key, - final ValidationResult nestedMapValidationResult) { - 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, nestedMapValidationResult); - this.setResult(nestedMapValidationResult.getStatus()); - } - - /** - * 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); - } - - @Override - protected void addGroupTypeName(StringBuilder result) { - result.append("parameter group \""); - - if (parameterGroup != null) { - result.append(parameterGroup.getName()); - result.append("\" type \""); - result.append(parameterGroup.getClass().getName()); - } else { - result.append("UNDEFINED"); - } - - result.append("\" "); - } - - - /** - * Check if a field should be included for validation. - * - * @param field the field to check for inclusion - * @return true of the field should be included - */ - private boolean isIncludedField(final Field field) { - return !field.getName().startsWith("$") && !field.getName().startsWith("_") - && !Modifier.isStatic(field.getModifiers()); - } - - /** - * Get the public and protected fields of super classes. - * @param firstSuperClass the first superclass to check - * - * @return a set of the superclass fields - */ - private List getSuperclassFields(final Class firstSuperClass) { - List superclassFields = new ArrayList<>(); - - Class currentClass = firstSuperClass; - while (currentClass.getSuperclass() != null) { - for (Field field : currentClass.getDeclaredFields()) { - // Check if this field is public or protected - if (Modifier.isPublic(field.getModifiers()) || Modifier.isProtected(field.getModifiers())) { - superclassFields.add(field); - } - } - - // Check the next super class down - currentClass = currentClass.getSuperclass(); - } - - return superclassFields; - } -} diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ObjectValidationResult.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ObjectValidationResult.java index e5597206..af1884a3 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ObjectValidationResult.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ObjectValidationResult.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,6 +40,8 @@ public class ObjectValidationResult extends ValidationResultImpl { * * @param name name of the object of this result * @param object object being validated + * @param status result status + * @param message result message */ public ObjectValidationResult(String name, Object object, ValidationStatus status, String message) { super(name, object, status, message); 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 8bfa183b..ab610933 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 @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -29,28 +30,28 @@ package org.onap.policy.common.parameters; public interface ParameterGroup { /** * Get the group name. - * + * * @return the group name */ 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 */ - GroupValidationResult validate(); + BeanValidationResult validate(); /** * Check if the parameters are valid. - * + * * @return true if the parameters are valid */ default boolean isValid() { diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterGroupImpl.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterGroupImpl.java index f0f34ac1..8a987bdd 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterGroupImpl.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterGroupImpl.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,9 @@ package org.onap.policy.common.parameters; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; import org.onap.policy.common.parameters.annotations.NotBlank; import org.onap.policy.common.parameters.annotations.NotNull; @@ -32,30 +34,16 @@ import org.onap.policy.common.parameters.annotations.NotNull; @NotBlank @Getter @Setter +@NoArgsConstructor +@AllArgsConstructor public class ParameterGroupImpl implements ParameterGroup { /** - * Group name. Note: this MUST not be "private" or it will not be validated. + * Group name. */ - protected String name; - - /** - * Constructs the object, with a {@code null} name. - */ - public ParameterGroupImpl() { - this.name = null; - } - - /** - * Constructs the object. - * - * @param name the group's name - */ - public ParameterGroupImpl(String name) { - this.name = name; - } + private String name; @Override - public GroupValidationResult validate() { - return new GroupValidationResult(this); + public BeanValidationResult validate() { + return new BeanValidator().validateTop(getClass().getSimpleName(), this); } } diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/annotations/ClassName.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/annotations/ClassName.java new file mode 100644 index 00000000..14d76fd7 --- /dev/null +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/annotations/ClassName.java @@ -0,0 +1,37 @@ +/* + * ============LICENSE_START======================================================= + * ONAP + * ================================================================================ + * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.common.parameters.annotations; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.TYPE_USE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Indicates that a field (i.e., String) identifies the name of a class in the classpath. + */ +@Retention(RUNTIME) +@Target({FIELD, TYPE_USE}) +public @interface ClassName { + +} diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/annotations/Size.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/annotations/Size.java new file mode 100644 index 00000000..160e0124 --- /dev/null +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/annotations/Size.java @@ -0,0 +1,43 @@ +/* + * ============LICENSE_START======================================================= + * ONAP + * ================================================================================ + * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.common.parameters.annotations; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.TYPE_USE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Indicates the size of a Map or Collection. + */ +@Retention(RUNTIME) +@Target({FIELD, TYPE_USE}) +public @interface Size { + + /** + * The minimum size allowed. + * + * @return the minimum size allowed + */ + int min(); +} diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestAbstractParameters.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestAbstractParameters.java deleted file mode 100644 index b568d7fb..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestAbstractParameters.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============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; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.onap.policy.common.parameters.testclasses.EmptyParameterGroup; - -public class TestAbstractParameters { - - @Test - public void testAbstractParameters() { - final EmptyParameterGroup parameters = new EmptyParameterGroup("Empty Group"); - assertTrue(parameters.isValid()); - } -} diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java index 8795602a..b7bea204 100644 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java +++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ package org.onap.policy.common.parameters; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; @@ -91,6 +92,10 @@ public class TestBeanValidationResult { assertEquals(INITIAL_INDENT + BEAN_INVALID_MSG + MID_INDENT + cleanMsg + MID_INDENT + invalidMsg, bean.getResult(INITIAL_INDENT, NEXT_INDENT, true)); + + bean = new BeanValidationResult(NAME, OBJECT); + assertFalse(bean.addResult(MY_LIST, "hello", ValidationStatus.INVALID, TEXT1)); + assertThat(bean.getResult()).contains("\"" + MY_LIST + "\" value \"hello\" INVALID, " + TEXT1); } @Test diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidator.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidator.java index 1095ff40..83d0a7f9 100644 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidator.java +++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidator.java @@ -23,6 +23,7 @@ package org.onap.policy.common.parameters; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertTrue; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -31,11 +32,13 @@ import java.util.function.Consumer; import lombok.Getter; import org.junit.Before; import org.junit.Test; +import org.onap.policy.common.parameters.annotations.ClassName; import org.onap.policy.common.parameters.annotations.Max; import org.onap.policy.common.parameters.annotations.Min; import org.onap.policy.common.parameters.annotations.NotBlank; import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.common.parameters.annotations.Pattern; +import org.onap.policy.common.parameters.annotations.Size; import org.onap.policy.common.parameters.annotations.Valid; public class TestBeanValidator { @@ -43,6 +46,7 @@ public class TestBeanValidator { private static final String STR_FIELD = "strValue"; private static final String INT_FIELD = "intValue"; private static final String NUM_FIELD = "numValue"; + private static final String ITEMS_FIELD = "items"; private static final String STRING_VALUE = "string value"; private static final int INT_VALUE = 20; @@ -170,6 +174,83 @@ public class TestBeanValidator { assertTrue(validator.validateTop(TOP, notBlankInt).isValid()); } + /** + * Tests verSize with a collection. + */ + @Test + public void testVerSizeCollection() { + class CollectionSizeCheck { + @Getter + @Size(min = 3) + Collection items; + } + + CollectionSizeCheck collCheck = new CollectionSizeCheck(); + + // valid length - exact + collCheck.items = List.of(1, 2, 3); + assertThat(validator.validateTop(TOP, collCheck).isValid()).isTrue(); + + // valid length - extra + collCheck.items = List.of(1, 2, 3, 4); + assertThat(validator.validateTop(TOP, collCheck).isValid()).isTrue(); + + // too few + collCheck.items = List.of(1, 2); + assertInvalid("testVerSize", validator.validateTop(TOP, collCheck), ITEMS_FIELD, "minimum", "3"); + + // null + collCheck.items = null; + assertThat(validator.validateTop(TOP, collCheck).isValid()).isTrue(); + } + + /** + * Tests verSize with a map. + */ + @Test + public void testVerSizeMap() { + class MapSizeCheck { + @Getter + @Size(min = 3) + Map items; + } + + MapSizeCheck mapCheck = new MapSizeCheck(); + + // valid length - exact + mapCheck.items = Map.of(1, 10, 2, 20, 3, 30); + assertThat(validator.validateTop(TOP, mapCheck).isValid()).isTrue(); + + // valid length - extra + mapCheck.items = Map.of(1, 10, 2, 20, 3, 30, 4, 40); + assertThat(validator.validateTop(TOP, mapCheck).isValid()).isTrue(); + + // too few + mapCheck.items = Map.of(1, 10, 2, 20); + assertInvalid("testVerSize", validator.validateTop(TOP, mapCheck), ITEMS_FIELD, "minimum", "3"); + + // null + mapCheck.items = null; + assertThat(validator.validateTop(TOP, mapCheck).isValid()).isTrue(); + } + + /** + * Tests verSize with an object for which it doesn't apply. + */ + @Test + public void testVerSizeOther() { + class OtherSizeCheck { + @Getter + @Size(min = 3) + Integer items; + } + + OtherSizeCheck otherCheck = new OtherSizeCheck(); + + otherCheck.items = 10; + assertThat(validator.validateTop(TOP, otherCheck).isValid()).isTrue(); + } + @Test public void testVerRegex() { class RegexCheck { @@ -410,6 +491,30 @@ public class TestBeanValidator { assertTrue(validator.validateTop(TOP, atomIntField).isValid()); } + @Test + public void testVerClassName() { + class ClassNameCheck { + @Getter + @ClassName + String strValue; + } + + ClassNameCheck classCheck = new ClassNameCheck(); + + // null should be OK + classCheck.strValue = null; + assertTrue(validator.validateTop(TOP, classCheck).isValid()); + + // valid class name + classCheck.strValue = getClass().getName(); + assertTrue(validator.validateTop(TOP, classCheck).isValid()); + + // invalid class name + classCheck.strValue = ""; + assertInvalid("testVerClassName", validator.validateTop(TOP, classCheck), + STR_FIELD, "class is not in the classpath"); + } + @Test public void testVerCascade() { class Item { diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestJsonInput.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestJsonInput.java deleted file mode 100644 index abef5528..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestJsonInput.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.common.parameters; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import java.io.FileReader; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import org.junit.Test; -import org.onap.policy.common.parameters.testclasses.TestParametersL00; - - -public class TestJsonInput { - - @Test - public void testJsonInput() throws IOException { - TestParametersL00 testParameterGroup = null; - - // Read the parameters from JSON using Gson - final Gson gson = new GsonBuilder().create(); - testParameterGroup = gson.fromJson(new FileReader("src/test/resources/parameters/TestParameters.json"), - TestParametersL00.class); - - GroupValidationResult validationResult = testParameterGroup.validate(); - assertTrue(validationResult.isValid()); - assertEquals("l00NameFromFile", testParameterGroup.getName()); - - String expectedResult = new String(Files.readAllBytes( - Paths.get("src/test/resources/expectedValidationResults/TestJsonYamlValidationResult.txt"))) - .replaceAll("\\s+", ""); - assertEquals(expectedResult, validationResult.getResult("", " ", true).replaceAll("\\s+", "")); - } -} 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 deleted file mode 100644 index fda37816..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestParameterService.java +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.common.parameters; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.onap.policy.common.parameters.testclasses.EmptyParameterGroup; - -public class TestParameterService { - private static final String EMPTY_GROUP = "Empty Group"; - - @Test - public void testParameterService() { - ParameterService.clear(); - - assertFalse(ParameterService.contains("EmptyGroup")); - - assertThatThrownBy(() -> ParameterService.get("EmptyGroup")) - .hasMessage("\"EmptyGroup\" not found in parameter service"); - - ParameterService.register(new EmptyParameterGroup(EMPTY_GROUP)); - assertTrue(ParameterService.contains(EMPTY_GROUP)); - assertNotNull(ParameterService.get(EMPTY_GROUP)); - - assertThatThrownBy(() -> ParameterService.register(new EmptyParameterGroup(EMPTY_GROUP))) - .hasMessage("\"Empty Group\" already registered in parameter service"); - - assertThatThrownBy(() -> ParameterService.register(new EmptyParameterGroup(EMPTY_GROUP), false)) - .hasMessage("\"Empty Group\" already registered in parameter service"); - - 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)); - - assertThatThrownBy(() -> ParameterService.deregister(EMPTY_GROUP)) - .hasMessage("\"Empty Group\" not registered in parameter service"); - - assertThatThrownBy(() -> ParameterService.get(EMPTY_GROUP)) - .hasMessage("\"Empty Group\" not found in parameter service"); - - ParameterService.register(new EmptyParameterGroup(EMPTY_GROUP)); - assertTrue(ParameterService.contains(EMPTY_GROUP)); - assertNotNull(ParameterService.get(EMPTY_GROUP)); - - assertEquals(1, ParameterService.getAll().size()); - ParameterService.clear(); - assertEquals(0, ParameterService.getAll().size()); - assertFalse(ParameterService.contains(EMPTY_GROUP)); - - assertThatThrownBy(() -> ParameterService.get(EMPTY_GROUP)) - .hasMessage("\"Empty Group\" not found in parameter service"); - } -} 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 9e7121cd..b19b92da 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 @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,25 +21,17 @@ package org.onap.policy.common.parameters; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; import org.junit.Test; import org.onap.policy.common.parameters.annotations.Max; import org.onap.policy.common.parameters.annotations.Min; import org.onap.policy.common.parameters.annotations.NotBlank; import org.onap.policy.common.parameters.annotations.NotNull; -import org.onap.policy.common.parameters.testclasses.TestParametersL00; -import org.onap.policy.common.parameters.testclasses.TestParametersL10; +import org.onap.policy.common.parameters.annotations.Valid; public class TestValidation { - private static final String L0_PARAMETERS = "l0Parameters"; - private static final String NOT_BLANK_STRING_MESSAGE = "field 'notBlankString' type 'java.lang.String' value '' INVALID, must be a non-blank string\n" .replace('\'', '"'); @@ -73,168 +65,6 @@ public class TestValidation { @Max(value = 10) private long maxLong; - @Test - public void testValidationOk() throws IOException { - TestParametersL00 l0Parameters = new TestParametersL00(L0_PARAMETERS); - - GroupValidationResult validationResult = l0Parameters.validate(); - assertTrue(validationResult.isValid()); - assertTrue(validationResult.isClean()); - assertNull(validationResult.getResult()); - assertEquals(l0Parameters, validationResult.getParameterGroup()); - assertEquals(l0Parameters.getName(), validationResult.getName()); - - String expectedResult = new String(Files.readAllBytes( - Paths.get("src/test/resources/expectedValidationResults/TestParametersL0_0_OK.txt"))) - .replaceAll("\\s+", ""); - assertEquals(expectedResult, validationResult.getResult("", " ", true).replaceAll("\\s+", "")); - } - - @Test - public void testValidationObservation() throws IOException { - TestParametersL00 l0Parameters = new TestParametersL00(L0_PARAMETERS); - - l0Parameters.triggerValidationStatus(ValidationStatus.OBSERVATION, 3); - - String expectedResult = new String(Files.readAllBytes( - Paths.get("src/test/resources/expectedValidationResults/TestParametersL0_3_Observation.txt"))) - .replaceAll("\\s+", ""); - - GroupValidationResult validationResult = l0Parameters.validate(); - assertTrue(validationResult.isValid()); - assertFalse(validationResult.isClean()); - assertEquals(expectedResult, validationResult.getResult().replaceAll("\\s+", "")); - - l0Parameters.triggerValidationStatus(ValidationStatus.CLEAN, 3); - l0Parameters.triggerValidationStatus(ValidationStatus.OBSERVATION, 2); - - expectedResult = new String(Files.readAllBytes( - Paths.get("src/test/resources/expectedValidationResults/TestParametersL0_2_Observation.txt"))) - .replaceAll("\\s+", ""); - - validationResult = l0Parameters.validate(); - assertTrue(validationResult.isValid()); - assertEquals(expectedResult, validationResult.getResult().replaceAll("\\s+", "")); - - l0Parameters.triggerValidationStatus(ValidationStatus.CLEAN, 3); - l0Parameters.triggerValidationStatus(ValidationStatus.OBSERVATION, 1); - - expectedResult = new String(Files.readAllBytes( - Paths.get("src/test/resources/expectedValidationResults/TestParametersL0_1_Observation.txt"))) - .replaceAll("\\s+", ""); - - validationResult = l0Parameters.validate(); - assertTrue(validationResult.isValid()); - assertEquals(expectedResult, validationResult.getResult().replaceAll("\\s+", "")); - - l0Parameters.triggerValidationStatus(ValidationStatus.CLEAN, 3); - l0Parameters.triggerValidationStatus(ValidationStatus.OBSERVATION, 0); - - validationResult = l0Parameters.validate(); - assertTrue(validationResult.isValid()); - assertEquals(null, validationResult.getResult()); - } - - @Test - public void testValidationWarning() throws IOException { - TestParametersL00 l0Parameters = new TestParametersL00(L0_PARAMETERS); - - l0Parameters.triggerValidationStatus(ValidationStatus.WARNING, 3); - - String expectedResult = new String(Files.readAllBytes( - Paths.get("src/test/resources/expectedValidationResults/TestParametersL0_3_Warning.txt"))) - .replaceAll("\\s+", ""); - - GroupValidationResult validationResult = l0Parameters.validate(); - assertTrue(validationResult.isValid()); - assertEquals(expectedResult, validationResult.getResult().replaceAll("\\s+", "")); - - l0Parameters.triggerValidationStatus(ValidationStatus.CLEAN, 3); - l0Parameters.triggerValidationStatus(ValidationStatus.WARNING, 2); - - expectedResult = new String(Files.readAllBytes( - Paths.get("src/test/resources/expectedValidationResults/TestParametersL0_2_Warning.txt"))) - .replaceAll("\\s+", ""); - - validationResult = l0Parameters.validate(); - assertTrue(validationResult.isValid()); - assertEquals(expectedResult, validationResult.getResult().replaceAll("\\s+", "")); - - l0Parameters.triggerValidationStatus(ValidationStatus.CLEAN, 3); - l0Parameters.triggerValidationStatus(ValidationStatus.WARNING, 1); - - expectedResult = new String(Files.readAllBytes( - Paths.get("src/test/resources/expectedValidationResults/TestParametersL0_1_Warning.txt"))) - .replaceAll("\\s+", ""); - - validationResult = l0Parameters.validate(); - assertTrue(validationResult.isValid()); - assertEquals(expectedResult, validationResult.getResult().replaceAll("\\s+", "")); - - l0Parameters.triggerValidationStatus(ValidationStatus.CLEAN, 3); - l0Parameters.triggerValidationStatus(ValidationStatus.WARNING, 0); - - validationResult = l0Parameters.validate(); - assertTrue(validationResult.isValid()); - assertEquals(null, validationResult.getResult()); - } - - @Test - public void testValidationInvalid() throws IOException { - TestParametersL00 l0Parameters = new TestParametersL00(L0_PARAMETERS); - - l0Parameters.triggerValidationStatus(ValidationStatus.INVALID, 3); - - String expectedResult = new String(Files.readAllBytes( - Paths.get("src/test/resources/expectedValidationResults/TestParametersL0_3_Invalid.txt"))) - .replaceAll("\\s+", ""); - - GroupValidationResult validationResult = l0Parameters.validate(); - assertFalse(validationResult.isValid()); - assertEquals(expectedResult, validationResult.getResult().replaceAll("\\s+", "")); - - l0Parameters.triggerValidationStatus(ValidationStatus.CLEAN, 3); - l0Parameters.triggerValidationStatus(ValidationStatus.INVALID, 2); - - expectedResult = new String(Files.readAllBytes( - Paths.get("src/test/resources/expectedValidationResults/TestParametersL0_2_Invalid.txt"))) - .replaceAll("\\s+", ""); - - validationResult = l0Parameters.validate(); - assertFalse(validationResult.isValid()); - assertEquals(expectedResult, validationResult.getResult().replaceAll("\\s+", "")); - - l0Parameters.triggerValidationStatus(ValidationStatus.CLEAN, 3); - l0Parameters.triggerValidationStatus(ValidationStatus.INVALID, 1); - - expectedResult = new String(Files.readAllBytes( - Paths.get("src/test/resources/expectedValidationResults/TestParametersL0_1_Invalid.txt"))) - .replaceAll("\\s+", ""); - - validationResult = l0Parameters.validate(); - assertFalse(validationResult.isValid()); - assertEquals(expectedResult, validationResult.getResult().replaceAll("\\s+", "")); - - l0Parameters.triggerValidationStatus(ValidationStatus.CLEAN, 3); - l0Parameters.triggerValidationStatus(ValidationStatus.INVALID, 0); - - validationResult = l0Parameters.validate(); - assertTrue(validationResult.isValid()); - assertEquals(null, validationResult.getResult()); - } - - @Test - public void testValidationEmptySubGroup() { - TestParametersL10 l10Parameters = new TestParametersL10("l10Parameters"); - - l10Parameters.setL10LGenericNested0(null); - - GroupValidationResult validationResult = l10Parameters.validate(); - assertTrue(validationResult.isValid()); - - assertTrue(validationResult.getResult("", "", true).contains("UNDEFINED")); - } - @Test public void testGetValidationResult() { Contained item = new Contained(); @@ -242,9 +72,9 @@ public class TestValidation { Container cont = new Container(); cont.item = item; - GroupValidationResult result = cont.validate(); + BeanValidationResult result = cont.validate(); assertEquals(ValidationStatus.INVALID, result.getStatus()); - assertTrue(result.getResult().contains(">= 1")); + assertThat(result.getResult()).contains("minimum"); item.minInt = 1000; result = cont.validate(); @@ -253,7 +83,7 @@ public class TestValidation { cont.item = null; result = cont.validate(); assertEquals(ValidationStatus.INVALID, result.getStatus()); - assertTrue(result.getResult().contains("is null")); + assertThat(result.getResult()).contains("is null"); } @Test @@ -429,6 +259,7 @@ public class TestValidation { private static class Container extends ParameterGroupImpl { @NotNull + @Valid private Contained item; public Container() { 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 deleted file mode 100644 index b02022d7..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationErrors.java +++ /dev/null @@ -1,117 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.common.parameters; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.onap.policy.common.parameters.testclasses.ParameterGroupMissingGetter; -import org.onap.policy.common.parameters.testclasses.ParameterGroupPrivateGetter; -import org.onap.policy.common.parameters.testclasses.ParameterGroupWithArray; -import org.onap.policy.common.parameters.testclasses.ParameterGroupWithCollection; -import org.onap.policy.common.parameters.testclasses.ParameterGroupWithIllegalMapKey; -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 { - @Test - public void testBadArrayValidation() { - ParameterGroupWithArray groupWithArray = new ParameterGroupWithArray("Illegal Array Group"); - assertTrue(groupWithArray.isValid()); - } - - @Test - public void testCollectionValidation() { - ParameterGroupWithCollection legalCollection = new ParameterGroupWithCollection("Legal Collection"); - assertTrue(legalCollection.isValid()); - - ParameterGroupWithParameterGroupCollection illegalCollection = new ParameterGroupWithParameterGroupCollection( - "Illegal Collection"); - - assertThatThrownBy(illegalCollection::isValid).isInstanceOf(ParameterRuntimeException.class) - .hasMessage("collection parameter \"parameterGroupArrayList\" is illegal," - + " parameter groups are not allowed as collection members"); - } - - @Test - public void testNullCollection() { - ParameterGroupWithNullCollection nullCollection = new ParameterGroupWithNullCollection("Null Collection"); - - assertThatThrownBy(nullCollection::isValid).isInstanceOf(ParameterRuntimeException.class) - .hasMessage("collection parameter \"nullList\" is null"); - } - - @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"); - - assertThatThrownBy(nullMap::isValid).isInstanceOf(ParameterRuntimeException.class) - .hasMessage("map parameter \"nullMap\" is null"); - } - - @Test - public void testBadMapKeyValidation() { - ParameterGroupWithIllegalMapKey illegalMap = new ParameterGroupWithIllegalMapKey("Illegal Map"); - - assertThatThrownBy(illegalMap::isValid).isInstanceOf(ParameterRuntimeException.class) - .hasMessage("map entry is not a parameter group keyed by a string, key \"1\" " - + "in map \"badMap\" is not a string"); - } - - @Test - public void testBadMapValueValidation() { - ParameterGroupWithIllegalMapValue illegalMap = new ParameterGroupWithIllegalMapValue("Illegal Map"); - - assertThatThrownBy(illegalMap::isValid).isInstanceOf(ParameterRuntimeException.class) - .hasMessage("map entry is not a parameter group keyed by a string, value \"1\" in " - + "map \"intMap\" is not a parameter group"); - } - - @Test - public void testMissingGetter() { - ParameterGroupMissingGetter badGetterName = new ParameterGroupMissingGetter("BGN"); - - assertThatThrownBy(badGetterName::isValid).isInstanceOf(ParameterRuntimeException.class) - .hasMessage("could not get getter method for parameter \"value\""); - } - - @Test - public void testPrivateGetter() { - ParameterGroupPrivateGetter privateGetter = new ParameterGroupPrivateGetter("privateGetter"); - - assertThatThrownBy(privateGetter::isValid).isInstanceOf(ParameterRuntimeException.class) - .hasMessage("could not get getter method for parameter \"value\""); - } -} 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 deleted file mode 100644 index 46360ef9..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResults.java +++ /dev/null @@ -1,143 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.common.parameters; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.LinkedHashMap; -import java.util.Map; -import org.junit.Before; -import org.junit.Test; -import org.onap.policy.common.parameters.testclasses.TestParametersL10; -import org.onap.policy.common.parameters.testclasses.TestParametersLGeneric; - -public class TestValidationResults { - private static final String NON_EXISTANT_PARAMETER = "nonExistantParameter"; - private static final String L10L_GENERIC_NESTED_MAP_VAL0 = "l10LGenericNestedMapVal0"; - private static final String L10_INT_FIELD = "l10IntField"; - private static final String ENTRY0 = "entry0"; - private static final String THIS_VALUE_IS_INVALID = "This value is invalid"; - private static final String SOMETHING_WAS_OBSERVED = "Something was observed"; - private static final String PG_MAP = "pgMap"; - - private Map pgMap = new LinkedHashMap<>(); - private ParameterGroup pg = new TestParametersL10("pg"); - - @Before - public void initMap() { - pgMap.put(ENTRY0, new TestParametersLGeneric(ENTRY0)); - } - - @Test - public void testGroupMapValidationResult() throws NoSuchFieldException { - GroupMapValidationResult result = new GroupMapValidationResult(this.getClass().getDeclaredField(PG_MAP), - pgMap); - - assertTrue(result.isValid()); - assertEquals(PG_MAP, result.getName()); - - result.setResult(ValidationStatus.OBSERVATION); - assertTrue(result.isValid()); - assertEquals(ValidationStatus.OBSERVATION, result.getStatus()); - - // Once the status is stepped, it can't be reset back because it is the status of map members - result.setResult(ValidationStatus.CLEAN); - assertTrue(result.isValid()); - assertEquals(ValidationStatus.OBSERVATION, result.getStatus()); - - result.setResult(ValidationStatus.OBSERVATION, SOMETHING_WAS_OBSERVED); - assertTrue(result.isValid()); - assertEquals(ValidationStatus.OBSERVATION, result.getStatus()); - assertEquals("parameter group map \"pgMap\" OBSERVATION, Something was observed", result.getResult().trim()); - - result.setResult(ENTRY0, new GroupValidationResult(pgMap.get(ENTRY0))); - assertTrue(result.isValid()); - assertEquals(ValidationStatus.OBSERVATION, result.getStatus()); - assertEquals("parameter group map \"pgMap\" OBSERVATION, Something was observed", result.getResult().trim()); - - assertThatThrownBy(() -> result.setResult("nonExistantEntry", new GroupValidationResult(pgMap.get(ENTRY0)))) - .hasMessage("no entry with name \"nonExistantEntry\" exists"); - } - - @Test - public void testGroupValidationResult() throws NoSuchFieldException { - GroupValidationResult result = new GroupValidationResult(pg); - - assertTrue(result.isValid()); - assertEquals(pg, result.getParameterGroup()); - assertEquals("pg", result.getName()); - - result.setResult(ValidationStatus.OBSERVATION); - assertTrue(result.isValid()); - assertEquals(ValidationStatus.OBSERVATION, result.getStatus()); - - // Once the status is stepped, it can't be reset back because it is the status of map members - result.setResult(ValidationStatus.CLEAN); - assertTrue(result.isValid()); - assertEquals(ValidationStatus.OBSERVATION, result.getStatus()); - - result.setResult(ValidationStatus.OBSERVATION, SOMETHING_WAS_OBSERVED); - assertTrue(result.isValid()); - assertEquals(ValidationStatus.OBSERVATION, result.getStatus()); - assertEquals("parameter group \"pg\" type \"org.onap.policy.common.parameters.testclasses.TestParametersL10\"" - + " OBSERVATION, Something was observed", result.getResult().trim()); - - assertThatThrownBy(() -> result.setResult(NON_EXISTANT_PARAMETER, ValidationStatus.OBSERVATION, - SOMETHING_WAS_OBSERVED)) - .hasMessage("no parameter field exists for parameter: nonExistantParameter"); - - result.setResult(L10_INT_FIELD, ValidationStatus.OBSERVATION, SOMETHING_WAS_OBSERVED); - assertTrue(result.isValid()); - - assertThatThrownBy(() -> result.setResult(NON_EXISTANT_PARAMETER, new GroupValidationResult(pg))) - .hasMessage("no nested parameter field exists for parameter: nonExistantParameter"); - - assertThatThrownBy(() -> result.setResult(L10_INT_FIELD, new GroupValidationResult(pg))) - .hasMessage("parameter is not a nested group parameter: l10IntField"); - - GroupMapValidationResult groupMapResult = new GroupMapValidationResult( - this.getClass().getDeclaredField(PG_MAP), pgMap); - - assertThatThrownBy(() -> result.setResult(NON_EXISTANT_PARAMETER, ENTRY0, groupMapResult)) - .hasMessage("no group map parameter field exists for parameter: nonExistantParameter"); - - assertThatThrownBy(() -> result.setResult(L10_INT_FIELD, ENTRY0, groupMapResult)) - .hasMessage("parameter is not a nested group map parameter: l10IntField"); - - result.setResult("l10LGenericNestedMap", L10L_GENERIC_NESTED_MAP_VAL0, ValidationStatus.INVALID, - THIS_VALUE_IS_INVALID); - assertEquals(ValidationStatus.INVALID, result.getStatus()); - - assertThatThrownBy(() -> result.setResult(L10_INT_FIELD, L10L_GENERIC_NESTED_MAP_VAL0, ValidationStatus.INVALID, - THIS_VALUE_IS_INVALID)) - .hasMessage("parameter is not a nested group map parameter: l10IntField"); - - assertThatThrownBy(() -> result.setResult(NON_EXISTANT_PARAMETER, L10L_GENERIC_NESTED_MAP_VAL0, - ValidationStatus.INVALID, THIS_VALUE_IS_INVALID)).hasMessage( - "no group map parameter field exists for parameter: nonExistantParameter"); - - assertThatThrownBy(() -> result.setResult("l10LGenericNestedMap", "NonExistantKey", ValidationStatus.INVALID, - THIS_VALUE_IS_INVALID)).hasMessage("no entry with name \"NonExistantKey\" exists"); - } -} diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestYamlInput.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestYamlInput.java deleted file mode 100644 index 66656844..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestYamlInput.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.common.parameters; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.io.FileReader; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import org.junit.Test; -import org.onap.policy.common.parameters.testclasses.TestParametersL00; -import org.yaml.snakeyaml.Yaml; - -public class TestYamlInput { - @Test - public void testYamlInput() throws IOException { - TestParametersL00 testParameterGroup = null; - - // Read the parameters from JSON using Gson - final Yaml yaml = new Yaml(); - testParameterGroup = yaml.loadAs(new FileReader("src/test/resources/parameters/TestParameters.yaml"), - TestParametersL00.class); - - GroupValidationResult validationResult = testParameterGroup.validate(); - assertTrue(validationResult.isValid()); - assertEquals("l00NameFromFile", testParameterGroup.getName()); - - String expectedResult = new String(Files.readAllBytes( - Paths.get("src/test/resources/expectedValidationResults/TestJsonYamlValidationResult.txt"))) - .replaceAll("\\s+", ""); - assertEquals(expectedResult, validationResult.getResult("", " ", true).replaceAll("\\s+", "")); - } -} 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 deleted file mode 100644 index d1787482..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/EmptyParameterGroup.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. - * ================================================================================ - * 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.ParameterGroupImpl; - -public class EmptyParameterGroup extends ParameterGroupImpl { - - public EmptyParameterGroup(String name) { - super(name); - } -} diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupMissingGetter.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupMissingGetter.java deleted file mode 100644 index e6c85923..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupMissingGetter.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. - * ================================================================================ - * 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.ParameterGroupImpl; - -public class ParameterGroupMissingGetter extends ParameterGroupImpl { - private String value; - - public ParameterGroupMissingGetter(final String name) { - super(name); - } - - public String getTheValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } -} diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupPrivateGetter.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupPrivateGetter.java deleted file mode 100644 index 1d90ca1f..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupPrivateGetter.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. - * ================================================================================ - * 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.ParameterGroupImpl; - -public class ParameterGroupPrivateGetter extends ParameterGroupImpl { - private String value; - - public ParameterGroupPrivateGetter(final String name) { - super(name); - } - - public String getTheValue() { - return getValue(); - } - - private String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } -} 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 deleted file mode 100644 index e37b47ae..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithArray.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. - * ================================================================================ - * 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.ParameterGroupImpl; - -public class ParameterGroupWithArray extends ParameterGroupImpl { - private int[] intArray = {1, 2, 3}; - - public ParameterGroupWithArray(final String name) { - super(name); - } - - public int[] getIntArray() { - return intArray; - } -} 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 deleted file mode 100644 index ee7c1715..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithCollection.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. - * ================================================================================ - * 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 java.util.ArrayList; -import java.util.List; -import org.onap.policy.common.parameters.ParameterGroupImpl; - -public class ParameterGroupWithCollection extends ParameterGroupImpl { - private List intArrayList = new ArrayList<>(); - - /** - * Create a test parameter group. - * - * @param name the parameter group name - */ - public ParameterGroupWithCollection(final String name) { - super(name); - - intArrayList.add(1); - intArrayList.add(2); - intArrayList.add(3); - } - - public List getIntArrayList() { - return intArrayList; - } -} 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 deleted file mode 100644 index b3c7d1b7..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapKey.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. - * ================================================================================ - * 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 java.util.LinkedHashMap; -import java.util.Map; -import org.onap.policy.common.parameters.ParameterGroup; -import org.onap.policy.common.parameters.ParameterGroupImpl; - -public class ParameterGroupWithIllegalMapKey extends ParameterGroupImpl { - private Map badMap = new LinkedHashMap<>(); - - /** - * Create a test parameter group. - * @param name the parameter group name - */ - public ParameterGroupWithIllegalMapKey(final String name) { - super(name); - - badMap.put(1, new TestParametersLGeneric("One")); - badMap.put(2, new TestParametersLGeneric("Two")); - badMap.put(3, new TestParametersLGeneric("Three")); - } - - public Map getBadMap() { - return badMap; - } -} 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 deleted file mode 100644 index 4df708a4..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapValue.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. - * ================================================================================ - * 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 java.util.LinkedHashMap; -import java.util.Map; -import org.onap.policy.common.parameters.ParameterGroupImpl; - -public class ParameterGroupWithIllegalMapValue extends ParameterGroupImpl { - private Map intMap = new LinkedHashMap<>(); - - /** - * Create a test parameter group. - * @param name the parameter group name - */ - public ParameterGroupWithIllegalMapValue(final String name) { - super(name); - - intMap.put("One", 1); - intMap.put("Two", 2); - intMap.put("Three", 3); - } - - public Map getIntMap() { - return intMap; - } -} 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 deleted file mode 100644 index 35752c75..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullCollection.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. - * ================================================================================ - * 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 java.util.List; -import org.onap.policy.common.parameters.ParameterGroupImpl; - -public class ParameterGroupWithNullCollection extends ParameterGroupImpl { - private List nullList = null; - - /** - * Create a test parameter group. - * @param name the parameter group name - */ - public ParameterGroupWithNullCollection(final String name) { - super(name); - } - - public List getNullList() { - return nullList; - } -} 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 deleted file mode 100644 index 1a640023..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullMapValue.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. - * ================================================================================ - * 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 java.util.Map; -import org.onap.policy.common.parameters.ParameterGroupImpl; - -public class ParameterGroupWithNullMapValue extends ParameterGroupImpl { - private Map nullMap = null; - - /** - * Create a test parameter group. - * @param name the parameter group name - */ - public ParameterGroupWithNullMapValue(final String name) { - super(name); - } - - public Map getNullMap() { - return nullMap; - } -} 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 deleted file mode 100644 index 7fe1402f..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullSubGroup.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. - * ================================================================================ - * 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.ParameterGroup; -import org.onap.policy.common.parameters.ParameterGroupImpl; - -public class ParameterGroupWithNullSubGroup extends ParameterGroupImpl { - private ParameterGroup subGroup = null; - - /** - * Create a test parameter group. - * @param name the parameter group name - */ - public ParameterGroupWithNullSubGroup(final String name) { - super(name); - } - - public ParameterGroup getSubGroup() { - return subGroup; - } -} 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 deleted file mode 100644 index 08c799f5..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithParameterGroupCollection.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. - * ================================================================================ - * 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 java.util.ArrayList; -import java.util.List; -import org.onap.policy.common.parameters.ParameterGroup; -import org.onap.policy.common.parameters.ParameterGroupImpl; - -public class ParameterGroupWithParameterGroupCollection extends ParameterGroupImpl { - private List parameterGroupArrayList = new ArrayList<>(); - - /** - * Create a test parameter group. - * @param name the parameter group name - */ - public ParameterGroupWithParameterGroupCollection(final String name) { - super(name); - - parameterGroupArrayList.add(new TestParametersLGeneric("Generic0")); - parameterGroupArrayList.add(new TestParametersLGeneric("Generic1")); - parameterGroupArrayList.add(new TestParametersLGeneric("Generic2")); - } - - public List getParameterGroupArrayList() { - return parameterGroupArrayList; - } -} diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersL00.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersL00.java deleted file mode 100644 index 51440546..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersL00.java +++ /dev/null @@ -1,208 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. - * ================================================================================ - * 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 java.util.LinkedHashMap; -import java.util.Map; -import java.util.Map.Entry; -import org.apache.commons.lang3.StringUtils; -import org.onap.policy.common.parameters.GroupValidationResult; -import org.onap.policy.common.parameters.ParameterConstants; -import org.onap.policy.common.parameters.ParameterGroupImpl; -import org.onap.policy.common.parameters.ValidationStatus; - -public class TestParametersL00 extends ParameterGroupImpl { - private static final String L00_INT_FIELD = "l00IntField"; - private static final String L00_STRING_FIELD = "l00StringField"; - - private static final String A_CONSTANT = "A Constant"; - - private int l00IntField = 0; - private String l00StringField = "Legal " + this.getClass().getName(); - private TestParametersL10 l00L10Nested = new TestParametersL10("l00L10Nested"); - private TestParametersLGeneric l00LGenericNested = new TestParametersLGeneric("l00LGenericNested"); - private Map l00LGenericNestedMap = new LinkedHashMap<>(); - private boolean isSomeFlag; - private boolean someNonIsFlag; - - /** - * Default constructor. - */ - public TestParametersL00() { - super(A_CONSTANT); - } - - /** - * Create a test parameter group. - * - * @param name the parameter group name - */ - public TestParametersL00(final String name) { - super(name); - - TestParametersLGeneric l00LGenericNestedMapVal0 = new TestParametersLGeneric("l00LGenericNestedMapVal0"); - l00LGenericNestedMap.put(l00LGenericNestedMapVal0.getName(), l00LGenericNestedMapVal0); - TestParametersLGeneric l00LGenericNestedMapVal1 = new TestParametersLGeneric("l00LGenericNestedMapVal1"); - l00LGenericNestedMap.put(l00LGenericNestedMapVal1.getName(), l00LGenericNestedMapVal1); - } - - public int getL00IntField() { - return l00IntField; - } - - public String getL00StringField() { - return l00StringField; - } - - public TestParametersL10 getL00L10Nested() { - return l00L10Nested; - } - - public TestParametersLGeneric getL00LGenericNested() { - return l00LGenericNested; - } - - public Map getL00LGenericNestedMap() { - return l00LGenericNestedMap; - } - - public boolean isSomeFlag() { - return isSomeFlag; - } - - public boolean isSomeNonIsFlag() { - return someNonIsFlag; - } - - public void setSomeFlag(boolean isSomeFlag) { - this.isSomeFlag = isSomeFlag; - } - - public void setL00IntField(int l00IntField) { - this.l00IntField = l00IntField; - } - - public void setL00StringField(String l00StringField) { - this.l00StringField = l00StringField; - } - - public void setL00L10Nested(TestParametersL10 l00l10Nested) { - l00L10Nested = l00l10Nested; - } - - public void setL00LGenericNested(TestParametersLGeneric l00lGenericNested) { - l00LGenericNested = l00lGenericNested; - } - - public void setL00LGenericNestedMap(Map l00lGenericNestedMap) { - l00LGenericNestedMap = l00lGenericNestedMap; - } - - /** - * Trigger a validation message. - * - * @param triggerStatus Validation status to trigger - * @param level Number of levels to recurse before stopping - */ - public void triggerValidationStatus(final ValidationStatus triggerStatus, int level) { - if (level == 0) { - return; - } else { - level--; - } - - switch (triggerStatus) { - case CLEAN: - l00StringField = "Legal " + this.getClass().getName(); - l00IntField = 0; - break; - case OBSERVATION: - l00StringField = "aString"; - l00IntField = 2; - break; - case WARNING: - l00StringField = L00_STRING_FIELD; - l00IntField = 3; - break; - case INVALID: - l00StringField = ""; - l00IntField = -1; - break; - default: - break; - } - - l00L10Nested.triggerValidationStatus(triggerStatus, level); - l00LGenericNested.triggerValidationStatus(triggerStatus, level); - - for (TestParametersLGeneric nestedParameterGroup : l00LGenericNestedMap.values()) { - nestedParameterGroup.triggerValidationStatus(triggerStatus, level); - } - - } - - @Override - public GroupValidationResult validate() { - GroupValidationResult validationResult = super.validate(); - - if (StringUtils.isBlank(getName())) { - validationResult.setResult("name", ValidationStatus.INVALID, "name must be a non-blank string"); - } - - if (StringUtils.isBlank(l00StringField)) { - validationResult.setResult(L00_STRING_FIELD, ValidationStatus.INVALID, - "l00StringField must be a non-blank string"); - } else if (l00StringField.equals(L00_STRING_FIELD)) { - validationResult.setResult(L00_STRING_FIELD, ValidationStatus.WARNING, - "using the field name for the parameter value is dangerous"); - } else if (l00StringField.equals("aString")) { - validationResult.setResult(L00_STRING_FIELD, ValidationStatus.OBSERVATION, - "this value for name is unhelpful"); - } else { - validationResult.setResult(L00_STRING_FIELD, ValidationStatus.CLEAN, - ParameterConstants.PARAMETER_HAS_STATUS_MESSAGE + ValidationStatus.CLEAN.toString()); - } - - if (l00IntField < 0) { - validationResult.setResult(L00_INT_FIELD, ValidationStatus.INVALID, - "l00IntField must be a positive integer"); - } else if (l00IntField > 2) { - validationResult.setResult(L00_INT_FIELD, ValidationStatus.WARNING, - "values greater than 2 are not recommended"); - } else if (l00IntField == 2) { - validationResult.setResult(L00_INT_FIELD, ValidationStatus.OBSERVATION, "this field has been set to 2"); - } else { - validationResult.setResult(L00_INT_FIELD, ValidationStatus.CLEAN, - ParameterConstants.PARAMETER_HAS_STATUS_MESSAGE + ValidationStatus.CLEAN.toString()); - } - - validationResult.setResult("l00L10Nested", l00L10Nested.validate()); - validationResult.setResult("l00LGenericNested", l00LGenericNested.validate()); - - for (Entry nestedGroupEntry : l00LGenericNestedMap.entrySet()) { - validationResult.setResult("l00LGenericNestedMap", nestedGroupEntry.getKey(), - nestedGroupEntry.getValue().validate()); - } - - return validationResult; - } -} diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersL10.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersL10.java deleted file mode 100644 index bd2cf101..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersL10.java +++ /dev/null @@ -1,188 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. - * ================================================================================ - * 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 java.util.LinkedHashMap; -import java.util.Map; -import java.util.Map.Entry; -import org.apache.commons.lang3.StringUtils; -import org.onap.policy.common.parameters.GroupValidationResult; -import org.onap.policy.common.parameters.ParameterConstants; -import org.onap.policy.common.parameters.ParameterGroupImpl; -import org.onap.policy.common.parameters.ValidationStatus; - -public class TestParametersL10 extends ParameterGroupImpl { - private static final String L10_INT_FIELD = "l10IntField"; - private static final String L10_STRING_FIELD = "l10StringField"; - - private int l10IntField = 0; - private String l10StringField = "Legal " + this.getClass().getName(); - private TestParametersLGeneric l10LGenericNested0 = new TestParametersLGeneric("l10LGenericNested0"); - private TestParametersLGeneric l10LGenericNested1 = new TestParametersLGeneric("l10LGenericNested1"); - private Map l10LGenericNestedMap = new LinkedHashMap<>(); - - /** - * Default constructor. - */ - public TestParametersL10() { - // Default Constructor - } - - /** - * Create a test parameter group. - * - * @param name the parameter group name - */ - public TestParametersL10(final String name) { - super(name); - - TestParametersLGeneric l10LGenericNestedMapVal0 = new TestParametersLGeneric("l10LGenericNestedMapVal0"); - l10LGenericNestedMap.put(l10LGenericNestedMapVal0.getName(), l10LGenericNestedMapVal0); - TestParametersLGeneric l10LGenericNestedMapVal1 = new TestParametersLGeneric("l10LGenericNestedMapVal1"); - l10LGenericNestedMap.put(l10LGenericNestedMapVal1.getName(), l10LGenericNestedMapVal1); - } - - public int getL10IntField() { - return l10IntField; - } - - public String getL10StringField() { - return l10StringField; - } - - public TestParametersLGeneric getL10LGenericNested0() { - return l10LGenericNested0; - } - - public TestParametersLGeneric getL10LGenericNested1() { - return l10LGenericNested1; - } - - public Map getL10LGenericNestedMap() { - return l10LGenericNestedMap; - } - - public void setL10IntField(int l10IntField) { - this.l10IntField = l10IntField; - } - - public void setL10StringField(String l10StringField) { - this.l10StringField = l10StringField; - } - - public void setL10LGenericNested0(TestParametersLGeneric l10lGenericNested0) { - l10LGenericNested0 = l10lGenericNested0; - } - - public void setL10LGenericNested1(TestParametersLGeneric l10lGenericNested1) { - l10LGenericNested1 = l10lGenericNested1; - } - - public void setL10LGenericNestedMap(Map l10lGenericNestedMap) { - l10LGenericNestedMap = l10lGenericNestedMap; - } - - /** - * Trigger a validation message. - * - * @param level Number of levels to recurse before stopping - */ - public void triggerValidationStatus(final ValidationStatus triggerStatus, int level) { - if (level == 0) { - return; - } else { - level--; - } - - switch (triggerStatus) { - case CLEAN: - l10StringField = "Legal " + this.getClass().getName(); - l10IntField = 0; - break; - case OBSERVATION: - l10StringField = "aString"; - l10IntField = 2; - break; - case WARNING: - l10StringField = L10_STRING_FIELD; - l10IntField = 3; - break; - case INVALID: - l10StringField = ""; - l10IntField = -1; - break; - default: - break; - } - - l10LGenericNested0.triggerValidationStatus(triggerStatus, level); - l10LGenericNested1.triggerValidationStatus(triggerStatus, level); - - for (TestParametersLGeneric nestedParameterGroup : l10LGenericNestedMap.values()) { - nestedParameterGroup.triggerValidationStatus(triggerStatus, level); - } - } - - @Override - public GroupValidationResult validate() { - GroupValidationResult validationResult = super.validate(); - - if (StringUtils.isBlank(l10StringField)) { - validationResult.setResult(L10_STRING_FIELD, ValidationStatus.INVALID, - "l10StringField must be a non-blank string"); - } else if (l10StringField.equals(L10_STRING_FIELD)) { - validationResult.setResult(L10_STRING_FIELD, ValidationStatus.WARNING, - "using the field name for the parameter value is dangerous"); - } else if (l10StringField.equals("aString")) { - validationResult.setResult(L10_STRING_FIELD, ValidationStatus.OBSERVATION, - "this value for name is unhelpful"); - } else { - validationResult.setResult(L10_STRING_FIELD, ValidationStatus.CLEAN, - ParameterConstants.PARAMETER_HAS_STATUS_MESSAGE + ValidationStatus.CLEAN.toString()); - } - - if (l10IntField < 0) { - validationResult.setResult(L10_INT_FIELD, ValidationStatus.INVALID, - "l10IntField must be a positive integer"); - } else if (l10IntField > 2) { - validationResult.setResult(L10_INT_FIELD, ValidationStatus.WARNING, - "values greater than 2 are not recommended"); - } else if (l10IntField == 2) { - validationResult.setResult(L10_INT_FIELD, ValidationStatus.OBSERVATION, "this field has been set to 2"); - } else { - validationResult.setResult(L10_INT_FIELD, ValidationStatus.CLEAN, - ParameterConstants.PARAMETER_HAS_STATUS_MESSAGE + ValidationStatus.CLEAN.toString()); - } - - if (l10LGenericNested0 != null) { - validationResult.setResult("l10LGenericNested0", l10LGenericNested0.validate()); - } - validationResult.setResult("l10LGenericNested1", l10LGenericNested1.validate()); - - for (Entry nestedGroupEntry : l10LGenericNestedMap.entrySet()) { - validationResult.setResult("l10LGenericNestedMap", nestedGroupEntry.getKey(), - nestedGroupEntry.getValue().validate()); - } - - return validationResult; - } -} diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersLGeneric.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersLGeneric.java deleted file mode 100644 index f9d6cdc4..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersLGeneric.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * 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.ParameterGroupImpl; -import org.onap.policy.common.parameters.ValidationStatus; -import org.onap.policy.common.parameters.annotations.NotBlank; -import org.onap.policy.common.parameters.annotations.NotNull; - -public class TestParametersLGeneric extends ParameterGroupImpl { - private static final String LGENERIC_INT_FIELD = "lgenericIntField"; - private static final String LGENERIC_STRING_FIELD = "lgenericStringField"; - - private int lgenericIntField = 0; - - @NotNull @NotBlank - private String lgenericStringField = "Legal " + this.getClass().getName(); - - /** - * Default constructor. - */ - public TestParametersLGeneric() { - // Default Constructor - } - - /** - * Create a test parameter group. - * - * @param name the parameter group name - */ - public TestParametersLGeneric(final String name) { - super(name); - } - - public int getLgenericIntField() { - return lgenericIntField; - } - - public String getLgenericStringField() { - return lgenericStringField; - } - - public void setLgenericIntField(int lgenericIntField) { - this.lgenericIntField = lgenericIntField; - } - - public void setLgenericStringField(String lgenericStringField) { - this.lgenericStringField = lgenericStringField; - } - - /** - * Trigger a validation message. - * - * @param level Number of levels to recurse before stopping - */ - public void triggerValidationStatus(final ValidationStatus triggerStatus, int level) { - if (level == 0) { - return; - } - - switch (triggerStatus) { - case CLEAN: - lgenericStringField = "Legal " + this.getClass().getName(); - lgenericIntField = 0; - break; - case OBSERVATION: - lgenericStringField = "aString"; - lgenericIntField = 2; - break; - case WARNING: - lgenericStringField = LGENERIC_STRING_FIELD; - lgenericIntField = 3; - break; - case INVALID: - lgenericStringField = ""; - lgenericIntField = -1; - break; - default: - break; - } - - } - - @Override - public GroupValidationResult validate() { - GroupValidationResult validationResult = super.validate(); - - if (LGENERIC_STRING_FIELD.equals(lgenericStringField)) { - validationResult.setResult(LGENERIC_STRING_FIELD, ValidationStatus.WARNING, - "using the field name for the parameter value is dangerous"); - } else if ("aString".equals(lgenericStringField)) { - validationResult.setResult(LGENERIC_STRING_FIELD, ValidationStatus.OBSERVATION, - "this value for name is unhelpful"); - } - - if (lgenericIntField < 0) { - validationResult.setResult(LGENERIC_INT_FIELD, ValidationStatus.INVALID, - "lgenericIntField must be a positive integer"); - } else if (lgenericIntField > 2) { - validationResult.setResult(LGENERIC_INT_FIELD, ValidationStatus.WARNING, - "values greater than 2 are not recommended"); - } else if (lgenericIntField == 2) { - validationResult.setResult(LGENERIC_INT_FIELD, ValidationStatus.OBSERVATION, - "this field has been set to 2"); - } - - return validationResult; - } -} diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestJsonYamlValidationResult.txt b/common-parameters/src/test/resources/expectedValidationResults/TestJsonYamlValidationResult.txt deleted file mode 100644 index 64af7247..00000000 --- a/common-parameters/src/test/resources/expectedValidationResults/TestJsonYamlValidationResult.txt +++ /dev/null @@ -1,41 +0,0 @@ -parameter group "l00NameFromFile" type "org.onap.policy.common.parameters.testclasses.TestParametersL00" CLEAN, parameter group has status CLEAN - field "l00IntField" type "int" value "1" CLEAN, parameter has status CLEAN - field "l00StringField" type "java.lang.String" value "l00 string field value from file" CLEAN, parameter has status CLEAN - parameter group "l00L10NestedNameFromFile" type "org.onap.policy.common.parameters.testclasses.TestParametersL10" CLEAN, parameter group has status CLEAN - field "l10IntField" type "int" value "1" CLEAN, parameter has status CLEAN - field "l10StringField" type "java.lang.String" value "l00 L10 nested string field value from file" CLEAN, parameter has status CLEAN - parameter group "l10LGenericNested0NameFromFile" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN - field "lgenericIntField" type "int" value "1" CLEAN, parameter has status CLEAN - field "lgenericStringField" type "java.lang.String" value "l10 generic nested 0 string field value from file" CLEAN, parameter has status CLEAN - field "name" type "java.lang.String" value "l10LGenericNested0NameFromFile" CLEAN, parameter has status CLEAN - parameter group "l10LGenericNested1NameFromFile" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN - field "lgenericIntField" type "int" value "1" CLEAN, parameter has status CLEAN - field "lgenericStringField" type "java.lang.String" value "l10 generic nested 1 string field value from file" CLEAN, parameter has status CLEAN - field "name" type "java.lang.String" value "l10LGenericNested1NameFromFile" CLEAN, parameter has status CLEAN - parameter group map "l10LGenericNestedMap" CLEAN, parameter group map has status CLEAN - parameter group "L10Entry0Name" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN - field "lgenericIntField" type "int" value "1" CLEAN, parameter has status CLEAN - field "lgenericStringField" type "java.lang.String" value "L10Entry0 value from file" CLEAN, parameter has status CLEAN - field "name" type "java.lang.String" value "L10Entry0Name" CLEAN, parameter has status CLEAN - parameter group "L10Entry1Name" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN - field "lgenericIntField" type "int" value "1" CLEAN, parameter has status CLEAN - field "lgenericStringField" type "java.lang.String" value "L10Entry1 value from file" CLEAN, parameter has status CLEAN - field "name" type "java.lang.String" value "L10Entry1Name" CLEAN, parameter has status CLEAN - field "name" type "java.lang.String" value "l00L10NestedNameFromFile" CLEAN, parameter has status CLEAN - parameter group "l00GenericNestedNameFromFile" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN - field "lgenericIntField" type "int" value "1" CLEAN, parameter has status CLEAN - field "lgenericStringField" type "java.lang.String" value "l00 generic nested string field value from file" CLEAN, parameter has status CLEAN - field "name" type "java.lang.String" value "l00GenericNestedNameFromFile" CLEAN, parameter has status CLEAN - parameter group map "l00LGenericNestedMap" CLEAN, parameter group map has status CLEAN - parameter group "L00Entry0Name" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN - field "lgenericIntField" type "int" value "1" CLEAN, parameter has status CLEAN - field "lgenericStringField" type "java.lang.String" value "L00Entry0 value from file" CLEAN, parameter has status CLEAN - field "name" type "java.lang.String" value "L00Entry0Name" CLEAN, parameter has status CLEAN - parameter group "L00Entry1Name" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN - field "lgenericIntField" type "int" value "1" CLEAN, parameter has status CLEAN - field "lgenericStringField" type "java.lang.String" value "L00Entry1 value from file" CLEAN, parameter has status CLEAN - field "name" type "java.lang.String" value "L00Entry1Name" CLEAN, parameter has status CLEAN - field "isSomeFlag" type "boolean" value "false" CLEAN, parameter has status CLEAN - field "someNonIsFlag" type "boolean" value "false" CLEAN, parameter has status CLEAN - field "name" type "java.lang.String" value "l00NameFromFile" CLEAN, parameter has status CLEAN - \ No newline at end of file diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_0_OK.txt b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_0_OK.txt deleted file mode 100644 index d6b43312..00000000 --- a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_0_OK.txt +++ /dev/null @@ -1,41 +0,0 @@ -parameter group "l0Parameters" type "org.onap.policy.common.parameters.testclasses.TestParametersL00" CLEAN, parameter group has status CLEAN - field "l00IntField" type "int" value "0" CLEAN, parameter has status CLEAN - field "l00StringField" type "java.lang.String" value "Legal org.onap.policy.common.parameters.testclasses.TestParametersL00" CLEAN, parameter has status CLEAN - parameter group "l00L10Nested" type "org.onap.policy.common.parameters.testclasses.TestParametersL10" CLEAN, parameter group has status CLEAN - field "l10IntField" type "int" value "0" CLEAN, parameter has status CLEAN - field "l10StringField" type "java.lang.String" value "Legal org.onap.policy.common.parameters.testclasses.TestParametersL10" CLEAN, parameter has status CLEAN - parameter group "l10LGenericNested0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN - field "lgenericIntField" type "int" value "0" CLEAN, parameter has status CLEAN - field "lgenericStringField" type "java.lang.String" value "Legal org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter has status CLEAN - field "name" type "java.lang.String" value "l10LGenericNested0" CLEAN, parameter has status CLEAN - parameter group "l10LGenericNested1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN - field "lgenericIntField" type "int" value "0" CLEAN, parameter has status CLEAN - field "lgenericStringField" type "java.lang.String" value "Legal org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter has status CLEAN - field "name" type "java.lang.String" value "l10LGenericNested1" CLEAN, parameter has status CLEAN - parameter group map "l10LGenericNestedMap" CLEAN, parameter group map has status CLEAN - parameter group "l10LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN - field "lgenericIntField" type "int" value "0" CLEAN, parameter has status CLEAN - field "lgenericStringField" type "java.lang.String" value "Legal org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter has status CLEAN - field "name" type "java.lang.String" value "l10LGenericNestedMapVal0" CLEAN, parameter has status CLEAN - parameter group "l10LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN - field "lgenericIntField" type "int" value "0" CLEAN, parameter has status CLEAN - field "lgenericStringField" type "java.lang.String" value "Legal org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter has status CLEAN - field "name" type "java.lang.String" value "l10LGenericNestedMapVal1" CLEAN, parameter has status CLEAN - field "name" type "java.lang.String" value "l00L10Nested" CLEAN, parameter has status CLEAN - parameter group "l00LGenericNested" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN - field "lgenericIntField" type "int" value "0" CLEAN, parameter has status CLEAN - field "lgenericStringField" type "java.lang.String" value "Legal org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter has status CLEAN - field "name" type "java.lang.String" value "l00LGenericNested" CLEAN, parameter has status CLEAN - parameter group map "l00LGenericNestedMap" CLEAN, parameter group map has status CLEAN - parameter group "l00LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN - field "lgenericIntField" type "int" value "0" CLEAN, parameter has status CLEAN - field "lgenericStringField" type "java.lang.String" value "Legal org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter has status CLEAN - field "name" type "java.lang.String" value "l00LGenericNestedMapVal0" CLEAN, parameter has status CLEAN - parameter group "l00LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN - field "lgenericIntField" type "int" value "0" CLEAN, parameter has status CLEAN - field "lgenericStringField" type "java.lang.String" value "Legal org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter has status CLEAN - field "name" type "java.lang.String" value "l00LGenericNestedMapVal1" CLEAN, parameter has status CLEAN - field "isSomeFlag" type "boolean" value "false" CLEAN, parameter has status CLEAN - field "someNonIsFlag" type "boolean" value "false" CLEAN, parameter has status CLEAN - field "name" type "java.lang.String" value "l0Parameters" CLEAN, parameter has status CLEAN - \ No newline at end of file diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_1_Invalid.txt b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_1_Invalid.txt deleted file mode 100644 index dcc3cee3..00000000 --- a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_1_Invalid.txt +++ /dev/null @@ -1,3 +0,0 @@ -parameter group "l0Parameters" type "org.onap.policy.common.parameters.testclasses.TestParametersL00" INVALID, parameter group has status INVALID - field "l00IntField" type "int" value "-1" INVALID, l00IntField must be a positive integer - field "l00StringField" type "java.lang.String" value "" INVALID, l00StringField must be a non-blank string diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_1_Observation.txt b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_1_Observation.txt deleted file mode 100644 index ae627926..00000000 --- a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_1_Observation.txt +++ /dev/null @@ -1,3 +0,0 @@ -parameter group "l0Parameters" type "org.onap.policy.common.parameters.testclasses.TestParametersL00" OBSERVATION, parameter group has status OBSERVATION - field "l00IntField" type "int" value "2" OBSERVATION, this field has been set to 2 - field "l00StringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_1_Warning.txt b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_1_Warning.txt deleted file mode 100644 index 14a65aa8..00000000 --- a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_1_Warning.txt +++ /dev/null @@ -1,3 +0,0 @@ -parameter group "l0Parameters" type "org.onap.policy.common.parameters.testclasses.TestParametersL00" WARNING, parameter group has status WARNING - field "l00IntField" type "int" value "3" WARNING, values greater than 2 are not recommended - field "l00StringField" type "java.lang.String" value "l00StringField" WARNING, using the field name for the parameter value is dangerous diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Invalid.txt b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Invalid.txt deleted file mode 100644 index 412a36c1..00000000 --- a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Invalid.txt +++ /dev/null @@ -1,16 +0,0 @@ -parameter group "l0Parameters" type "org.onap.policy.common.parameters.testclasses.TestParametersL00" INVALID, parameter group has status INVALID - field "l00IntField" type "int" value "-1" INVALID, l00IntField must be a positive integer - field "l00StringField" type "java.lang.String" value "" INVALID, l00StringField must be a non-blank string - parameter group "l00L10Nested" type "org.onap.policy.common.parameters.testclasses.TestParametersL10" INVALID, parameter group has status INVALID - field "l10IntField" type "int" value "-1" INVALID, l10IntField must be a positive integer - field "l10StringField" type "java.lang.String" value "" INVALID, l10StringField must be a non-blank string - parameter group "l00LGenericNested" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" INVALID, parameter group has status INVALID - field "lgenericIntField" type "int" value "-1" INVALID, lgenericIntField must be a positive integer - field "lgenericStringField" type "java.lang.String" value "" INVALID, must be a non-blank string - parameter group map "l00LGenericNestedMap" INVALID, parameter group map has status INVALID - parameter group "l00LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" INVALID, parameter group has status INVALID - field "lgenericIntField" type "int" value "-1" INVALID, lgenericIntField must be a positive integer - field "lgenericStringField" type "java.lang.String" value "" INVALID, must be a non-blank string - parameter group "l00LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" INVALID, parameter group has status INVALID - field "lgenericIntField" type "int" value "-1" INVALID, lgenericIntField must be a positive integer - field "lgenericStringField" type "java.lang.String" value "" INVALID, must be a non-blank string \ No newline at end of file diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Observation.txt b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Observation.txt deleted file mode 100644 index c1989226..00000000 --- a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Observation.txt +++ /dev/null @@ -1,16 +0,0 @@ -parameter group "l0Parameters" type "org.onap.policy.common.parameters.testclasses.TestParametersL00" OBSERVATION, parameter group has status OBSERVATION - field "l00IntField" type "int" value "2" OBSERVATION, this field has been set to 2 - field "l00StringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful - parameter group "l00L10Nested" type "org.onap.policy.common.parameters.testclasses.TestParametersL10" OBSERVATION, parameter group has status OBSERVATION - field "l10IntField" type "int" value "2" OBSERVATION, this field has been set to 2 - field "l10StringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful - parameter group "l00LGenericNested" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" OBSERVATION, parameter group has status OBSERVATION - field "lgenericIntField" type "int" value "2" OBSERVATION, this field has been set to 2 - field "lgenericStringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful - parameter group map "l00LGenericNestedMap" OBSERVATION, parameter group map has status OBSERVATION - parameter group "l00LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" OBSERVATION, parameter group has status OBSERVATION - field "lgenericIntField" type "int" value "2" OBSERVATION, this field has been set to 2 - field "lgenericStringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful - parameter group "l00LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" OBSERVATION, parameter group has status OBSERVATION - field "lgenericIntField" type "int" value "2" OBSERVATION, this field has been set to 2 - field "lgenericStringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Warning.txt b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Warning.txt deleted file mode 100644 index 380ded8f..00000000 --- a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Warning.txt +++ /dev/null @@ -1,16 +0,0 @@ -parameter group "l0Parameters" type "org.onap.policy.common.parameters.testclasses.TestParametersL00" WARNING, parameter group has status WARNING - field "l00IntField" type "int" value "3" WARNING, values greater than 2 are not recommended - field "l00StringField" type "java.lang.String" value "l00StringField" WARNING, using the field name for the parameter value is dangerous - parameter group "l00L10Nested" type "org.onap.policy.common.parameters.testclasses.TestParametersL10" WARNING, parameter group has status WARNING - field "l10IntField" type "int" value "3" WARNING, values greater than 2 are not recommended - field "l10StringField" type "java.lang.String" value "l10StringField" WARNING, using the field name for the parameter value is dangerous - parameter group "l00LGenericNested" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" WARNING, parameter group has status WARNING - field "lgenericIntField" type "int" value "3" WARNING, values greater than 2 are not recommended - field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous - parameter group map "l00LGenericNestedMap" WARNING, parameter group map has status WARNING - parameter group "l00LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" WARNING, parameter group has status WARNING - field "lgenericIntField" type "int" value "3" WARNING, values greater than 2 are not recommended - field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous - parameter group "l00LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" WARNING, parameter group has status WARNING - field "lgenericIntField" type "int" value "3" WARNING, values greater than 2 are not recommended - field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous \ No newline at end of file diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Invalid.txt b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Invalid.txt deleted file mode 100644 index 12bce5c3..00000000 --- a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Invalid.txt +++ /dev/null @@ -1,29 +0,0 @@ -parameter group "l0Parameters" type "org.onap.policy.common.parameters.testclasses.TestParametersL00" INVALID, parameter group has status INVALID - field "l00IntField" type "int" value "-1" INVALID, l00IntField must be a positive integer - field "l00StringField" type "java.lang.String" value "" INVALID, l00StringField must be a non-blank string - parameter group "l00L10Nested" type "org.onap.policy.common.parameters.testclasses.TestParametersL10" INVALID, parameter group has status INVALID - field "l10IntField" type "int" value "-1" INVALID, l10IntField must be a positive integer - field "l10StringField" type "java.lang.String" value "" INVALID, l10StringField must be a non-blank string - parameter group "l10LGenericNested0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" INVALID, parameter group has status INVALID - field "lgenericIntField" type "int" value "-1" INVALID, lgenericIntField must be a positive integer - field "lgenericStringField" type "java.lang.String" value "" INVALID, must be a non-blank string - parameter group "l10LGenericNested1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" INVALID, parameter group has status INVALID - field "lgenericIntField" type "int" value "-1" INVALID, lgenericIntField must be a positive integer - field "lgenericStringField" type "java.lang.String" value "" INVALID, must be a non-blank string - parameter group map "l10LGenericNestedMap" INVALID, parameter group map has status INVALID - parameter group "l10LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" INVALID, parameter group has status INVALID - field "lgenericIntField" type "int" value "-1" INVALID, lgenericIntField must be a positive integer - field "lgenericStringField" type "java.lang.String" value "" INVALID, must be a non-blank string - parameter group "l10LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" INVALID, parameter group has status INVALID - field "lgenericIntField" type "int" value "-1" INVALID, lgenericIntField must be a positive integer - field "lgenericStringField" type "java.lang.String" value "" INVALID, must be a non-blank string - parameter group "l00LGenericNested" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" INVALID, parameter group has status INVALID - field "lgenericIntField" type "int" value "-1" INVALID, lgenericIntField must be a positive integer - field "lgenericStringField" type "java.lang.String" value "" INVALID, must be a non-blank string - parameter group map "l00LGenericNestedMap" INVALID, parameter group map has status INVALID - parameter group "l00LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" INVALID, parameter group has status INVALID - field "lgenericIntField" type "int" value "-1" INVALID, lgenericIntField must be a positive integer - field "lgenericStringField" type "java.lang.String" value "" INVALID, must be a non-blank string - parameter group "l00LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" INVALID, parameter group has status INVALID - field "lgenericIntField" type "int" value "-1" INVALID, lgenericIntField must be a positive integer - field "lgenericStringField" type "java.lang.String" value "" INVALID, must be a non-blank string \ No newline at end of file diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Observation.txt b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Observation.txt deleted file mode 100644 index 36517cef..00000000 --- a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Observation.txt +++ /dev/null @@ -1,29 +0,0 @@ -parameter group "l0Parameters" type "org.onap.policy.common.parameters.testclasses.TestParametersL00" OBSERVATION, parameter group has status OBSERVATION - field "l00IntField" type "int" value "2" OBSERVATION, this field has been set to 2 - field "l00StringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful - parameter group "l00L10Nested" type "org.onap.policy.common.parameters.testclasses.TestParametersL10" OBSERVATION, parameter group has status OBSERVATION - field "l10IntField" type "int" value "2" OBSERVATION, this field has been set to 2 - field "l10StringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful - parameter group "l10LGenericNested0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" OBSERVATION, parameter group has status OBSERVATION - field "lgenericIntField" type "int" value "2" OBSERVATION, this field has been set to 2 - field "lgenericStringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful - parameter group "l10LGenericNested1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" OBSERVATION, parameter group has status OBSERVATION - field "lgenericIntField" type "int" value "2" OBSERVATION, this field has been set to 2 - field "lgenericStringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful - parameter group map "l10LGenericNestedMap" OBSERVATION, parameter group map has status OBSERVATION - parameter group "l10LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" OBSERVATION, parameter group has status OBSERVATION - field "lgenericIntField" type "int" value "2" OBSERVATION, this field has been set to 2 - field "lgenericStringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful - parameter group "l10LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" OBSERVATION, parameter group has status OBSERVATION - field "lgenericIntField" type "int" value "2" OBSERVATION, this field has been set to 2 - field "lgenericStringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful - parameter group "l00LGenericNested" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" OBSERVATION, parameter group has status OBSERVATION - field "lgenericIntField" type "int" value "2" OBSERVATION, this field has been set to 2 - field "lgenericStringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful - parameter group map "l00LGenericNestedMap" OBSERVATION, parameter group map has status OBSERVATION - parameter group "l00LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" OBSERVATION, parameter group has status OBSERVATION - field "lgenericIntField" type "int" value "2" OBSERVATION, this field has been set to 2 - field "lgenericStringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful - parameter group "l00LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" OBSERVATION, parameter group has status OBSERVATION - field "lgenericIntField" type "int" value "2" OBSERVATION, this field has been set to 2 - field "lgenericStringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Warning.txt b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Warning.txt deleted file mode 100644 index 28747670..00000000 --- a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Warning.txt +++ /dev/null @@ -1,29 +0,0 @@ -parameter group "l0Parameters" type "org.onap.policy.common.parameters.testclasses.TestParametersL00" WARNING, parameter group has status WARNING - field "l00IntField" type "int" value "3" WARNING, values greater than 2 are not recommended - field "l00StringField" type "java.lang.String" value "l00StringField" WARNING, using the field name for the parameter value is dangerous - parameter group "l00L10Nested" type "org.onap.policy.common.parameters.testclasses.TestParametersL10" WARNING, parameter group has status WARNING - field "l10IntField" type "int" value "3" WARNING, values greater than 2 are not recommended - field "l10StringField" type "java.lang.String" value "l10StringField" WARNING, using the field name for the parameter value is dangerous - parameter group "l10LGenericNested0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" WARNING, parameter group has status WARNING - field "lgenericIntField" type "int" value "3" WARNING, values greater than 2 are not recommended - field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous - parameter group "l10LGenericNested1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" WARNING, parameter group has status WARNING - field "lgenericIntField" type "int" value "3" WARNING, values greater than 2 are not recommended - field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous - parameter group map "l10LGenericNestedMap" WARNING, parameter group map has status WARNING - parameter group "l10LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" WARNING, parameter group has status WARNING - field "lgenericIntField" type "int" value "3" WARNING, values greater than 2 are not recommended - field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous - parameter group "l10LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" WARNING, parameter group has status WARNING - field "lgenericIntField" type "int" value "3" WARNING, values greater than 2 are not recommended - field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous - parameter group "l00LGenericNested" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" WARNING, parameter group has status WARNING - field "lgenericIntField" type "int" value "3" WARNING, values greater than 2 are not recommended - field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous - parameter group map "l00LGenericNestedMap" WARNING, parameter group map has status WARNING - parameter group "l00LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" WARNING, parameter group has status WARNING - field "lgenericIntField" type "int" value "3" WARNING, values greater than 2 are not recommended - field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous - parameter group "l00LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" WARNING, parameter group has status WARNING - field "lgenericIntField" type "int" value "3" WARNING, values greater than 2 are not recommended - field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous \ No newline at end of file -- cgit 1.2.3-korg