diff options
Diffstat (limited to 'common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses')
14 files changed, 0 insertions, 987 deletions
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<Integer> 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<Integer> 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<Integer, ParameterGroup> 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<Integer, ParameterGroup> 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<String, Integer> 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<String, Integer> 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<Integer> nullList = null; - - /** - * Create a test parameter group. - * @param name the parameter group name - */ - public ParameterGroupWithNullCollection(final String name) { - super(name); - } - - public List<Integer> 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<String, Integer> nullMap = null; - - /** - * Create a test parameter group. - * @param name the parameter group name - */ - public ParameterGroupWithNullMapValue(final String name) { - super(name); - } - - public Map<String, Integer> 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<ParameterGroup> 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<ParameterGroup> 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<String, TestParametersLGeneric> 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<String, TestParametersLGeneric> 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<String, TestParametersLGeneric> 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<String, TestParametersLGeneric> 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 7276b504..00000000 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersL10.java +++ /dev/null @@ -1,189 +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<String, TestParametersLGeneric> 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<String, TestParametersLGeneric> 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<String, TestParametersLGeneric> 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<String, TestParametersLGeneric> 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; - } -} |