summaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-04-26 17:41:25 -0400
committerJim Hahn <jrh3@att.com>2021-04-29 11:30:24 -0400
commit3b00f1c32b89282dcbb74d3d3645e263f005319e (patch)
treea760975aaf1975905db7069d6d733e7e77b0f797 /policy-endpoints/src/test
parent322b149685bb2f9405999f5a299130694d1b8fe3 (diff)
Remove GroupValidationResult
Removed GroupValidationResult, replacing it with BeanValidationResult. Modified the ParameterGroup subclasses to use BeanValidator, adding annotations where needed to trigger the validations that had been automatically performed by GroupValidationResult. Added Size annotation, used to verify minimum lengths of maps and collections. Added ClassName annotation, used to verify that a property contains the name of a class that is actually in the classpath. Added another addResult() method to make it easier when replacing calls to GroupValidationResult setResult() method with BeanValidationResult. Issue-ID: POLICY-2059 Change-Id: Id4da24886908723006624c5d53edeb034102299d Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'policy-endpoints/src/test')
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestServerParametersTest.java16
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroupTest.java16
2 files changed, 16 insertions, 16 deletions
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestServerParametersTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestServerParametersTest.java
index 58bf98b3..9f03150e 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestServerParametersTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestServerParametersTest.java
@@ -1,8 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
-
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,13 +21,14 @@
package org.onap.policy.common.endpoints.parameters;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -46,7 +46,7 @@ public class RestServerParametersTest {
public void test() {
final RestServerParameters restServerParameters =
testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class);
- final GroupValidationResult validationResult = restServerParameters.validate();
+ final ValidationResult validationResult = restServerParameters.validate();
assertTrue(validationResult.isValid());
assertEquals(CommonTestData.REST_SERVER_HOST, restServerParameters.getHost());
assertEquals(CommonTestData.REST_SERVER_PORT, restServerParameters.getPort());
@@ -60,7 +60,7 @@ public class RestServerParametersTest {
public void testValidate() {
final RestServerParameters restServerParameters =
testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class);
- final GroupValidationResult result = restServerParameters.validate();
+ final ValidationResult result = restServerParameters.validate();
assertNull(result.getResult());
assertTrue(result.isValid());
}
@@ -70,7 +70,7 @@ public class RestServerParametersTest {
String json = testData.getParameterGroupAsString(
"src/test/resources/org/onap/policy/common/endpoints/parameters/RestServerParameters_valid.json");
RestServerParameters restServerParameters = coder.decode(json, RestServerParameters.class);
- final GroupValidationResult result = restServerParameters.validate();
+ final ValidationResult result = restServerParameters.validate();
assertNull(result.getResult());
assertTrue(result.isValid());
}
@@ -80,8 +80,8 @@ public class RestServerParametersTest {
String json = testData.getParameterGroupAsString(
"src/test/resources/org/onap/policy/common/endpoints/parameters/RestServerParameters_invalid.json");
RestServerParameters restServerParameters = coder.decode(json, RestServerParameters.class);
- final GroupValidationResult result = restServerParameters.validate();
+ final ValidationResult result = restServerParameters.validate();
assertFalse(result.isValid());
- assertTrue(result.getResult().contains("parameter group has status INVALID"));
+ assertThat(result.getResult()).contains("item has status INVALID");
}
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroupTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroupTest.java
index 98b3d84a..e4ac6c85 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroupTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroupTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -51,7 +51,7 @@ public class TopicParameterGroupTest {
public void test() throws CoderException {
final TopicParameterGroup topicParameterGroup =
testData.toObject(testData.getTopicParameterGroupMap(false), TopicParameterGroup.class);
- final GroupValidationResult validationResult = topicParameterGroup.validate();
+ final ValidationResult validationResult = topicParameterGroup.validate();
assertTrue(validationResult.isValid());
assertEquals(CommonTestData.TOPIC_PARAMS, topicParameterGroup.getTopicSinks());
assertEquals(CommonTestData.TOPIC_PARAMS, topicParameterGroup.getTopicSources());
@@ -68,7 +68,7 @@ public class TopicParameterGroupTest {
public void testValidate() {
final TopicParameterGroup topicParameterGroup =
testData.toObject(testData.getTopicParameterGroupMap(false), TopicParameterGroup.class);
- final GroupValidationResult result = topicParameterGroup.validate();
+ final ValidationResult result = topicParameterGroup.validate();
assertNull(result.getResult());
assertTrue(result.isValid());
}
@@ -78,7 +78,7 @@ public class TopicParameterGroupTest {
String json = testData.getParameterGroupAsString(
"src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_valid.json");
TopicParameterGroup topicParameterGroup = coder.decode(json, TopicParameterGroup.class);
- final GroupValidationResult result = topicParameterGroup.validate();
+ final ValidationResult result = topicParameterGroup.validate();
assertNull(result.getResult());
assertTrue(result.isValid());
}
@@ -88,7 +88,7 @@ public class TopicParameterGroupTest {
String json = testData.getParameterGroupAsString(
"src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_invalid.json");
TopicParameterGroup topicParameterGroup = coder.decode(json, TopicParameterGroup.class);
- final GroupValidationResult result = topicParameterGroup.validate();
+ final ValidationResult result = topicParameterGroup.validate();
assertFalse(result.isValid());
assertTrue(result.getResult().contains("INVALID"));
}
@@ -98,7 +98,7 @@ public class TopicParameterGroupTest {
String json = testData.getParameterGroupAsString(
"src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_missing_mandatory.json");
TopicParameterGroup topicParameterGroup = coder.decode(json, TopicParameterGroup.class);
- final GroupValidationResult result = topicParameterGroup.validate();
+ final ValidationResult result = topicParameterGroup.validate();
assertTrue(result.getResult().contains("Mandatory parameters are missing"));
assertFalse(result.isValid());
}
@@ -108,7 +108,7 @@ public class TopicParameterGroupTest {
String json = testData.getParameterGroupAsString(
"src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_all_params.json");
TopicParameterGroup topicParameterGroup = coder.decode(json, TopicParameterGroup.class);
- final GroupValidationResult result = topicParameterGroup.validate();
+ final ValidationResult result = topicParameterGroup.validate();
assertNull(result.getResult());
assertTrue(result.isValid());
assertTrue(checkIfAllParamsNotEmpty(topicParameterGroup.getTopicSinks()));