summaryrefslogtreecommitdiffstats
path: root/main/src/test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-04-27 11:39:56 -0400
committerJim Hahn <jrh3@att.com>2021-04-29 11:36:26 -0400
commit2f74523b7c5657b4bed38315c5ebfc0ed1bd02c6 (patch)
tree1113c51165768c839039d98626496cd2db8f75f9 /main/src/test
parent518592d628b9f1caa8dfc27c9c38faae25bb6c4f (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. Issue-ID: POLICY-2059 Change-Id: I039f761745316fea41d63bdc885584c9a9c2bc6e Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'main/src/test')
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java41
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterHandler.java24
2 files changed, 25 insertions, 40 deletions
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java b/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java
index 1c4cf1d0..b2d1cbe3 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java
@@ -36,7 +36,7 @@ import org.junit.rules.TemporaryFolder;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.parameters.RestServerParameters;
import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
/**
* Class to perform unit test of XacmlPdpParameterGroup.
@@ -67,7 +67,7 @@ public class TestXacmlPdpParameterGroup {
new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME,
CommonTestData.PDPX_GROUP, "flavor", restServerParameters, policyApiParameters,
topicParameterGroup, applicationPath.getAbsolutePath());
- final GroupValidationResult validationResult = pdpxParameters.validate();
+ final ValidationResult validationResult = pdpxParameters.validate();
assertThat(validationResult.getResult()).isNull();
assertTrue(validationResult.isValid());
assertEquals(restServerParameters.getHost(), pdpxParameters.getRestServerParameters().getHost());
@@ -91,11 +91,10 @@ public class TestXacmlPdpParameterGroup {
final XacmlPdpParameterGroup pdpxParameters = new XacmlPdpParameterGroup(null, CommonTestData.PDPX_GROUP,
null, restServerParameters, policyApiParameters, topicParameterGroup,
applicationPath.getAbsolutePath());
- final GroupValidationResult validationResult = pdpxParameters.validate();
+ final ValidationResult validationResult = pdpxParameters.validate();
assertFalse(validationResult.isValid());
assertEquals(null, pdpxParameters.getName());
- assertTrue(validationResult.getResult().contains(
- "field \"name\" type \"java.lang.String\" value \"null\" INVALID, " + "must be a non-blank string"));
+ assertThat(validationResult.getResult()).contains("\"name\" value \"null\" INVALID, is null");
}
@Test
@@ -109,11 +108,10 @@ public class TestXacmlPdpParameterGroup {
final XacmlPdpParameterGroup pdpxParameters = new XacmlPdpParameterGroup("", CommonTestData.PDPX_GROUP,
CommonTestData.PDPX_TYPE, restServerParameters, policyApiParameters, topicParameterGroup,
applicationPath.getAbsolutePath());
- final GroupValidationResult validationResult = pdpxParameters.validate();
+ final ValidationResult validationResult = pdpxParameters.validate();
assertFalse(validationResult.isValid());
assertEquals("", pdpxParameters.getName());
- assertTrue(validationResult.getResult().contains(
- "field \"name\" type \"java.lang.String\" value \"\" INVALID, " + "must be a non-blank string"));
+ assertThat(validationResult.getResult()).contains("\"name\" value \"\" INVALID, is blank");
}
@Test
@@ -127,12 +125,10 @@ public class TestXacmlPdpParameterGroup {
final XacmlPdpParameterGroup pdpxParameters =
new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME, null, null, restServerParameters,
policyApiParameters, topicParameterGroup, applicationPath.getAbsolutePath());
- final GroupValidationResult validationResult = pdpxParameters.validate();
+ final ValidationResult validationResult = pdpxParameters.validate();
assertFalse(validationResult.isValid());
assertEquals(null, pdpxParameters.getPdpGroup());
- assertTrue(validationResult.getResult()
- .contains("field \"pdpGroup\" type \"java.lang.String\" value \"null\" INVALID, "
- + "must be a non-blank string"));
+ assertThat(validationResult.getResult()).contains("\"pdpGroup\" value \"null\" INVALID, is null");
}
@Test
@@ -146,12 +142,10 @@ public class TestXacmlPdpParameterGroup {
final XacmlPdpParameterGroup pdpxParameters =
new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME, "", null, restServerParameters,
policyApiParameters, topicParameterGroup, applicationPath.getAbsolutePath());
- final GroupValidationResult validationResult = pdpxParameters.validate();
+ final ValidationResult validationResult = pdpxParameters.validate();
assertFalse(validationResult.isValid());
assertEquals("", pdpxParameters.getPdpGroup());
- assertTrue(validationResult.getResult()
- .contains("field \"pdpGroup\" type \"java.lang.String\" value \"\" INVALID, "
- + "must be a non-blank string"));
+ assertThat(validationResult.getResult()).contains("\"pdpGroup\" value \"\" INVALID, is blank");
}
@Test
@@ -166,10 +160,9 @@ public class TestXacmlPdpParameterGroup {
new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME, CommonTestData.PDPX_GROUP,
null, restServerParameters, policyApiParameters,
topicParameterGroup, applicationPath.getAbsolutePath());
- final GroupValidationResult validationResult = pdpxParameters.validate();
+ final ValidationResult validationResult = pdpxParameters.validate();
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult()
- .contains("parameter group \"RestServerParameters\""));
+ assertThat(validationResult.getResult()).contains("\"RestServerParameters\"");
}
@Test
@@ -184,10 +177,9 @@ public class TestXacmlPdpParameterGroup {
new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME, CommonTestData.PDPX_GROUP,
null, restServerParameters, policyApiParameters,
topicParameterGroup, applicationPath.getAbsolutePath());
- final GroupValidationResult validationResult = pdpxParameters.validate();
+ final ValidationResult validationResult = pdpxParameters.validate();
assertFalse(validationResult.isValid());
- assertThat(validationResult.getResult())
- .contains("field \"policyApiParameters\"");
+ assertThat(validationResult.getResult()).contains("\"policyApiParameters\"");
}
@Test
@@ -202,9 +194,8 @@ public class TestXacmlPdpParameterGroup {
new XacmlPdpParameterGroup(CommonTestData.PDPX_PARAMETER_GROUP_NAME, CommonTestData.PDPX_GROUP,
null, restServerParameters, policyApiParameters,
topicParameterGroup, applicationPath.getAbsolutePath());
- final GroupValidationResult validationResult = pdpxParameters.validate();
+ final ValidationResult validationResult = pdpxParameters.validate();
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult()
- .contains("parameter group \"TopicParameterGroup\""));
+ assertThat(validationResult.getResult()).contains("\"TopicParameterGroup\"");
}
}
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterHandler.java b/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterHandler.java
index 1b62965d..570b4319 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterHandler.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterHandler.java
@@ -94,18 +94,12 @@ public class TestXacmlPdpParameterHandler {
noArguments.parse(noArgumentString);
assertThatThrownBy(() -> new XacmlPdpParameterHandler().getParameters(noArguments))
- .hasMessage("validation error(s) on parameters from \"parameters/NoParameters.json\"\n"
- + "parameter group \"null\" type "
- + "\"org.onap.policy.pdpx.main.parameters.XacmlPdpParameterGroup\""
- + " INVALID, parameter group has status INVALID\n"
- + " field \"name\" type \"java.lang.String\" value \"null\" INVALID, "
- + "must be a non-blank string\n"
- + " field \"pdpGroup\" type \"java.lang.String\" value \"null\" INVALID, "
- + "must be a non-blank string\n"
- + " field \"pdpType\" type \"java.lang.String\" value \"null\" INVALID, "
- + "must be a non-blank string\n"
- + " field \"applicationPath\" type \"java.lang.String\" value \"null\" INVALID, "
- + "must have application path for applications to store policies and data.\n");
+ .hasMessageContaining("validation error(s) on parameters from \"parameters/NoParameters.json\"",
+ "\"XacmlPdpParameterGroup\" INVALID, item has status INVALID",
+ "\"name\" value \"null\" INVALID, is null",
+ "\"pdpGroup\" value \"null\" INVALID, is null",
+ "\"pdpType\" value \"null\" INVALID, is null",
+ "\"applicationPath\" value \"null\" INVALID, is null");
}
@Test
@@ -142,20 +136,20 @@ public class TestXacmlPdpParameterHandler {
arguments.parse(xacmlPdpConfigParameters);
assertThatThrownBy(() -> new XacmlPdpParameterHandler().getParameters(arguments)).hasMessageContaining(
- "field \"name\" type \"java.lang.String\" value \" \" INVALID, must be a non-blank string");
+ "\"name\" value \" \" INVALID, is blank");
xacmlPdpConfigParameters[1] = "parameters/XacmlPdpConfigParameters_InvalidPdpGroup.json";
arguments.parse(xacmlPdpConfigParameters);
assertThatThrownBy(() -> new XacmlPdpParameterHandler().getParameters(arguments)).hasMessageContaining(
- "field \"pdpGroup\" type \"java.lang.String\" value \" \" INVALID, must be a non-blank string");
+ "\"pdpGroup\" value \" \" INVALID, is blank");
xacmlPdpConfigParameters[1] = "parameters/XacmlPdpConfigParameters_InvalidPdpType.json";
arguments.parse(xacmlPdpConfigParameters);
assertThatThrownBy(() -> new XacmlPdpParameterHandler().getParameters(arguments)).hasMessageContaining(
- "field \"pdpType\" type \"java.lang.String\" value \"\" INVALID, must be a non-blank string");
+ "\"pdpType\" value \"\" INVALID, is blank");
}
@Test