aboutsummaryrefslogtreecommitdiffstats
path: root/reception/src/test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-04-27 15:08:59 -0400
committerJim Hahn <jrh3@att.com>2021-04-29 14:49:33 -0400
commita05cc62b6426d31c23f60dbe4a6f367331431ea4 (patch)
treebb38e4b81c133004ab9541c15db030750957f5f3 /reception/src/test
parentadfc3ee02f3194a143bcea430e5e3aeb99a23206 (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: Ib5c0dc0ac3762e68307e63f5ce29efb49208e55d Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'reception/src/test')
-rw-r--r--reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestPluginHandlerParameters.java21
-rw-r--r--reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestPolicyDecoderParameters.java19
-rw-r--r--reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestReceptionHandlerParameters.java31
3 files changed, 30 insertions, 41 deletions
diff --git a/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestPluginHandlerParameters.java b/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestPluginHandlerParameters.java
index 9d6a78d0..9a0ac316 100644
--- a/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestPluginHandlerParameters.java
+++ b/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestPluginHandlerParameters.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 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.
@@ -25,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters;
/**
@@ -40,30 +41,24 @@ public class TestPluginHandlerParameters {
public void testValidate_PolicyDecodersEmpty() {
PluginHandlerParameters emptyDecoder = new PluginHandlerParameters(new HashMap<>(), getPolicyForwarders());
- GroupValidationResult result = emptyDecoder.validate();
+ ValidationResult result = emptyDecoder.validate();
- assertThat(result.getResult())
- .contains("parameter group map \"policyDecoders\" INVALID, must have at least one policy decoder");
- assertThat(result.getResult()).doesNotContain(
- "parameter group map \"policyForwarders\" INVALID, must have at least one policy forwarder");
+ assertThat(result.getResult()).contains("\"policyDecoders\"", "minimum").doesNotContain("\"policyForwarders\"");
}
@Test
public void testValidate_PolicyForwardersNullEmpty() {
PluginHandlerParameters emptyDecoder = new PluginHandlerParameters(getPolicyDecoders(), new HashMap<>());
- GroupValidationResult result = emptyDecoder.validate();
+ ValidationResult result = emptyDecoder.validate();
- assertThat(result.getResult())
- .contains("parameter group map \"policyForwarders\" INVALID, must have at least one policy forwarder");
- assertThat(result.getResult()).doesNotContain(
- "parameter group map \"policyDecoders\" INVALID, must have at least one policy decoder");
+ assertThat(result.getResult()).contains("\"policyForwarders\"", "minimum").doesNotContain("\"policyDecoders\"");
}
private Map<String, PolicyDecoderParameters> getPolicyDecoders() {
final Map<String, PolicyDecoderParameters> policyDecoders = new HashMap<>();
final PolicyDecoderParameters pDParameters =
- new PolicyDecoderParameters("DummyDecoder", "DummyDecoder", "dummyDecoderConfiguration");
+ new PolicyDecoderParameters("DummyDecoder", getClass().getName(), "dummyDecoderConfiguration");
policyDecoders.put("DummyDecoder", pDParameters);
return policyDecoders;
@@ -72,7 +67,7 @@ public class TestPluginHandlerParameters {
private Map<String, PolicyForwarderParameters> getPolicyForwarders() {
final Map<String, PolicyForwarderParameters> policyForwarders = new HashMap<>();
final PolicyForwarderParameters pFParameters =
- new PolicyForwarderParameters("DummyForwarder", "DummyForwarder", "dummyForwarderConfiguration");
+ new PolicyForwarderParameters("DummyForwarder", getClass().getName(), "dummyForwarderConfiguration");
policyForwarders.put("DummyForwarder", pFParameters);
return policyForwarders;
diff --git a/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestPolicyDecoderParameters.java b/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestPolicyDecoderParameters.java
index d1d0b421..dae91abf 100644
--- a/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestPolicyDecoderParameters.java
+++ b/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestPolicyDecoderParameters.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 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.
@@ -23,6 +24,7 @@ package org.onap.policy.distribution.reception.parameters;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
+import org.onap.policy.distribution.reception.handling.DummyDecoder;
/**
* Class for unit testing PolicyDecoderParameters class.
@@ -32,7 +34,7 @@ import org.junit.Test;
*/
public class TestPolicyDecoderParameters {
- static final String DECODER_CLASS_NAME = "org.onap.policy.distribution.reception.handling.DummyDecoder";
+ static final String DECODER_CLASS_NAME = DummyDecoder.class.getName();
static final String DECODER_CONFIG = "decoderConfigName";
static final String DECODER_TYPE = "DummyDecoder";
@@ -40,14 +42,12 @@ public class TestPolicyDecoderParameters {
public void testValidate_DecoderTypeEmptyNull() {
PolicyDecoderParameters sutParams = new PolicyDecoderParameters(null, DECODER_CLASS_NAME, DECODER_CONFIG);
- assertThat(sutParams.validate().getResult()).contains(
- "field \"decoderType\" type \"java.lang.String\" value \"null\" INVALID, must be a non-blank string");
+ assertThat(sutParams.validate().getResult()).contains("\"decoderType\" value \"null\" INVALID, is null");
sutParams.setName("");
- assertThat(sutParams.validate().getResult()).contains(
- "field \"decoderType\" type \"java.lang.String\" value \"\" INVALID, must be a non-blank string");
- assertThat(sutParams.validate().getResult()).doesNotContain("policy decoder class not found in classpath");
+ assertThat(sutParams.validate().getResult()).contains("\"decoderType\" value \"\" INVALID, is blank")
+ .doesNotContain("not found in classpath");
}
@Test
@@ -55,13 +55,10 @@ public class TestPolicyDecoderParameters {
PolicyDecoderParameters nullClassName = new PolicyDecoderParameters(DECODER_TYPE, null, DECODER_CONFIG);
assertThat(nullClassName.validate().getResult())
- .contains("field \"decoderClassName\" type \"java.lang.String\" value \"null\" INVALID, "
- + "must be a non-blank string containing full class name of the decoder");
+ .contains("\"decoderClassName\" value \"null\" INVALID, is null");
PolicyDecoderParameters emptyClassName = new PolicyDecoderParameters(DECODER_TYPE, "", DECODER_CONFIG);
- assertThat(emptyClassName.validate().getResult())
- .contains("field \"decoderClassName\" type \"java.lang.String\" value \"\" INVALID, "
- + "must be a non-blank string containing full class name of the decoder");
+ assertThat(emptyClassName.validate().getResult()).contains("\"decoderClassName\" value \"\" INVALID, is blank");
}
}
diff --git a/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestReceptionHandlerParameters.java b/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestReceptionHandlerParameters.java
index e2ef01db..b12af003 100644
--- a/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestReceptionHandlerParameters.java
+++ b/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestReceptionHandlerParameters.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 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.
@@ -26,6 +27,7 @@ import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters;
+import org.onap.policy.distribution.reception.handling.DummyDecoder;
/**
* Class for unit testing ReceptionHandlerParameters class.
@@ -42,25 +44,24 @@ public class TestReceptionHandlerParameters {
ReceptionHandlerParameters sutParams = getReceptionHandlerParameters(className);
sutParams.setName(className);
- assertThat(sutParams.validate().getResult()).contains("reception handler class not found in classpath");
+ assertThat(sutParams.validate().getResult()).contains("class is not in the classpath");
}
@Test
public void testValidate_ReceptionHandlerTypeNullEmpty() {
- final String className = "org.onap.policy.distribution.reception.handling.DummyReceptionHandler";
+ final String className = DummyDecoder.class.getName();
final PluginHandlerParameters pHParameters =
new PluginHandlerParameters(getPolicyDecoders(), getPolicyForwarders());
ReceptionHandlerParameters nullType = new ReceptionHandlerParameters(null, className, className, pHParameters);
- assertThat(nullType.validate().getResult()).contains("field \"receptionHandlerType\" type \"java.lang.String\""
- + " value \"null\" INVALID, must be a non-blank string");
+ assertThat(nullType.validate().getResult())
+ .contains("\"receptionHandlerType\" value \"null\" INVALID, is null");
ReceptionHandlerParameters emptyType = new ReceptionHandlerParameters("", className, className, pHParameters);
- assertThat(emptyType.validate().getResult()).contains("field \"receptionHandlerType\" type \"java.lang.String\""
- + " value \"\" INVALID, must be a non-blank string");
- assertThat(emptyType.validate().getResult()).doesNotContain("reception handler class not found in classpath");
+ assertThat(emptyType.validate().getResult()).contains("\"receptionHandlerType\" value \"\" INVALID, is blank")
+ .doesNotContain("classpath");
}
@Test
@@ -72,17 +73,13 @@ public class TestReceptionHandlerParameters {
"dummyReceptionHandlerConfiguration", pHParameters);
assertThat(nullType.validate().getResult())
- .contains("field \"receptionHandlerClassName\" type \"java.lang.String\" value "
- + "\"null\" INVALID, must be a non-blank string containing full class name "
- + "of the reception handler");
+ .contains("\"receptionHandlerClassName\" value \"null\" INVALID, is null");
ReceptionHandlerParameters emptyType = new ReceptionHandlerParameters("DummyReceptionHandler", "",
"dummyReceptionHandlerConfiguration", pHParameters);
assertThat(emptyType.validate().getResult())
- .contains("field \"receptionHandlerClassName\" type \"java.lang.String\" value "
- + "\"\" INVALID, must be a non-blank string containing full class name of "
- + "the reception handler");
+ .contains("\"receptionHandlerClassName\" value \"\" INVALID, is blank");
}
@Test
@@ -93,7 +90,7 @@ public class TestReceptionHandlerParameters {
"dummyReceptionHandlerConfiguration", null);
assertThat(sutParams.validate().getResult())
- .contains("parameter group \"UNDEFINED\" INVALID, must have a plugin handler");
+ .contains("\"pluginHandlerParameters\" value \"null\" INVALID, is null");
}
private ReceptionHandlerParameters getReceptionHandlerParameters(String className) {
@@ -109,7 +106,7 @@ public class TestReceptionHandlerParameters {
final Map<String, PolicyDecoderParameters> policyDecoders = new HashMap<>();
final PolicyDecoderParameters pDParameters =
- new PolicyDecoderParameters("DummyDecoder", "DummyDecoder", "dummyDecoderConfiguration");
+ new PolicyDecoderParameters("DummyDecoder", DummyDecoder.class.getName(), "dummyDecoderConfiguration");
policyDecoders.put("DummyDecoder", pDParameters);
return policyDecoders;
@@ -118,8 +115,8 @@ public class TestReceptionHandlerParameters {
private Map<String, PolicyForwarderParameters> getPolicyForwarders() {
final Map<String, PolicyForwarderParameters> policyForwarders = new HashMap<>();
- final PolicyForwarderParameters pFParameters =
- new PolicyForwarderParameters("DummyForwarder", "DummyForwarder", "dummyForwarderConfiguration");
+ final PolicyForwarderParameters pFParameters = new PolicyForwarderParameters("DummyForwarder",
+ DummyDecoder.class.getName(), "dummyForwarderConfiguration");
policyForwarders.put("DummyForwarder", pFParameters);
return policyForwarders;