diff options
Diffstat (limited to 'common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersLGeneric.java')
-rw-r--r-- | common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersLGeneric.java | 53 |
1 files changed, 19 insertions, 34 deletions
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 index 2d263fc7..2fc04180 100644 --- 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 @@ -1,19 +1,20 @@ -/*- +/* * ============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========================================================= */ @@ -21,29 +22,31 @@ package org.onap.policy.common.parameters.testclasses; import org.onap.policy.common.parameters.GroupValidationResult; -import org.onap.policy.common.parameters.ParameterConstants; -import org.onap.policy.common.parameters.ParameterGroup; +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 implements ParameterGroup { - private String name; +public class TestParametersLGeneric extends ParameterGroupImpl { private int lgenericIntField = 0; + + @NotNull @NotBlank private String lgenericStringField = "Legal " + this.getClass().getCanonicalName(); - + /** * Default constructor. */ public TestParametersLGeneric() { // Default Constructor } - + /** * Create a test parameter group. - * + * * @param name the parameter group name */ public TestParametersLGeneric(final String name) { - this.name = name; + super(name); } public int getLgenericIntField() { @@ -54,10 +57,6 @@ public class TestParametersLGeneric implements ParameterGroup { return lgenericStringField; } - public void setName(String name) { - this.name = name; - } - public void setLgenericIntField(int lgenericIntField) { this.lgenericIntField = lgenericIntField; } @@ -68,7 +67,7 @@ public class TestParametersLGeneric implements ParameterGroup { /** * Trigger a validation message. - * + * * @param level Number of levels to recurse before stopping */ public void triggerValidationStatus(final ValidationStatus triggerStatus, int level) { @@ -103,26 +102,15 @@ public class TestParametersLGeneric implements ParameterGroup { } @Override - public String getName() { - return this.name; - } - - @Override public GroupValidationResult validate() { - GroupValidationResult validationResult = new GroupValidationResult(this); + GroupValidationResult validationResult = super.validate(); - if (lgenericStringField == null || lgenericStringField.trim().length() == 0) { - validationResult.setResult("lgenericStringField", ValidationStatus.INVALID, - "lgenericStringField must be a non-blank string"); - } else if (lgenericStringField.equals("lgenericStringField")) { + if ("lgenericStringField".equals(lgenericStringField)) { validationResult.setResult("lgenericStringField", ValidationStatus.WARNING, "using the field name for the parameter value is dangerous"); - } else if (lgenericStringField.equals("aString")) { + } else if ("aString".equals(lgenericStringField)) { validationResult.setResult("lgenericStringField", ValidationStatus.OBSERVATION, "this value for name is unhelpful"); - } else { - validationResult.setResult("lgenericStringField", ValidationStatus.CLEAN, - ParameterConstants.PARAMETER_HAS_STATUS_MESSAGE + ValidationStatus.CLEAN.toString()); } if (lgenericIntField < 0) { @@ -134,9 +122,6 @@ public class TestParametersLGeneric implements ParameterGroup { } else if (lgenericIntField == 2) { validationResult.setResult("lgenericIntField", ValidationStatus.OBSERVATION, "this field has been set to 2"); - } else { - validationResult.setResult("lgenericIntField", ValidationStatus.CLEAN, - ParameterConstants.PARAMETER_HAS_STATUS_MESSAGE + ValidationStatus.CLEAN.toString()); } return validationResult; |