summaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
Diffstat (limited to 'main/src')
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterGroup.java194
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java6
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterGroup.java40
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java27
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/parameters/TestPluginHandlerParameters.java23
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/parameters/TestPolicyDecoderParameters.java41
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/parameters/TestPolicyForwarderParameters.java42
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/parameters/TestReceptionHandlerParameters.java39
-rw-r--r--main/src/test/resources/expectedValidationResults/InvalidDecoderAndForwarderParameters.txt37
-rw-r--r--main/src/test/resources/expectedValidationResults/InvalidReceptionHandlerParameters.txt11
-rw-r--r--main/src/test/resources/expectedValidationResults/InvalidRestServerParameters.txt12
11 files changed, 154 insertions, 318 deletions
diff --git a/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterGroup.java b/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterGroup.java
index d568980a..b78031b7 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterGroup.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterGroup.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * 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.
@@ -23,12 +23,14 @@ package org.onap.policy.distribution.main.parameters;
import java.util.LinkedHashMap;
import java.util.Map;
-import java.util.Map.Entry;
+import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.common.endpoints.parameters.RestServerParameters;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ParameterGroup;
-import org.onap.policy.common.parameters.ValidationStatus;
-import org.onap.policy.common.utils.validation.ParameterValidationUtils;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
+import org.onap.policy.common.parameters.annotations.NotBlank;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.common.parameters.annotations.Size;
+import org.onap.policy.common.parameters.annotations.Valid;
import org.onap.policy.distribution.reception.parameters.PolicyDecoderConfigurationParameterGroup;
import org.onap.policy.distribution.reception.parameters.ReceptionHandlerConfigurationParameterGroup;
import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters;
@@ -38,17 +40,26 @@ import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParamet
*
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
-public class DistributionParameterGroup implements ParameterGroup {
+@Getter
+@Setter
+@NotNull
+@NotBlank
+public class DistributionParameterGroup extends ParameterGroupImpl {
// @formatter:off
- private String name;
+ @Valid
private RestServerParameters restServerParameters;
- private Map<String, ReceptionHandlerParameters> receptionHandlerParameters;
- private Map<String, ReceptionHandlerConfigurationParameterGroup> receptionHandlerConfigurationParameters
- = new LinkedHashMap<>();
- private Map<String, PolicyForwarderConfigurationParameterGroup> policyForwarderConfigurationParameters
- = new LinkedHashMap<>();
- private Map<String, PolicyDecoderConfigurationParameterGroup> policyDecoderConfigurationParameters
- = new LinkedHashMap<>();
+
+ @Size(min = 1)
+ private Map<String, @NotNull @Valid ReceptionHandlerParameters> receptionHandlerParameters;
+
+ private Map<String, @NotNull @Valid ReceptionHandlerConfigurationParameterGroup>
+ receptionHandlerConfigurationParameters = new LinkedHashMap<>();
+
+ private Map<String, @NotNull @Valid PolicyForwarderConfigurationParameterGroup>
+ policyForwarderConfigurationParameters = new LinkedHashMap<>();
+
+ private Map<String, @NotNull @Valid PolicyDecoderConfigurationParameterGroup>
+ policyDecoderConfigurationParameters = new LinkedHashMap<>();
// @formatter:on
/**
@@ -61,162 +72,11 @@ public class DistributionParameterGroup implements ParameterGroup {
final Map<String, ReceptionHandlerConfigurationParameterGroup> receptionHandlerConfigurationParameters,
final Map<String, PolicyForwarderConfigurationParameterGroup> policyForwarderConfigurationParameters,
final Map<String, PolicyDecoderConfigurationParameterGroup> policyDecoderConfigurationParameters) {
- this.name = name;
+ super(name);
this.restServerParameters = restServerParameters;
this.receptionHandlerParameters = receptionHandlerParameters;
this.receptionHandlerConfigurationParameters = receptionHandlerConfigurationParameters;
this.policyForwarderConfigurationParameters = policyForwarderConfigurationParameters;
this.policyDecoderConfigurationParameters = policyDecoderConfigurationParameters;
}
-
- /**
- * Return the name of this parameter group instance.
- *
- * @return name the parameter group name
- */
- @Override
- public String getName() {
- return name;
- }
-
- /**
- * Set the name of this parameter group instance.
- *
- * @param name the parameter group name
- */
- @Override
- public void setName(final String name) {
- this.name = name;
- }
-
- /**
- * Return the receptionHandlerParameters of this parameter group instance.
- *
- * @return the receptionHandlerParameters
- */
- public Map<String, ReceptionHandlerParameters> getReceptionHandlerParameters() {
- return receptionHandlerParameters;
- }
-
- /**
- * Return the restServerParameters of this parameter group instance.
- *
- * @return the restServerParameters
- */
- public RestServerParameters getRestServerParameters() {
- return restServerParameters;
- }
-
- /**
- * Gets the reception handler configuration parameter map.
- *
- * @return the reception handler configuration parameter map
- */
- public Map<String, ReceptionHandlerConfigurationParameterGroup> getReceptionHandlerConfigurationParameters() {
- return receptionHandlerConfigurationParameters;
- }
-
- /**
- * Sets the reception handler configuration parameter map.
- *
- * @param receptionHandlerConfigurationParameters the reception handler configuration parameters
- */
- public void setReceptionHandlerConfigurationParameters(
- final Map<String, ReceptionHandlerConfigurationParameterGroup> receptionHandlerConfigurationParameters) {
- this.receptionHandlerConfigurationParameters = receptionHandlerConfigurationParameters;
- }
-
- /**
- * Gets the policy forwarder configuration parameter map.
- *
- * @return the policy forwarder configuration parameter map
- */
- public Map<String, PolicyForwarderConfigurationParameterGroup> getPolicyForwarderConfigurationParameters() {
- return policyForwarderConfigurationParameters;
- }
-
- /**
- * Sets the policy forwarder configuration parameter map.
- *
- * @param policyForwarderConfigurationParameters the policy forwarder configuration parameters
- */
- public void setPolicyForwarderConfigurationParameters(
- final Map<String, PolicyForwarderConfigurationParameterGroup> policyForwarderConfigurationParameters) {
- this.policyForwarderConfigurationParameters = policyForwarderConfigurationParameters;
- }
-
- /**
- * Returns the policy decoder configuration parameter map.
- *
- * @return the policyDecoderConfigurationParameters
- */
- public Map<String, PolicyDecoderConfigurationParameterGroup> getPolicyDecoderConfigurationParameters() {
- return policyDecoderConfigurationParameters;
- }
-
- /**
- * Set the policy decoder configuration parameter map.
- *
- * @param policyDecoderConfigurationParameters the policyDecoderConfigurationParameters to set
- */
- public void setPolicyDecoderConfigurationParameters(
- final Map<String, PolicyDecoderConfigurationParameterGroup> policyDecoderConfigurationParameters) {
- this.policyDecoderConfigurationParameters = policyDecoderConfigurationParameters;
- }
-
- /**
- * Validate the parameter group.
- *
- * @return the result of the validation
- */
- @Override
- public GroupValidationResult validate() {
- final GroupValidationResult validationResult = new GroupValidationResult(this);
- if (!ParameterValidationUtils.validateStringParameter(name)) {
- validationResult.setResult("name", ValidationStatus.INVALID, "must be a non-blank string");
- }
- if (restServerParameters == null) {
- validationResult.setResult("restServerParameters", ValidationStatus.INVALID,
- "must have restServerParameters to configure distribution rest server");
- } else {
- validationResult.setResult("restServerParameters", restServerParameters.validate());
- }
- validateReceptionHandlers(validationResult);
- validateForwarderConfigurations(validationResult);
- validateDecoderConfigurations(validationResult);
- return validationResult;
- }
-
- private void validateReceptionHandlers(final GroupValidationResult validationResult) {
- if (receptionHandlerParameters == null || receptionHandlerParameters.size() == 0) {
- validationResult.setResult("receptionHandlerParameters", ValidationStatus.INVALID,
- "must have at least one reception handler");
- } else {
- for (final Entry<String, ReceptionHandlerParameters> nestedGroupEntry : receptionHandlerParameters
- .entrySet()) {
- validationResult.setResult("receptionHandlerParameters", nestedGroupEntry.getKey(),
- nestedGroupEntry.getValue().validate());
- }
- }
- }
-
- private void validateForwarderConfigurations(final GroupValidationResult validationResult) {
- // @formatter:off
- for (final Entry<String, PolicyForwarderConfigurationParameterGroup> configurationParameters :
- policyForwarderConfigurationParameters.entrySet()) {
- validationResult.setResult("policyForwarderConfigurationParameters", configurationParameters.getKey(),
- configurationParameters.getValue().validate());
- }
- // @formatter:on
- }
-
- private void validateDecoderConfigurations(final GroupValidationResult validationResult) {
- // @formatter:off
- for (final Entry<String, PolicyDecoderConfigurationParameterGroup> configurationParameters :
- policyDecoderConfigurationParameters.entrySet()) {
- validationResult.setResult("policyDecoderConfigurationParameters", configurationParameters.getKey(),
- configurationParameters.getValue().validate());
- }
- // @formatter:on
- }
}
diff --git a/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java b/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java
index ea7cde6d..7807dcc1 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2020 AT&T Inc.
+ * Modifications Copyright (C) 2020-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 +25,7 @@ package org.onap.policy.distribution.main.parameters;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.FileReader;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.distribution.main.PolicyDistributionException;
import org.onap.policy.distribution.main.startstop.DistributionCommandLineArguments;
import org.onap.policy.distribution.reception.parameters.PolicyDecoderConfigurationParameterGroup;
@@ -79,7 +79,7 @@ public class DistributionParameterHandler {
}
// validate the parameters
- final GroupValidationResult validationResult = distributionParameterGroup.validate();
+ final ValidationResult validationResult = distributionParameterGroup.validate();
if (!validationResult.isValid()) {
String returnMessage =
"validation error(s) on parameters from \"" + arguments.getConfigurationFilePath() + "\"\n";
diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterGroup.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterGroup.java
index fb5dfbd4..0b5bfcb8 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterGroup.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterGroup.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,7 +23,6 @@
package org.onap.policy.distribution.main.parameters;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -31,8 +30,7 @@ import static org.junit.Assert.assertTrue;
import java.util.Map;
import org.junit.Test;
import org.onap.policy.common.endpoints.parameters.RestServerParameters;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ParameterRuntimeException;
+import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.distribution.main.testclasses.DummyPolicyForwarderParameterGroup;
import org.onap.policy.distribution.main.testclasses.DummyReceptionHandlerParameterGroup;
import org.onap.policy.distribution.reception.parameters.PolicyDecoderConfigurationParameterGroup;
@@ -62,7 +60,7 @@ public class TestDistributionParameterGroup {
final DistributionParameterGroup distributionParameters = new DistributionParameterGroup(
CommonTestData.DISTRIBUTION_GROUP_NAME, restServerParameters, receptionHandlerParameters,
receptionHandlerConfigurations, forwarderConfigurations, decoderConfigurations);
- final GroupValidationResult validationResult = distributionParameters.validate();
+ final ValidationResult validationResult = distributionParameters.validate();
assertTrue(validationResult.isValid());
assertEquals(restServerParameters.getHost(), distributionParameters.getRestServerParameters().getHost());
assertEquals(restServerParameters.getPort(), distributionParameters.getRestServerParameters().getPort());
@@ -116,7 +114,7 @@ public class TestDistributionParameterGroup {
final DistributionParameterGroup distributionParameters =
new DistributionParameterGroup(null, restServerParameters, receptionHandlerParameters,
receptionHandlerConfigurations, forwarderConfigurations, decoderConfigurations);
- final GroupValidationResult validationResult = distributionParameters.validate();
+ final ValidationResult validationResult = distributionParameters.validate();
assertFalse(validationResult.isValid());
assertEquals(null, distributionParameters.getName());
assertEquals(
@@ -132,8 +130,7 @@ public class TestDistributionParameterGroup {
receptionHandlerParameters.get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY).getPluginHandlerParameters(),
distributionParameters.getReceptionHandlerParameters().get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
.getPluginHandlerParameters());
- 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
@@ -151,7 +148,7 @@ public class TestDistributionParameterGroup {
final DistributionParameterGroup distributionParameters =
new DistributionParameterGroup("", restServerParameters, receptionHandlerParameters,
receptionHandlerConfigurations, forwarderConfigurations, decoderConfigurations);
- final GroupValidationResult validationResult = distributionParameters.validate();
+ final ValidationResult validationResult = distributionParameters.validate();
assertFalse(validationResult.isValid());
assertEquals("", distributionParameters.getName());
assertEquals(
@@ -167,8 +164,7 @@ public class TestDistributionParameterGroup {
receptionHandlerParameters.get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY).getPluginHandlerParameters(),
distributionParameters.getReceptionHandlerParameters().get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
.getPluginHandlerParameters());
- 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
@@ -182,9 +178,9 @@ public class TestDistributionParameterGroup {
commonTestData.getPolicyDecoderConfigurationParameters(false);
final DistributionParameterGroup distributionParameters =
new DistributionParameterGroup(CommonTestData.DISTRIBUTION_GROUP_NAME, restServerParameters, null,
- receptionHandlerConfigurations, forwarderConfigurations, decoderConfigurations);
- assertThatThrownBy(distributionParameters::validate).isInstanceOf(ParameterRuntimeException.class)
- .hasMessageContaining("map parameter \"receptionHandlerParameters\" is null");
+ receptionHandlerConfigurations, forwarderConfigurations, decoderConfigurations);
+ assertThat(distributionParameters.validate().getResult())
+ .contains("\"receptionHandlerParameters\" value \"null\" INVALID, is null");
}
@Test
@@ -202,9 +198,9 @@ public class TestDistributionParameterGroup {
CommonTestData.DISTRIBUTION_GROUP_NAME, restServerParameters, receptionHandlerParameters,
receptionHandlerConfigurations, forwarderConfigurations, decoderConfigurations);
distributionParameters.validate();
- final GroupValidationResult result = distributionParameters.validate();
+ final ValidationResult result = distributionParameters.validate();
assertFalse(result.isValid());
- assertTrue(result.getResult().endsWith("must have at least one reception handler\n"));
+ assertThat(result.getResult()).contains("minimum");
}
@Test
@@ -222,11 +218,9 @@ public class TestDistributionParameterGroup {
final DistributionParameterGroup distributionParameters = new DistributionParameterGroup(
CommonTestData.DISTRIBUTION_GROUP_NAME, restServerParameters, receptionHandlerParameters,
receptionHandlerConfigurations, forwarderConfigurations, decoderConfigurations);
- final GroupValidationResult validationResult = distributionParameters.validate();
+ final ValidationResult validationResult = distributionParameters.validate();
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult()
- .contains("\"org.onap.policy.common.endpoints.parameters.RestServerParameters\" INVALID, "
- + "parameter group has status INVALID"));
+ assertThat(validationResult.getResult()).contains("\"RestServerParameters\" INVALID");
}
@Test
@@ -244,10 +238,8 @@ public class TestDistributionParameterGroup {
final DistributionParameterGroup distributionParameters = new DistributionParameterGroup(
CommonTestData.DISTRIBUTION_GROUP_NAME, restServerParameters, receptionHandlerParameters,
receptionHandlerConfigurations, forwarderConfigurations, decoderConfigurations);
- final GroupValidationResult validationResult = distributionParameters.validate();
+ final ValidationResult validationResult = distributionParameters.validate();
assertFalse(validationResult.isValid());
- assertThat(validationResult.getResult())
- .contains("parameter group \"UNDEFINED\" INVALID, "
- + "must have restServerParameters to configure distribution rest server");
+ assertThat(validationResult.getResult()).contains("\"restServerParameters\" value \"null\" INVALID, is null");
}
}
diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java
index dcafe68c..b83b3fc9 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020-2021 Nordix Foundation.
- * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020-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.
@@ -30,7 +30,6 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.junit.Test;
-import org.onap.policy.common.parameters.ParameterRuntimeException;
import org.onap.policy.common.utils.cmd.CommandLineException;
import org.onap.policy.distribution.main.PolicyDistributionException;
import org.onap.policy.distribution.main.startstop.DistributionCommandLineArguments;
@@ -72,8 +71,8 @@ public class TestDistributionParameterHandler {
@Test
public void testParameterHandlerNoParameters() throws PolicyDistributionException, CommandLineException {
- verifyFailure("NoParameters.json", ParameterRuntimeException.class,
- "map parameter \"receptionHandlerParameters\" is null");
+ verifyFailure("NoParameters.json", PolicyDistributionException.class,
+ "\"receptionHandlerParameters\" value \"null\" INVALID, is null");
}
@Test
@@ -136,49 +135,49 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_InvalidName() throws PolicyDistributionException, CommandLineException {
verifyFailure("DistributionConfigParameters_InvalidName.json", PolicyDistributionException.class,
- "field \"name\" type \"java.lang.String\" value \" \" INVALID, must be a non-blank string");
+ "\"name\" value \" \" INVALID, is blank");
}
@Test
public void testDistributionParameterGroup_NoReceptionHandler()
throws PolicyDistributionException, CommandLineException {
- verifyFailure("DistributionConfigParameters_NoReceptionHandler.json", ParameterRuntimeException.class,
- "map parameter \"receptionHandlerParameters\" is null");
+ verifyFailure("DistributionConfigParameters_NoReceptionHandler.json", PolicyDistributionException.class,
+ "\"receptionHandlerParameters\" value \"null\" INVALID, is null");
}
@Test
public void testDistributionParameterGroup_EmptyReceptionHandler()
throws PolicyDistributionException, CommandLineException {
verifyFailure("DistributionConfigParameters_EmptyReceptionHandler.json", PolicyDistributionException.class,
- "must have at least one reception handler\n");
+ "\"receptionHandlerParameters\" value \"{}\" INVALID, minimum number of elements: 1");
}
@Test
public void testDistributionParameterGroup_NoPolicyDecoder()
throws PolicyDistributionException, CommandLineException {
- verifyFailure("DistributionConfigParameters_NoPolicyDecoder.json", ParameterRuntimeException.class,
- "map parameter \"policyDecoders\" is null");
+ verifyFailure("DistributionConfigParameters_NoPolicyDecoder.json", PolicyDistributionException.class,
+ "\"policyDecoders\" value \"null\" INVALID, is null");
}
@Test
public void testDistributionParameterGroup_NoPolicyForwarder()
throws PolicyDistributionException, CommandLineException {
- verifyFailure("DistributionConfigParameters_NoPolicyForwarder.json", ParameterRuntimeException.class,
- "map parameter \"policyForwarders\" is null");
+ verifyFailure("DistributionConfigParameters_NoPolicyForwarder.json", PolicyDistributionException.class,
+ "\"policyForwarderConfigurationParameters\" value \"null\" INVALID, is null");
}
@Test
public void testDistributionParameterGroup_EmptyPolicyDecoder()
throws PolicyDistributionException, CommandLineException {
verifyFailure("DistributionConfigParameters_EmptyPolicyDecoder.json", PolicyDistributionException.class,
- "must have at least one policy decoder\n");
+ "\"policyDecoders\" value \"{}\" INVALID, minimum number of elements: 1");
}
@Test
public void testDistributionParameterGroup_EmptyPolicyForwarder()
throws PolicyDistributionException, CommandLineException {
verifyFailure("DistributionConfigParameters_EmptyPolicyForwarder.json", PolicyDistributionException.class,
- "must have at least one policy forwarder\n");
+ "\"policyForwarders\" value \"{}\" INVALID, minimum number of elements: 1");
}
@Test
diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPluginHandlerParameters.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPluginHandlerParameters.java
index 73ec0ba3..9def403d 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPluginHandlerParameters.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPluginHandlerParameters.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 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.
@@ -21,15 +22,14 @@
package org.onap.policy.distribution.main.parameters;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
+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.assertTrue;
import java.util.Map;
import org.junit.Test;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ParameterRuntimeException;
+import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters;
import org.onap.policy.distribution.reception.parameters.PluginHandlerParameters;
import org.onap.policy.distribution.reception.parameters.PolicyDecoderParameters;
@@ -47,7 +47,7 @@ public class TestPluginHandlerParameters {
final Map<String, PolicyDecoderParameters> policyDecoders = commonTestData.getPolicyDecoders(false);
final Map<String, PolicyForwarderParameters> policyForwarders = commonTestData.getPolicyForwarders(false);
final PluginHandlerParameters pHParameters = new PluginHandlerParameters(policyDecoders, policyForwarders);
- final GroupValidationResult validationResult = pHParameters.validate();
+ final ValidationResult validationResult = pHParameters.validate();
assertEquals(policyDecoders.get(CommonTestData.DUMMY_DECODER_KEY),
pHParameters.getPolicyDecoders().get(CommonTestData.DUMMY_DECODER_KEY));
assertEquals(policyForwarders.get(CommonTestData.DUMMY_ENGINE_FORWARDER_KEY),
@@ -59,16 +59,15 @@ public class TestPluginHandlerParameters {
public void testPluginHandlerParameters_NullPolicyDecoders() {
final Map<String, PolicyForwarderParameters> policyForwarders = commonTestData.getPolicyForwarders(false);
final PluginHandlerParameters pHParameters = new PluginHandlerParameters(null, policyForwarders);
- assertThatThrownBy(pHParameters::validate).isInstanceOf(ParameterRuntimeException.class)
- .hasMessage("map parameter \"policyDecoders\" is null");
+ assertThat(pHParameters.validate().getResult()).contains("\"policyDecoders\" value \"null\" INVALID, is null");
}
@Test
public void testPluginHandlerParameters_NullPolicyForwarders() {
final Map<String, PolicyDecoderParameters> policyDecoders = commonTestData.getPolicyDecoders(false);
final PluginHandlerParameters pHParameters = new PluginHandlerParameters(policyDecoders, null);
- assertThatThrownBy(pHParameters::validate).isInstanceOf(ParameterRuntimeException.class)
- .hasMessage("map parameter \"policyForwarders\" is null");
+ assertThat(pHParameters.validate().getResult())
+ .contains("\"policyForwarders\" value \"null\" INVALID, is null");
}
@Test
@@ -76,9 +75,9 @@ public class TestPluginHandlerParameters {
final Map<String, PolicyDecoderParameters> policyDecoders = commonTestData.getPolicyDecoders(true);
final Map<String, PolicyForwarderParameters> policyForwarders = commonTestData.getPolicyForwarders(false);
final PluginHandlerParameters pHParameters = new PluginHandlerParameters(policyDecoders, policyForwarders);
- GroupValidationResult result = pHParameters.validate();
+ ValidationResult result = pHParameters.validate();
assertFalse(result.isValid());
- assertTrue(result.getResult().endsWith("must have at least one policy decoder\n"));
+ assertThat(pHParameters.validate().getResult()).contains("\"policyDecoders\"", "minimum");
}
@Test
@@ -86,8 +85,8 @@ public class TestPluginHandlerParameters {
final Map<String, PolicyForwarderParameters> policyForwarders = commonTestData.getPolicyForwarders(true);
final Map<String, PolicyDecoderParameters> policyDecoders = commonTestData.getPolicyDecoders(false);
final PluginHandlerParameters pHParameters = new PluginHandlerParameters(policyDecoders, policyForwarders);
- GroupValidationResult result = pHParameters.validate();
+ ValidationResult result = pHParameters.validate();
assertFalse(result.isValid());
- assertTrue(result.getResult().endsWith("must have at least one policy forwarder\n"));
+ assertThat(pHParameters.validate().getResult()).contains("\"policyForwarders\"", "minimum");
}
}
diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPolicyDecoderParameters.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPolicyDecoderParameters.java
index 7b9e6095..4195f1b6 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPolicyDecoderParameters.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPolicyDecoderParameters.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * 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.
@@ -20,6 +21,7 @@
package org.onap.policy.distribution.main.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.assertTrue;
@@ -28,7 +30,7 @@ import static org.onap.policy.distribution.main.parameters.CommonTestData.DECODE
import static org.onap.policy.distribution.main.parameters.CommonTestData.DECODER_TYPE;
import org.junit.Test;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.distribution.reception.parameters.PolicyDecoderParameters;
/**
@@ -42,7 +44,7 @@ public class TestPolicyDecoderParameters {
public void testPolicyDecoderParameters() {
final PolicyDecoderParameters pDParameters =
new PolicyDecoderParameters(DECODER_TYPE, DECODER_CLASS_NAME, DECODER_CONFIGURATION_PARAMETERS);
- final GroupValidationResult validationResult = pDParameters.validate();
+ final ValidationResult validationResult = pDParameters.validate();
assertEquals(DECODER_TYPE, pDParameters.getDecoderType());
assertEquals(DECODER_CLASS_NAME, pDParameters.getDecoderClassName());
assertEquals(DECODER_CONFIGURATION_PARAMETERS, pDParameters.getDecoderConfigurationName());
@@ -53,75 +55,66 @@ public class TestPolicyDecoderParameters {
public void testPolicyDecoderParameters_InvalidDecoderType() {
final PolicyDecoderParameters pDParameters =
new PolicyDecoderParameters("", DECODER_CLASS_NAME, DECODER_CONFIGURATION_PARAMETERS);
- final GroupValidationResult validationResult = pDParameters.validate();
+ final ValidationResult validationResult = pDParameters.validate();
assertEquals("", pDParameters.getDecoderType());
assertEquals(DECODER_CLASS_NAME, pDParameters.getDecoderClassName());
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult().contains(
- "field \"decoderType\" type \"java.lang.String\" value \"\" INVALID, must be a non-blank string"));
+ assertThat(validationResult.getResult()).contains("\"decoderType\" value \"\" INVALID, is blank");
}
@Test
public void testPolicyDecoderParameters_InvalidDecoderClassName() {
final PolicyDecoderParameters pDParameters =
new PolicyDecoderParameters(DECODER_TYPE, "", DECODER_CONFIGURATION_PARAMETERS);
- final GroupValidationResult validationResult = pDParameters.validate();
+ final ValidationResult validationResult = pDParameters.validate();
assertEquals(DECODER_TYPE, pDParameters.getDecoderType());
assertEquals("", pDParameters.getDecoderClassName());
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult()
- .contains("field \"decoderClassName\" type \"java.lang.String\" value \"\" INVALID, "
- + "must be a non-blank string containing full class name of the decoder"));
+ assertThat(validationResult.getResult()).contains("\"decoderClassName\" value \"\" INVALID, is blank");
}
@Test
public void testPolicyDecoderParameters_InvalidDecoderTypeAndClassName() {
final PolicyDecoderParameters pDParameters =
new PolicyDecoderParameters("", "", DECODER_CONFIGURATION_PARAMETERS);
- final GroupValidationResult validationResult = pDParameters.validate();
+ final ValidationResult validationResult = pDParameters.validate();
assertEquals("", pDParameters.getDecoderType());
assertEquals("", pDParameters.getDecoderClassName());
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult().contains(
- "field \"decoderType\" type \"java.lang.String\" value \"\" INVALID, must be a non-blank string"));
- assertTrue(validationResult.getResult()
- .contains("field \"decoderClassName\" type \"java.lang.String\" value \"\" INVALID, "
- + "must be a non-blank string containing full class name of the decoder"));
+ assertThat(validationResult.getResult()).contains("\"decoderType\" value \"\" INVALID, is blank",
+ "\"decoderClassName\" value \"\" INVALID, is blank");
}
@Test
public void testPolicyDecoderParameters_NullDecoderType() {
final PolicyDecoderParameters pDParameters =
new PolicyDecoderParameters(null, DECODER_CLASS_NAME, DECODER_CONFIGURATION_PARAMETERS);
- final GroupValidationResult validationResult = pDParameters.validate();
+ final ValidationResult validationResult = pDParameters.validate();
assertEquals(null, pDParameters.getDecoderType());
assertEquals(DECODER_CLASS_NAME, pDParameters.getDecoderClassName());
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult().contains(
- "field \"decoderType\" type \"java.lang.String\" value \"null\" INVALID, must be a non-blank string"));
+ assertThat(validationResult.getResult()).contains("\"decoderType\" value \"null\" INVALID, is null");
}
@Test
public void testPolicyDecoderParameters_NullDecoderClassName() {
final PolicyDecoderParameters pDParameters =
new PolicyDecoderParameters(DECODER_TYPE, null, DECODER_CONFIGURATION_PARAMETERS);
- final GroupValidationResult validationResult = pDParameters.validate();
+ final ValidationResult validationResult = pDParameters.validate();
assertEquals(DECODER_TYPE, pDParameters.getDecoderType());
assertEquals(null, pDParameters.getDecoderClassName());
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult()
- .contains("field \"decoderClassName\" type \"java.lang.String\" value \"null\" INVALID, "
- + "must be a non-blank string containing full class name of the decoder"));
+ assertThat(validationResult.getResult()).contains("\"decoderClassName\" value \"null\" INVALID, is null");
}
@Test
public void testPolicyDecoderParameters_InvalidDecoderClass() {
final PolicyDecoderParameters pDParameters = new PolicyDecoderParameters(DECODER_TYPE,
DECODER_CLASS_NAME + "Invalid", DECODER_CONFIGURATION_PARAMETERS);
- final GroupValidationResult validationResult = pDParameters.validate();
+ final ValidationResult validationResult = pDParameters.validate();
assertEquals(DECODER_TYPE, pDParameters.getDecoderType());
assertEquals(DECODER_CLASS_NAME + "Invalid", pDParameters.getDecoderClassName());
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult().contains("policy decoder class not found in classpath"));
+ assertThat(validationResult.getResult()).contains("\"decoderClassName\"", "classpath");
}
}
diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPolicyForwarderParameters.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPolicyForwarderParameters.java
index 9907bfb8..5dc1b448 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPolicyForwarderParameters.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPolicyForwarderParameters.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * 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.
@@ -20,6 +21,7 @@
package org.onap.policy.distribution.main.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.assertTrue;
@@ -28,7 +30,7 @@ import static org.onap.policy.distribution.main.parameters.CommonTestData.FORWAR
import static org.onap.policy.distribution.main.parameters.CommonTestData.FORWARDER_TYPE;
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;
/**
@@ -42,7 +44,7 @@ public class TestPolicyForwarderParameters {
public void testPolicyForwarderParameters() {
final PolicyForwarderParameters pFParameters =
new PolicyForwarderParameters(FORWARDER_TYPE, FORWARDER_CLASS_NAME, FORWARDER_CONFIGURATION_PARAMETERS);
- final GroupValidationResult validationResult = pFParameters.validate();
+ final ValidationResult validationResult = pFParameters.validate();
assertEquals(FORWARDER_TYPE, pFParameters.getForwarderType());
assertEquals(FORWARDER_CLASS_NAME, pFParameters.getForwarderClassName());
assertTrue(validationResult.isValid());
@@ -52,76 +54,66 @@ public class TestPolicyForwarderParameters {
public void testPolicyForwarderParameters_InvalidForwarderType() {
final PolicyForwarderParameters pFParameters =
new PolicyForwarderParameters("", FORWARDER_CLASS_NAME, FORWARDER_CONFIGURATION_PARAMETERS);
- final GroupValidationResult validationResult = pFParameters.validate();
+ final ValidationResult validationResult = pFParameters.validate();
assertEquals("", pFParameters.getForwarderType());
assertEquals(FORWARDER_CLASS_NAME, pFParameters.getForwarderClassName());
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult().contains(
- "field \"forwarderType\" type \"java.lang.String\" value \"\" INVALID, must be a non-blank string"));
+ assertThat(validationResult.getResult()).contains("\"forwarderType\" value \"\" INVALID, is blank");
}
@Test
public void testPolicyForwarderParameters_InvalidForwarderClassName() {
final PolicyForwarderParameters pFParameters =
new PolicyForwarderParameters(FORWARDER_TYPE, "", FORWARDER_CONFIGURATION_PARAMETERS);
- final GroupValidationResult validationResult = pFParameters.validate();
+ final ValidationResult validationResult = pFParameters.validate();
assertEquals(CommonTestData.FORWARDER_TYPE, pFParameters.getForwarderType());
assertEquals("", pFParameters.getForwarderClassName());
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult()
- .contains("field \"forwarderClassName\" type \"java.lang.String\" value \"\" INVALID, "
- + "must be a non-blank string containing full class name of the forwarder"));
+ assertThat(validationResult.getResult()).contains("\"forwarderClassName\" value \"\" INVALID, is blank");
}
@Test
public void testPolicyForwarderParameters_InvalidForwarderTypeAndClassName() {
final PolicyForwarderParameters pFParameters =
new PolicyForwarderParameters("", "", FORWARDER_CONFIGURATION_PARAMETERS);
- final GroupValidationResult validationResult = pFParameters.validate();
+ final ValidationResult validationResult = pFParameters.validate();
assertEquals("", pFParameters.getForwarderType());
assertEquals("", pFParameters.getForwarderClassName());
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult().contains(
- "field \"forwarderType\" type \"java.lang.String\" value \"\" INVALID, must be a non-blank string"));
- assertTrue(validationResult.getResult()
- .contains("field \"forwarderClassName\" type \"java.lang.String\" value \"\" INVALID, "
- + "must be a non-blank string containing full class name of the forwarder"));
+ assertThat(validationResult.getResult()).contains("\"forwarderType\" value \"\" INVALID, is blank",
+ "\"forwarderClassName\" value \"\" INVALID, is blank");
}
@Test
public void testPolicyForwarderParameters_NullForwarderType() {
final PolicyForwarderParameters pFParameters =
new PolicyForwarderParameters(null, FORWARDER_CLASS_NAME, FORWARDER_CONFIGURATION_PARAMETERS);
- final GroupValidationResult validationResult = pFParameters.validate();
+ final ValidationResult validationResult = pFParameters.validate();
assertEquals(null, pFParameters.getForwarderType());
assertEquals(FORWARDER_CLASS_NAME, pFParameters.getForwarderClassName());
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult()
- .contains("field \"forwarderType\" type \"java.lang.String\" value \"null\" INVALID, "
- + "must be a non-blank string"));
+ assertThat(validationResult.getResult()).contains("\"forwarderType\" value \"null\" INVALID, is null");
}
@Test
public void testPolicyForwarderParameters_NullForwarderClassName() {
final PolicyForwarderParameters pFParameters =
new PolicyForwarderParameters(FORWARDER_TYPE, null, FORWARDER_CONFIGURATION_PARAMETERS);
- final GroupValidationResult validationResult = pFParameters.validate();
+ final ValidationResult validationResult = pFParameters.validate();
assertEquals(FORWARDER_TYPE, pFParameters.getForwarderType());
assertEquals(null, pFParameters.getForwarderClassName());
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult()
- .contains("field \"forwarderClassName\" type \"java.lang.String\" value \"null\" INVALID, "
- + "must be a non-blank string containing full class name of the forwarder"));
+ assertThat(validationResult.getResult()).contains("\"forwarderClassName\" value \"null\" INVALID, is null");
}
@Test
public void testPolicyForwarderParameters_InvalidForwarderClass() {
final PolicyForwarderParameters pFParameters = new PolicyForwarderParameters(FORWARDER_TYPE,
FORWARDER_CLASS_NAME + "Invalid", FORWARDER_CONFIGURATION_PARAMETERS);
- final GroupValidationResult validationResult = pFParameters.validate();
+ final ValidationResult validationResult = pFParameters.validate();
assertEquals(FORWARDER_TYPE, pFParameters.getForwarderType());
assertEquals(FORWARDER_CLASS_NAME + "Invalid", pFParameters.getForwarderClassName());
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult().contains("policy forwarder class not found in classpath"));
+ assertThat(validationResult.getResult()).contains("class is not in the classpath");
}
}
diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestReceptionHandlerParameters.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestReceptionHandlerParameters.java
index 2dde9666..c02b96bc 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestReceptionHandlerParameters.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestReceptionHandlerParameters.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * 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.
@@ -20,12 +21,13 @@
package org.onap.policy.distribution.main.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.assertTrue;
import org.junit.Test;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.distribution.reception.parameters.PluginHandlerParameters;
import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters;
@@ -43,7 +45,7 @@ public class TestReceptionHandlerParameters {
final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters(
CommonTestData.RECEPTION_HANDLER_TYPE, CommonTestData.RECEPTION_HANDLER_CLASS_NAME,
CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS, pHParameters);
- final GroupValidationResult validationResult = rHParameters.validate();
+ final ValidationResult validationResult = rHParameters.validate();
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType());
assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME, rHParameters.getReceptionHandlerClassName());
assertEquals(CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS,
@@ -58,16 +60,14 @@ public class TestReceptionHandlerParameters {
final ReceptionHandlerParameters rHParameters =
new ReceptionHandlerParameters(null, CommonTestData.RECEPTION_HANDLER_CLASS_NAME,
CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS, pHParameters);
- final GroupValidationResult validationResult = rHParameters.validate();
+ final ValidationResult validationResult = rHParameters.validate();
assertEquals(null, rHParameters.getReceptionHandlerType());
assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME, rHParameters.getReceptionHandlerClassName());
assertEquals(CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS,
rHParameters.getReceptionHandlerConfigurationName());
assertEquals(pHParameters, rHParameters.getPluginHandlerParameters());
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult()
- .contains("field \"receptionHandlerType\" type \"java.lang.String\" value \"null\" INVALID, "
- + "must be a non-blank string"));
+ assertThat(validationResult.getResult()).contains("\"receptionHandlerType\" value \"null\" INVALID, is null");
}
@Test
@@ -76,16 +76,15 @@ public class TestReceptionHandlerParameters {
final ReceptionHandlerParameters rHParameters =
new ReceptionHandlerParameters(CommonTestData.RECEPTION_HANDLER_TYPE, null,
CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS, pHParameters);
- final GroupValidationResult validationResult = rHParameters.validate();
+ final ValidationResult validationResult = rHParameters.validate();
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType());
assertEquals(null, rHParameters.getReceptionHandlerClassName());
assertEquals(CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS,
rHParameters.getReceptionHandlerConfigurationName());
assertEquals(pHParameters, rHParameters.getPluginHandlerParameters());
assertFalse(validationResult.isValid());
- assertTrue(validationResult.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"));
+ assertThat(validationResult.getResult())
+ .contains("\"receptionHandlerClassName\" value \"null\" INVALID, is null");
}
@Test
@@ -94,14 +93,12 @@ public class TestReceptionHandlerParameters {
final ReceptionHandlerParameters rHParameters =
new ReceptionHandlerParameters("", CommonTestData.RECEPTION_HANDLER_CLASS_NAME,
CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS, pHParameters);
- final GroupValidationResult validationResult = rHParameters.validate();
+ final ValidationResult validationResult = rHParameters.validate();
assertEquals("", rHParameters.getReceptionHandlerType());
assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME, rHParameters.getReceptionHandlerClassName());
assertEquals(pHParameters, rHParameters.getPluginHandlerParameters());
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult()
- .contains("field \"receptionHandlerType\" type \"java.lang.String\" value \"\" INVALID, "
- + "must be a non-blank string"));
+ assertThat(validationResult.getResult()).contains("\"receptionHandlerType\" value \"\" INVALID, is blank");
}
@Test
@@ -110,16 +107,14 @@ public class TestReceptionHandlerParameters {
final ReceptionHandlerParameters rHParameters =
new ReceptionHandlerParameters(CommonTestData.RECEPTION_HANDLER_TYPE, "",
CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS, pHParameters);
- final GroupValidationResult validationResult = rHParameters.validate();
+ final ValidationResult validationResult = rHParameters.validate();
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType());
assertEquals("", rHParameters.getReceptionHandlerClassName());
assertEquals(CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS,
rHParameters.getReceptionHandlerConfigurationName());
assertEquals(pHParameters, rHParameters.getPluginHandlerParameters());
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult()
- .contains("field \"receptionHandlerClassName\" type \"java.lang.String\" value \"\" INVALID, "
- + "must be a non-blank string containing full class name " + "of the reception handler"));
+ assertThat(validationResult.getResult()).contains("\"receptionHandlerClassName\" value \"\" INVALID, is blank");
}
@Test
@@ -128,9 +123,9 @@ public class TestReceptionHandlerParameters {
final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters(
CommonTestData.RECEPTION_HANDLER_TYPE, CommonTestData.RECEPTION_HANDLER_CLASS_NAME,
CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS, pHParameters);
- GroupValidationResult result = rHParameters.validate();
+ ValidationResult result = rHParameters.validate();
assertFalse(result.isValid());
- assertTrue(result.getResult().endsWith("must have at least one policy forwarder\n"));
+ assertThat(result.getResult()).contains("\"policyForwarders\"", "minimum");
}
@Test
@@ -140,7 +135,7 @@ public class TestReceptionHandlerParameters {
final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters(
CommonTestData.RECEPTION_HANDLER_TYPE, CommonTestData.RECEPTION_HANDLER_CLASS_NAME + "Invalid",
CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS, pHParameters);
- final GroupValidationResult validationResult = rHParameters.validate();
+ final ValidationResult validationResult = rHParameters.validate();
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType());
assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME + "Invalid",
rHParameters.getReceptionHandlerClassName());
@@ -148,6 +143,6 @@ public class TestReceptionHandlerParameters {
rHParameters.getReceptionHandlerConfigurationName());
assertEquals(pHParameters, rHParameters.getPluginHandlerParameters());
assertFalse(validationResult.isValid());
- assertTrue(validationResult.getResult().contains("reception handler class not found in classpath"));
+ assertThat(validationResult.getResult()).contains("\"receptionHandlerClassName\"", "classpath");
}
}
diff --git a/main/src/test/resources/expectedValidationResults/InvalidDecoderAndForwarderParameters.txt b/main/src/test/resources/expectedValidationResults/InvalidDecoderAndForwarderParameters.txt
index a5e84f5c..ebad6984 100644
--- a/main/src/test/resources/expectedValidationResults/InvalidDecoderAndForwarderParameters.txt
+++ b/main/src/test/resources/expectedValidationResults/InvalidDecoderAndForwarderParameters.txt
@@ -1,17 +1,22 @@
validation error(s) on parameters from "parameters/DistributionConfigParameters_InvalidDecoderAndForwarderParameters.json"
-parameter group "SDCDistributionGroup" type "org.onap.policy.distribution.main.parameters.DistributionParameterGroup" INVALID, parameter group has status INVALID
- parameter group map "receptionHandlerParameters" INVALID, parameter group map has status INVALID
- parameter group "null_DummyReceptionHandler" type "org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters" INVALID, parameter group has status INVALID
- parameter group "null_PluginHandler" type "org.onap.policy.distribution.reception.parameters.PluginHandlerParameters" INVALID, parameter group has status INVALID
- parameter group map "policyDecoders" INVALID, parameter group map has status INVALID
- parameter group "" type "org.onap.policy.distribution.reception.parameters.PolicyDecoderParameters" INVALID, parameter group has status INVALID
- field "decoderType" type "java.lang.String" value "" INVALID, must be a non-blank string
- field "decoderClassName" type "java.lang.String" value "org.onap.policy.distribution.main.testclasses.PolicyDecoderApexPdpa" INVALID, policy decoder class not found in classpath
- parameter group "DROOLS" type "org.onap.policy.distribution.reception.parameters.PolicyDecoderParameters" INVALID, parameter group has status INVALID
- field "decoderClassName" type "java.lang.String" value "" INVALID, must be a non-blank string containing full class name of the decoder
- parameter group map "policyForwarders" INVALID, parameter group map has status INVALID
- parameter group "" type "org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters" INVALID, parameter group has status INVALID
- field "forwarderType" type "java.lang.String" value "" INVALID, must be a non-blank string
- field "forwarderClassName" type "java.lang.String" value "org.onap.policy.distribution.main.testclasses.PapStandalonePolicyForwarder" INVALID, policy forwarder class not found in classpath
- parameter group "PAPEngineForwarder" type "org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters" INVALID, parameter group has status INVALID
- field "forwarderClassName" type "java.lang.String" value "" INVALID, must be a non-blank string containing full class name of the forwarder \ No newline at end of file
+"DistributionParameterGroup" INVALID, item has status INVALID
+ "receptionHandlerParameters" INVALID, item has status INVALID
+ "DummyReceptionHandler" INVALID, item has status INVALID
+ "ReceptionHandlerParameters" INVALID, item has status INVALID
+ "PluginHandlerParameters" INVALID, item has status INVALID
+ "policyDecoders" INVALID, item has status INVALID
+ "APEXDecoder" INVALID, item has status INVALID
+ "PolicyDecoderParameters" INVALID, item has status INVALID
+ item "decoderType" value "" INVALID, is blank
+ item "decoderClassName" value "org.onap.policy.distribution.main.testclasses.PolicyDecoderApexPdpa" INVALID, class is not in the classpath
+ "DROOLSDecoder" INVALID, item has status INVALID
+ "PolicyDecoderParameters" INVALID, item has status INVALID
+ item "decoderClassName" value "" INVALID, is blank
+ "policyForwarders" INVALID, item has status INVALID
+ "PAPStandaloneForwarder" INVALID, item has status INVALID
+ "PolicyForwarderParameters" INVALID, item has status INVALID
+ item "forwarderType" value "" INVALID, is blank
+ item "forwarderClassName" value "org.onap.policy.distribution.main.testclasses.PapStandalonePolicyForwarder" INVALID, class is not in the classpath
+ "PAPEngineForwarder" INVALID, item has status INVALID
+ "PolicyForwarderParameters" INVALID, item has status INVALID
+ item "forwarderClassName" value "" INVALID, is blank
diff --git a/main/src/test/resources/expectedValidationResults/InvalidReceptionHandlerParameters.txt b/main/src/test/resources/expectedValidationResults/InvalidReceptionHandlerParameters.txt
index 37c3457d..9879892a 100644
--- a/main/src/test/resources/expectedValidationResults/InvalidReceptionHandlerParameters.txt
+++ b/main/src/test/resources/expectedValidationResults/InvalidReceptionHandlerParameters.txt
@@ -1,6 +1,7 @@
validation error(s) on parameters from "parameters/DistributionConfigParameters_InvalidReceptionHandlerParameters.json"
-parameter group "SDCDistributionGroup" type "org.onap.policy.distribution.main.parameters.DistributionParameterGroup" INVALID, parameter group has status INVALID
- parameter group map "receptionHandlerParameters" INVALID, parameter group map has status INVALID
- parameter group "null_" type "org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters" INVALID, parameter group has status INVALID
- field "receptionHandlerType" type "java.lang.String" value "" INVALID, must be a non-blank string
- field "receptionHandlerClassName" type "java.lang.String" value "org.onap.policy.distribution.main.testclasses.InvalidSdcReceptionHandler" INVALID, reception handler class not found in classpath
+"DistributionParameterGroup" INVALID, item has status INVALID
+ "receptionHandlerParameters" INVALID, item has status INVALID
+ "DummyReceptionHandler" INVALID, item has status INVALID
+ "ReceptionHandlerParameters" INVALID, item has status INVALID
+ item "receptionHandlerType" value "" INVALID, is blank
+ item "receptionHandlerClassName" value "org.onap.policy.distribution.main.testclasses.InvalidSdcReceptionHandler" INVALID, class is not in the classpath
diff --git a/main/src/test/resources/expectedValidationResults/InvalidRestServerParameters.txt b/main/src/test/resources/expectedValidationResults/InvalidRestServerParameters.txt
index f3152e41..5ae0c819 100644
--- a/main/src/test/resources/expectedValidationResults/InvalidRestServerParameters.txt
+++ b/main/src/test/resources/expectedValidationResults/InvalidRestServerParameters.txt
@@ -1,7 +1,7 @@
validation error(s) on parameters from "parameters/DistributionConfigParameters_InvalidRestServerParameters.json"
-parameter group "SDCDistributionGroup" type "org.onap.policy.distribution.main.parameters.DistributionParameterGroup" INVALID, parameter group has status INVALID
- parameter group "RestServerParameters" type "org.onap.policy.common.endpoints.parameters.RestServerParameters" INVALID, parameter group has status INVALID
- field "host" type "java.lang.String" value "" INVALID, must be a non-blank string
- field "port" type "int" value "-1" INVALID, must be >= 1
- field "userName" type "java.lang.String" value "" INVALID, must be a non-blank string
- field "password" type "java.lang.String" value "" INVALID, must be a non-blank string \ No newline at end of file
+"DistributionParameterGroup" INVALID, item has status INVALID
+ "RestServerParameters" INVALID, item has status INVALID
+ item "host" value "" INVALID, is blank
+ item "port" value "-1" INVALID, is below the minimum value: 1
+ item "userName" value "" INVALID, is blank
+ item "password" value "" INVALID, is blank