summaryrefslogtreecommitdiffstats
path: root/common-parameters/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'common-parameters/src/test')
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/ExceptionTest.java3
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/TestAbstractParameters.java8
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/TestJsonInput.java62
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/TestParameterService.java57
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidation.java183
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationErrors.java105
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResults.java147
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/TestYamlInput.java59
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/EmptyParameterGroup.java (renamed from common-parameters/src/test/java/org/onap/policy/common/parameters/LegalParameters.java)27
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithArray.java47
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithCollection.java58
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapKey.java59
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapValue.java58
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullCollection.java53
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullMapValue.java53
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithParameterGroupCollection.java58
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersL00.java177
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersL10.java173
-rw-r--r--common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersLGeneric.java135
-rw-r--r--common-parameters/src/test/resources/expectedValidationResults/TestJsonYamlValidationResult.txt39
-rw-r--r--common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_0_OK.txt39
-rw-r--r--common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_1_Invalid.txt3
-rw-r--r--common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_1_Observation.txt3
-rw-r--r--common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_1_Warning.txt3
-rw-r--r--common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Invalid.txt9
-rw-r--r--common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Observation.txt9
-rw-r--r--common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Warning.txt9
-rw-r--r--common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Invalid.txt15
-rw-r--r--common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Observation.txt15
-rw-r--r--common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Warning.txt15
-rw-r--r--common-parameters/src/test/resources/parameters/TestParameters.json49
-rw-r--r--common-parameters/src/test/resources/parameters/TestParameters.yaml37
32 files changed, 1732 insertions, 35 deletions
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/ExceptionTest.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/ExceptionTest.java
index 510b6e36..b65db953 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/ExceptionTest.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/ExceptionTest.java
@@ -1,4 +1,4 @@
-/*
+/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* ================================================================================
@@ -17,6 +17,7 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.common.parameters;
import static org.junit.Assert.assertEquals;
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
index f8003cfe..b568d7fb 100644
--- 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
@@ -20,16 +20,16 @@
package org.onap.policy.common.parameters;
-import static org.junit.Assert.assertEquals;
+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 LegalParameters parameters = new LegalParameters();
- assertEquals(LegalParameters.class, parameters.getParameterClass());
- assertEquals("org.onap.policy.common.parameters.LegalParameters", parameters.getParameterClassName());
+ final EmptyParameterGroup parameters = new EmptyParameterGroup("Empty Group");
+ assertTrue(parameters.isValid());
}
}
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
new file mode 100644
index 00000000..6d0aae5e
--- /dev/null
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestJsonInput.java
@@ -0,0 +1,62 @@
+/*-
+ * ============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.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+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 com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+public class TestJsonInput {
+
+ @Test
+ public void testJsonInput() throws IOException {
+ TestParametersL00 testParameterGroup = null;
+
+ // Read the parameters
+ try {
+ // 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);
+ } catch (final Exception e) {
+ fail("test should not throw an exception here: " + e.getMessage());
+ }
+
+ 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
index efd3e304..0b7e46ca 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestParameterService.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestParameterService.java
@@ -27,6 +27,9 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Test;
+import org.onap.policy.common.parameters.ParameterRuntimeException;
+import org.onap.policy.common.parameters.ParameterService;
+import org.onap.policy.common.parameters.testclasses.EmptyParameterGroup;
public class TestParameterService {
@@ -34,47 +37,57 @@ public class TestParameterService {
public void testParameterService() {
ParameterService.clear();
- assertFalse(ParameterService.existsParameters(LegalParameters.class));
+ assertFalse(ParameterService.contains("EmptyGroup"));
try {
- ParameterService.getParameters(LegalParameters.class);
+ ParameterService.get("EmptyGroup");
fail("Test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "Parameters for org.onap.policy.common.parameters.LegalParameters not found in parameter service",
- e.getMessage());
+ assertEquals("\"EmptyGroup\" not found in parameter service", e.getMessage());
}
- ParameterService.registerParameters(new LegalParameters());
- assertTrue(ParameterService.existsParameters(LegalParameters.class));
- assertNotNull(ParameterService.getParameters(LegalParameters.class));
+ ParameterService.register(new EmptyParameterGroup("Empty Group"));
+ assertTrue(ParameterService.contains("Empty Group"));
+ assertNotNull(ParameterService.get("Empty Group"));
+
+ try {
+ ParameterService.register(new EmptyParameterGroup("Empty Group"));
+ fail("this test should throw an exception");
+ }
+ catch (ParameterRuntimeException e) {
+ assertEquals("\"Empty Group\" already registered in parameter service", e.getMessage());
+ }
+
+ ParameterService.deregister("Empty Group");
+ assertFalse(ParameterService.contains("Empty Group"));
- ParameterService.deregisterParameters(LegalParameters.class);
+ try {
+ ParameterService.deregister("Empty Group");
+ fail("this test should throw an exception");
+ }
+ catch (ParameterRuntimeException e) {
+ assertEquals("\"Empty Group\" not registered in parameter service", e.getMessage());
+ }
- assertFalse(ParameterService.existsParameters(LegalParameters.class));
try {
- ParameterService.getParameters(LegalParameters.class);
+ ParameterService.get("Empty Group");
fail("Test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "Parameters for org.onap.policy.common.parameters.LegalParameters not found in parameter service",
- e.getMessage());
+ assertEquals("\"Empty Group\" not found in parameter service", e.getMessage());
}
- ParameterService.registerParameters(new LegalParameters());
- assertTrue(ParameterService.existsParameters(LegalParameters.class));
- assertNotNull(ParameterService.getParameters(LegalParameters.class));
+ 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.existsParameters(LegalParameters.class));
+ assertFalse(ParameterService.contains("Empty Group"));
try {
- ParameterService.getParameters(LegalParameters.class);
+ ParameterService.get("Empty Group");
fail("Test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "Parameters for org.onap.policy.common.parameters.LegalParameters not found in parameter service",
- e.getMessage());
+ assertEquals("\"Empty Group\" not found in parameter service", e.getMessage());
}
}
}
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
new file mode 100644
index 00000000..2ca24a05
--- /dev/null
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidation.java
@@ -0,0 +1,183 @@
+/*-
+ * ============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.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.testclasses.TestParametersL00;
+
+public class TestValidation {
+ @Test
+ public void testValidationOk() throws IOException {
+ TestParametersL00 l0Parameters = new TestParametersL00("l0Parameters");
+
+ GroupValidationResult validationResult = l0Parameters.validate();
+ assertTrue(validationResult.isValid());
+ 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("l0Parameters");
+
+ 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());
+ 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("l0Parameters");
+
+ 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("l0Parameters");
+
+ 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());
+ }
+}
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
new file mode 100644
index 00000000..6b781472
--- /dev/null
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationErrors.java
@@ -0,0 +1,105 @@
+/*-
+ * ============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.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+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.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");
+ try {
+ illegalCollection.isValid();
+ fail("test should throw an exception");
+ } catch (ParameterRuntimeException e) {
+ assertEquals("collection parameter \"parameterGroupArrayList\" is illegal,"
+ + " parameter groups are not allowed as collection members", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testNullCollection() {
+ ParameterGroupWithNullCollection nullCollection = new ParameterGroupWithNullCollection("Null Collection");
+
+ try {
+ nullCollection.isValid();
+ fail("test should throw an exception");
+ } catch (ParameterRuntimeException e) {
+ assertEquals("collection parameter \"nullList\" is null", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testMapNullValueValidation() {
+ ParameterGroupWithNullMapValue nullMap = new ParameterGroupWithNullMapValue("Null Map value");
+ try {
+ nullMap.isValid();
+ fail("test should throw an exception");
+ } catch (ParameterRuntimeException e) {
+ assertEquals("map parameter \"nullMap\" is null", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testBadMapKeyValidation() {
+ ParameterGroupWithIllegalMapKey illegalMap = new ParameterGroupWithIllegalMapKey("Illegal Map");
+ try {
+ illegalMap.isValid();
+ fail("test should throw an exception");
+ } catch (ParameterRuntimeException e) {
+ assertEquals("map entry is not a parameter group keyed by a string, key \"1\" "
+ + "in map \"badMap\" is not a string", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testBadMapValueValidation() {
+ ParameterGroupWithIllegalMapValue illegalMap = new ParameterGroupWithIllegalMapValue("Illegal Map");
+ try {
+ illegalMap.isValid();
+ fail("test should throw an exception");
+ } catch (ParameterRuntimeException e) {
+ assertEquals("map entry is not a parameter group keyed by a string, value \"1\" in "
+ + "map \"intMap\" is not a parameter group", e.getMessage());
+ }
+ }
+}
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
new file mode 100644
index 00000000..8f22765b
--- /dev/null
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestValidationResults.java
@@ -0,0 +1,147 @@
+/*-
+ * ============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.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+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 Map<String, ParameterGroup> 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, SecurityException {
+ GroupMapValidationResult result = new GroupMapValidationResult(this.getClass().getDeclaredField("pgMap"),
+ pgMap);
+
+ assertTrue(result.isValid());
+ assertEquals("pgMap", 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());
+
+ try {
+ result.setResult("nonExistantEntry", new GroupValidationResult(pgMap.get("entry0")));
+ fail("test shold throw an exception here");
+ } catch (Exception e) {
+ assertEquals("no entry with name \"nonExistantEntry\" exists", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testGroupValidationResult() throws NoSuchFieldException, SecurityException {
+ 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());
+
+ try {
+ result.setResult("nonExistantParameter", ValidationStatus.OBSERVATION, "Something was observed");
+ fail("test shold throw an exception here");
+ } catch (Exception e) {
+ assertEquals("no regular parameter field exists for parameter: nonExistantParameter", e.getMessage());
+ }
+
+ try {
+ result.setResult("l10LGenericNestedMap", ValidationStatus.OBSERVATION, "Something was observed");
+ fail("test shold throw an exception here");
+ } catch (Exception e) {
+ assertEquals("parameter not a regular parameter: l10LGenericNestedMap", e.getMessage());
+ }
+
+ try {
+ result.setResult("nonExistantParameter", new GroupValidationResult(pg));
+ fail("test shold throw an exception here");
+ } catch (Exception e) {
+ assertEquals("no nested parameter field exists for parameter: nonExistantParameter", e.getMessage());
+ }
+
+ try {
+ result.setResult("l10IntField", new GroupValidationResult(pg));
+ fail("test shold throw an exception here");
+ } catch (Exception e) {
+ assertEquals("parameter is not a nested group parameter: l10IntField", e.getMessage());
+ }
+
+ GroupMapValidationResult groupMapResult = new GroupMapValidationResult(
+ this.getClass().getDeclaredField("pgMap"), pgMap);
+
+ try {
+ result.setResult("nonExistantParameter", "entry0", groupMapResult);
+ fail("test shold throw an exception here");
+ } catch (Exception e) {
+ assertEquals("no group map parameter field exists for parameter: nonExistantParameter", e.getMessage());
+ }
+
+ try {
+ result.setResult("l10IntField", "entry0", groupMapResult);
+ fail("test shold throw an exception here");
+ } catch (Exception e) {
+ assertEquals("parameter is not a nested group map parameter: l10IntField", e.getMessage());
+ }
+ }
+}
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
new file mode 100644
index 00000000..7d803525
--- /dev/null
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestYamlInput.java
@@ -0,0 +1,59 @@
+/*-
+ * ============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.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+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
+ try {
+ // 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);
+ } catch (final Exception e) {
+ fail("test should not throw an exception here: " + e.getMessage());
+ }
+
+ 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/LegalParameters.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/EmptyParameterGroup.java
index fb1bd478..f545ce65 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/LegalParameters.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/EmptyParameterGroup.java
@@ -1,4 +1,4 @@
-/*
+/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* ================================================================================
@@ -18,14 +18,25 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.common.parameters;
+package org.onap.policy.common.parameters.testclasses;
-import org.onap.policy.common.parameters.AbstractParameters;
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.GroupValidationResult;
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class LegalParameters implements AbstractParameters {
- public LegalParameters() {
+public class EmptyParameterGroup implements ParameterGroup {
+ private String name;
+
+ public EmptyParameterGroup(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
}
}
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithArray.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithArray.java
new file mode 100644
index 00000000..cdab1272
--- /dev/null
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithArray.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.parameters.testclasses;
+
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.GroupValidationResult;
+
+public class ParameterGroupWithArray implements ParameterGroup {
+ private String name;
+ private int[] intArray = {1, 2, 3};
+
+ public ParameterGroupWithArray(final String name) {
+ this.name = name;
+ }
+
+ public int[] getIntArray() {
+ return intArray;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
+ }
+}
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithCollection.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithCollection.java
new file mode 100644
index 00000000..0f993099
--- /dev/null
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithCollection.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.parameters.testclasses;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.GroupValidationResult;
+
+public class ParameterGroupWithCollection implements ParameterGroup {
+ private String name;
+ private List<Integer> intArrayList = new ArrayList<>();
+
+ /**
+ * Create a test parameter group.
+ * @param name the parameter group name
+ */
+ public ParameterGroupWithCollection(final String name) {
+ this.name = name;
+
+ intArrayList.add(1);
+ intArrayList.add(2);
+ intArrayList.add(3);
+ }
+
+ public List<Integer> getIntArrayList() {
+ return intArrayList;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
+ }
+}
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapKey.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapKey.java
new file mode 100644
index 00000000..3de3270e
--- /dev/null
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapKey.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.parameters.testclasses;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.GroupValidationResult;
+
+public class ParameterGroupWithIllegalMapKey implements ParameterGroup {
+ private String name;
+ private Map<Integer, ParameterGroup> badMap = new LinkedHashMap<>();
+
+ /**
+ * Create a test parameter group.
+ * @param name the parameter group name
+ */
+ public ParameterGroupWithIllegalMapKey(final String name) {
+ this.name = 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;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
+ }
+
+}
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapValue.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapValue.java
new file mode 100644
index 00000000..8eb697a4
--- /dev/null
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithIllegalMapValue.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.parameters.testclasses;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.GroupValidationResult;
+
+public class ParameterGroupWithIllegalMapValue implements ParameterGroup {
+ private String name;
+ private Map<String, Integer> intMap = new LinkedHashMap<>();
+
+ /**
+ * Create a test parameter group.
+ * @param name the parameter group name
+ */
+ public ParameterGroupWithIllegalMapValue(final String name) {
+ this.name = name;
+
+ intMap.put("One", 1);
+ intMap.put("Two", 2);
+ intMap.put("Three", 3);
+ }
+
+ public Map<String, Integer> getIntMap() {
+ return intMap;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
+ }
+}
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullCollection.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullCollection.java
new file mode 100644
index 00000000..37399da3
--- /dev/null
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullCollection.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.parameters.testclasses;
+
+import java.util.List;
+
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.GroupValidationResult;
+
+public class ParameterGroupWithNullCollection implements ParameterGroup {
+ private String name;
+ private List<Integer> nullList = null;
+
+ /**
+ * Create a test parameter group.
+ * @param name the parameter group name
+ */
+ public ParameterGroupWithNullCollection(final String name) {
+ this.name = name;
+ }
+
+ public List<Integer> getNullList() {
+ return nullList;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
+ }
+}
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullMapValue.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullMapValue.java
new file mode 100644
index 00000000..80f55355
--- /dev/null
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithNullMapValue.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.parameters.testclasses;
+
+import java.util.Map;
+
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.GroupValidationResult;
+
+public class ParameterGroupWithNullMapValue implements ParameterGroup {
+ private String name;
+ private Map<String, Integer> nullMap = null;
+
+ /**
+ * Create a test parameter group.
+ * @param name the parameter group name
+ */
+ public ParameterGroupWithNullMapValue(final String name) {
+ this.name = name;
+ }
+
+ public Map<String, Integer> getNullMap() {
+ return nullMap;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
+ }
+}
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithParameterGroupCollection.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithParameterGroupCollection.java
new file mode 100644
index 00000000..e7d1de75
--- /dev/null
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/ParameterGroupWithParameterGroupCollection.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.parameters.testclasses;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.GroupValidationResult;
+
+public class ParameterGroupWithParameterGroupCollection implements ParameterGroup {
+ private String name;
+ private List<ParameterGroup> parameterGroupArrayList = new ArrayList<>();
+
+ /**
+ * Create a test parameter group.
+ * @param name the parameter group name
+ */
+ public ParameterGroupWithParameterGroupCollection(final String name) {
+ this.name = name;
+
+ parameterGroupArrayList.add(new TestParametersLGeneric("Generic0"));
+ parameterGroupArrayList.add(new TestParametersLGeneric("Generic1"));
+ parameterGroupArrayList.add(new TestParametersLGeneric("Generic2"));
+ }
+
+ public List<ParameterGroup> getIntArrayList() {
+ return parameterGroupArrayList;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
+ }
+}
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
new file mode 100644
index 00000000..6b8460cd
--- /dev/null
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersL00.java
@@ -0,0 +1,177 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.parameters.testclasses;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterConstants;
+import org.onap.policy.common.parameters.ValidationStatus;
+
+public class TestParametersL00 implements ParameterGroup {
+ private String name;
+ private int l00IntField = 0;
+ private String l00StringField = "Legal " + this.getClass().getCanonicalName();
+ private TestParametersL10 l00L10Nested = new TestParametersL10("l00L10Nested");
+ private TestParametersLGeneric l00LGenericNested = new TestParametersLGeneric("l00LGenericNested");
+ private Map<String, TestParametersLGeneric> l00LGenericNestedMap = new LinkedHashMap<>();
+
+ /**
+ * Default constructor
+ */
+ public TestParametersL00() {
+ }
+
+ /**
+ * Create a test parameter group.
+ *
+ * @param name the parameter group name
+ */
+ public TestParametersL00(final String name) {
+ this.name = name;
+
+ TestParametersLGeneric l00LGenericNestedMapVal0 = new TestParametersLGeneric("l00LGenericNestedMapVal0");
+ l00LGenericNestedMap.put(l00LGenericNestedMapVal0.getName(), l00LGenericNestedMapVal0);
+ TestParametersLGeneric l00LGenericNestedMapVal1 = new TestParametersLGeneric("l00LGenericNestedMapVal1");
+ l00LGenericNestedMap.put(l00LGenericNestedMapVal1.getName(), l00LGenericNestedMapVal1);
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ 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().getCanonicalName();
+ l00IntField = 0;
+ break;
+ case OBSERVATION:
+ l00StringField = "aString";
+ l00IntField = 2;
+ break;
+ case WARNING:
+ l00StringField = "l00StringField";
+ 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 String getName() {
+ return name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ GroupValidationResult validationResult = new GroupValidationResult(this);
+
+ if (name == null || name.trim().length() == 0) {
+ validationResult.setResult("name", ValidationStatus.INVALID, "name must be a non-blank string");
+ }
+
+ if (l00StringField == null || l00StringField.trim().length() == 0) {
+ validationResult.setResult("l00StringField", ValidationStatus.INVALID,
+ "l00StringField must be a non-blank string");
+ } else if (l00StringField.equals("l00StringField")) {
+ validationResult.setResult("l00StringField", ValidationStatus.WARNING,
+ "using the field name for the parameter value is dangerous");
+ } else if (l00StringField.equals("aString")) {
+ validationResult.setResult("l00StringField", ValidationStatus.OBSERVATION,
+ "this value for name is unhelpful");
+ } else {
+ validationResult.setResult("l00StringField", ValidationStatus.CLEAN,
+ ParameterConstants.PARAMETER_HAS_STATUS_MESSAGE + ValidationStatus.CLEAN.toString());
+ }
+
+ if (l00IntField < 0) {
+ validationResult.setResult("l00IntField", ValidationStatus.INVALID,
+ "l00IntField must be a positive integer");
+ } else if (l00IntField > 2) {
+ validationResult.setResult("l00IntField", ValidationStatus.WARNING,
+ "values greater than 2 are not recommended");
+ } else if (l00IntField == 2) {
+ validationResult.setResult("l00IntField", ValidationStatus.OBSERVATION, "this field has been set to 2");
+ } else {
+ validationResult.setResult("l00IntField", 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
new file mode 100644
index 00000000..94a67ec7
--- /dev/null
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersL10.java
@@ -0,0 +1,173 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.parameters.testclasses;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterConstants;
+import org.onap.policy.common.parameters.ValidationStatus;
+
+public class TestParametersL10 implements ParameterGroup {
+ private String name;
+ private int l10IntField = 0;
+ private String l10StringField = "Legal " + this.getClass().getCanonicalName();
+ private TestParametersLGeneric l10LGenericNested0 = new TestParametersLGeneric("l10LGenericNested0");
+ private TestParametersLGeneric l10LGenericNested1 = new TestParametersLGeneric("l10LGenericNested1");
+ private Map<String, TestParametersLGeneric> l10LGenericNestedMap = new LinkedHashMap<>();
+
+ /**
+ * Default constructor
+ */
+ public TestParametersL10() {
+ }
+
+ /**
+ * Create a test parameter group.
+ *
+ * @param name the parameter group name
+ */
+ public TestParametersL10(final String name) {
+ this.name = name;
+
+ TestParametersLGeneric l10LGenericNestedMapVal0 = new TestParametersLGeneric("l10LGenericNestedMapVal0");
+ l10LGenericNestedMap.put(l10LGenericNestedMapVal0.getName(), l10LGenericNestedMapVal0);
+ TestParametersLGeneric l10LGenericNestedMapVal1 = new TestParametersLGeneric("l10LGenericNestedMapVal1");
+ l10LGenericNestedMap.put(l10LGenericNestedMapVal1.getName(), l10LGenericNestedMapVal1);
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ 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().getCanonicalName();
+ l10IntField = 0;
+ break;
+ case OBSERVATION:
+ l10StringField = "aString";
+ l10IntField = 2;
+ break;
+ case WARNING:
+ l10StringField = "l10StringField";
+ 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 String getName() {
+ return this.name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ GroupValidationResult validationResult = new GroupValidationResult(this);
+
+ if (l10StringField == null || l10StringField.trim().length() == 0) {
+ validationResult.setResult("l10StringField", ValidationStatus.INVALID,
+ "l10StringField must be a non-blank string");
+ } else if (l10StringField.equals("l10StringField")) {
+ validationResult.setResult("l10StringField", ValidationStatus.WARNING,
+ "using the field name for the parameter value is dangerous");
+ } else if (l10StringField.equals("aString")) {
+ validationResult.setResult("l10StringField", ValidationStatus.OBSERVATION,
+ "this value for name is unhelpful");
+ } else {
+ validationResult.setResult("l10StringField", ValidationStatus.CLEAN,
+ ParameterConstants.PARAMETER_HAS_STATUS_MESSAGE + ValidationStatus.CLEAN.toString());
+ }
+
+ if (l10IntField < 0) {
+ validationResult.setResult("l10IntField", ValidationStatus.INVALID,
+ "l10IntField must be a positive integer");
+ } else if (l10IntField > 2) {
+ validationResult.setResult("l10IntField", ValidationStatus.WARNING,
+ "values greater than 2 are not recommended");
+ } else if (l10IntField == 2) {
+ validationResult.setResult("l10IntField", ValidationStatus.OBSERVATION, "this field has been set to 2");
+ } else {
+ validationResult.setResult("l10IntField", ValidationStatus.CLEAN,
+ ParameterConstants.PARAMETER_HAS_STATUS_MESSAGE + ValidationStatus.CLEAN.toString());
+ }
+
+
+ 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
new file mode 100644
index 00000000..ce368bac
--- /dev/null
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersLGeneric.java
@@ -0,0 +1,135 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.parameters.testclasses;
+
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterConstants;
+import org.onap.policy.common.parameters.ValidationStatus;
+
+public class TestParametersLGeneric implements ParameterGroup {
+ private String name;
+ private int lgenericIntField = 0;
+ private String lgenericStringField = "Legal " + this.getClass().getCanonicalName();
+
+ /**
+ * Default constructor
+ */
+ public TestParametersLGeneric() {
+ }
+
+ /**
+ * Create a test parameter group.
+ *
+ * @param name the parameter group name
+ */
+ public TestParametersLGeneric(final String name) {
+ this.name = name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ 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;
+ }
+ else {
+ level--;
+ }
+
+ switch (triggerStatus) {
+ case CLEAN:
+ lgenericStringField = "Legal " + this.getClass().getCanonicalName();
+ lgenericIntField = 0;
+ break;
+ case OBSERVATION:
+ lgenericStringField = "aString";
+ lgenericIntField = 2;
+ break;
+ case WARNING:
+ lgenericStringField = "lgenericStringField";
+ lgenericIntField = 3;
+ break;
+ case INVALID:
+ lgenericStringField = "";
+ lgenericIntField = -1;
+ break;
+ default:
+ break;
+ }
+
+ }
+
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ GroupValidationResult validationResult = new GroupValidationResult(this);
+
+ if (lgenericStringField == null || lgenericStringField.trim().length() == 0) {
+ validationResult.setResult("lgenericStringField", ValidationStatus.INVALID,
+ "lgenericStringField must be a non-blank string");
+ } else if (lgenericStringField.equals("lgenericStringField")) {
+ validationResult.setResult("lgenericStringField", ValidationStatus.WARNING,
+ "using the field name for the parameter value is dangerous");
+ } else if (lgenericStringField.equals("aString")) {
+ 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) {
+ validationResult.setResult("lgenericIntField", ValidationStatus.INVALID,
+ "lgenericIntField must be a positive integer");
+ } else if (lgenericIntField > 2) {
+ validationResult.setResult("lgenericIntField", ValidationStatus.WARNING,
+ "values greater than 2 are not recommended");
+ } 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;
+ }
+}
diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestJsonYamlValidationResult.txt b/common-parameters/src/test/resources/expectedValidationResults/TestJsonYamlValidationResult.txt
new file mode 100644
index 00000000..103321ff
--- /dev/null
+++ b/common-parameters/src/test/resources/expectedValidationResults/TestJsonYamlValidationResult.txt
@@ -0,0 +1,39 @@
+parameter group "l00NameFromFile" type "org.onap.policy.common.parameters.testclasses.TestParametersL00" CLEAN, parameter group has status CLEAN
+ field "name" type "java.lang.String" value "l00NameFromFile" CLEAN, parameter 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 "name" type "java.lang.String" value "l00L10NestedNameFromFile" CLEAN, parameter 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 "name" type "java.lang.String" value "l10LGenericNested0NameFromFile" CLEAN, parameter 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
+ parameter group "l10LGenericNested1NameFromFile" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
+ field "name" type "java.lang.String" value "l10LGenericNested1NameFromFile" CLEAN, parameter 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
+ 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 "name" type "java.lang.String" value "L10Entry0Name" CLEAN, parameter 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
+ parameter group "L10Entry1Name" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
+ field "name" type "java.lang.String" value "L10Entry1Name" CLEAN, parameter 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
+ parameter group "l00GenericNestedNameFromFile" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
+ field "name" type "java.lang.String" value "l00GenericNestedNameFromFile" CLEAN, parameter 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
+ 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 "name" type "java.lang.String" value "L00Entry0Name" CLEAN, parameter 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
+ parameter group "L00Entry1Name" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
+ field "name" type "java.lang.String" value "L00Entry1Name" CLEAN, parameter 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
+
diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_0_OK.txt b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_0_OK.txt
new file mode 100644
index 00000000..7f6d298c
--- /dev/null
+++ b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_0_OK.txt
@@ -0,0 +1,39 @@
+parameter group "l0Parameters" type "org.onap.policy.common.parameters.testclasses.TestParametersL00" CLEAN, parameter group has status CLEAN
+ field "name" type "java.lang.String" value "l0Parameters" CLEAN, parameter 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 "name" type "java.lang.String" value "l00L10Nested" CLEAN, parameter 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 "name" type "java.lang.String" value "l10LGenericNested0" CLEAN, parameter 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
+ parameter group "l10LGenericNested1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
+ field "name" type "java.lang.String" value "l10LGenericNested1" CLEAN, parameter 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
+ 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 "name" type "java.lang.String" value "l10LGenericNestedMapVal0" CLEAN, parameter 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
+ parameter group "l10LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
+ field "name" type "java.lang.String" value "l10LGenericNestedMapVal1" CLEAN, parameter 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
+ parameter group "l00LGenericNested" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
+ field "name" type "java.lang.String" value "l00LGenericNested" CLEAN, parameter 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
+ 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 "name" type "java.lang.String" value "l00LGenericNestedMapVal0" CLEAN, parameter 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
+ parameter group "l00LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
+ field "name" type "java.lang.String" value "l00LGenericNestedMapVal1" CLEAN, parameter 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
+
diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_1_Invalid.txt b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_1_Invalid.txt
new file mode 100644
index 00000000..dcc3cee3
--- /dev/null
+++ b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_1_Invalid.txt
@@ -0,0 +1,3 @@
+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
new file mode 100644
index 00000000..ae627926
--- /dev/null
+++ b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_1_Observation.txt
@@ -0,0 +1,3 @@
+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
new file mode 100644
index 00000000..14a65aa8
--- /dev/null
+++ b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_1_Warning.txt
@@ -0,0 +1,3 @@
+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
new file mode 100644
index 00000000..cec8f208
--- /dev/null
+++ b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Invalid.txt
@@ -0,0 +1,9 @@
+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, lgenericStringField 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
new file mode 100644
index 00000000..45402033
--- /dev/null
+++ b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Observation.txt
@@ -0,0 +1,9 @@
+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
diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Warning.txt b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Warning.txt
new file mode 100644
index 00000000..33d1d16a
--- /dev/null
+++ b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Warning.txt
@@ -0,0 +1,9 @@
+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 \ 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
new file mode 100644
index 00000000..fecfe70d
--- /dev/null
+++ b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Invalid.txt
@@ -0,0 +1,15 @@
+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, lgenericStringField 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, lgenericStringField 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, lgenericStringField 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
new file mode 100644
index 00000000..00fe6627
--- /dev/null
+++ b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Observation.txt
@@ -0,0 +1,15 @@
+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 "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
diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Warning.txt b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Warning.txt
new file mode 100644
index 00000000..6c1c639d
--- /dev/null
+++ b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Warning.txt
@@ -0,0 +1,15 @@
+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 "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 \ No newline at end of file
diff --git a/common-parameters/src/test/resources/parameters/TestParameters.json b/common-parameters/src/test/resources/parameters/TestParameters.json
new file mode 100644
index 00000000..8e312166
--- /dev/null
+++ b/common-parameters/src/test/resources/parameters/TestParameters.json
@@ -0,0 +1,49 @@
+{
+ "name" : "l00NameFromFile",
+ "l00IntField" : 1,
+ "l00StringField" : "l00 string field value from file",
+ "l00L10Nested" : {
+ "name" : "l00L10NestedNameFromFile",
+ "l10IntField" : 1,
+ "l10StringField" : "l00 L10 nested string field value from file",
+ "l10LGenericNested0" : {
+ "name" : "l10LGenericNested0NameFromFile",
+ "lgenericIntField" : 1,
+ "lgenericStringField" : "l10 generic nested 0 string field value from file"
+ },
+ "l10LGenericNested1" : {
+ "name" : "l10LGenericNested1NameFromFile",
+ "lgenericIntField" : 1,
+ "lgenericStringField" : "l10 generic nested 1 string field value from file"
+ },
+ "l10LGenericNestedMap": {
+ "L10Entry0": {
+ "name" : "L10Entry0Name",
+ "lgenericIntField" : 1,
+ "lgenericStringField" : "L10Entry0 value from file"
+ },
+ "L10Entry1": {
+ "name" : "L10Entry1Name",
+ "lgenericIntField" : 1,
+ "lgenericStringField" : "L10Entry1 value from file"
+ }
+ }
+ },
+ "l00LGenericNested" : {
+ "name" : "l00GenericNestedNameFromFile",
+ "lgenericIntField" : 1,
+ "lgenericStringField" : "l00 generic nested string field value from file"
+ },
+ "l00LGenericNestedMap": {
+ "L00Entry0": {
+ "name" : "L00Entry0Name",
+ "lgenericIntField" : 1,
+ "lgenericStringField" : "L00Entry0 value from file"
+ },
+ "L00Entry1": {
+ "name" : "L00Entry1Name",
+ "lgenericIntField" : 1,
+ "lgenericStringField" : "L00Entry1 value from file"
+ }
+ }
+} \ No newline at end of file
diff --git a/common-parameters/src/test/resources/parameters/TestParameters.yaml b/common-parameters/src/test/resources/parameters/TestParameters.yaml
new file mode 100644
index 00000000..c7e17f6a
--- /dev/null
+++ b/common-parameters/src/test/resources/parameters/TestParameters.yaml
@@ -0,0 +1,37 @@
+name: l00NameFromFile
+l00IntField: 1
+l00StringField: l00 string field value from file
+l00L10Nested:
+ name: l00L10NestedNameFromFile
+ l10IntField: 1
+ l10StringField: l00 L10 nested string field value from file
+ l10LGenericNested0:
+ name: l10LGenericNested0NameFromFile
+ lgenericIntField: 1
+ lgenericStringField: l10 generic nested 0 string field value from file
+ l10LGenericNested1:
+ name: l10LGenericNested1NameFromFile
+ lgenericIntField: 1
+ lgenericStringField: l10 generic nested 1 string field value from file
+ l10LGenericNestedMap:
+ l10Entry0:
+ name: L10Entry0Name
+ lgenericIntField: 1
+ lgenericStringField: L10Entry0 value from file
+ L10Entry1:
+ name: L10Entry1Name
+ lgenericIntField: 1
+ lgenericStringField: L10Entry1 value from file
+l00LGenericNested:
+ name: l00GenericNestedNameFromFile
+ lgenericIntField: 1
+ lgenericStringField: l00 generic nested string field value from file
+l00LGenericNestedMap:
+ L00Entry0:
+ name: L00Entry0Name
+ lgenericIntField: 1
+ lgenericStringField: L00Entry0 value from file
+ L00Entry1:
+ name: L00Entry1Name
+ lgenericIntField: 1
+ lgenericStringField: L00Entry1 value from file