aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-08-29 16:20:52 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-08-29 17:51:46 +0100
commite705197bb18af558fb7ea853b01e1297521763f2 (patch)
tree2bb2edc2a764d5fa5871c9485f20f577f1d02e51
parentd7a69ea29e4ea46231cec1d16788d9451793a2a7 (diff)
Parameter Service Interface Changes
Changes to distribution due to changes to parameter services, mainly addition of setName() to parameter service interface and correct handling of empty parameters Change-Id: I9523da6461874241d220f0feac61419ef6ebbb9d Issue-ID: POLICY-1035 Signed-off-by: liamfallon <liam.fallon@ericsson.com>
-rw-r--r--forwarding/src/main/java/org/onap/policy/distribution/forwarding/parameters/PolicyForwarderParameters.java10
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterGroup.java10
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterGroup.java139
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java6
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/parameters/TestPluginHandlerParameters.java35
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/parameters/TestReceptionHandlerParameters.java88
-rw-r--r--main/src/test/resources/expectedValidationResults/InvalidDecoderAndForwarderParameters.txt10
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderParameters.java10
8 files changed, 163 insertions, 145 deletions
diff --git a/forwarding/src/main/java/org/onap/policy/distribution/forwarding/parameters/PolicyForwarderParameters.java b/forwarding/src/main/java/org/onap/policy/distribution/forwarding/parameters/PolicyForwarderParameters.java
index 7306cc64..28a1b1be 100644
--- a/forwarding/src/main/java/org/onap/policy/distribution/forwarding/parameters/PolicyForwarderParameters.java
+++ b/forwarding/src/main/java/org/onap/policy/distribution/forwarding/parameters/PolicyForwarderParameters.java
@@ -72,7 +72,15 @@ public class PolicyForwarderParameters implements ParameterGroup {
*/
@Override
public String getName() {
- return null;
+ return getForwarderType();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setName(final String name) {
+ this.forwarderType = name;
}
/**
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 dc114c1d..a188fb04 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
@@ -62,6 +62,16 @@ public class DistributionParameterGroup implements ParameterGroup {
}
/**
+ * 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
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 6d5135ee..a2d72585 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
@@ -42,97 +42,98 @@ public class TestDistributionParameterGroup {
@Test
public void testDistributionParameterGroup() {
final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false);
- final Map<String, ReceptionHandlerParameters> receptionHandlerParameters =
- commonTestData.getReceptionHandlerParameters(false);
+ final Map<String, ReceptionHandlerParameters> receptionHandlerParameters = commonTestData
+ .getReceptionHandlerParameters(false);
final DistributionParameterGroup distributionParameters = new DistributionParameterGroup(
- CommonTestData.DISTRIBUTION_GROUP_NAME, restServerParameters, receptionHandlerParameters);
+ CommonTestData.DISTRIBUTION_GROUP_NAME, restServerParameters, receptionHandlerParameters);
final GroupValidationResult validationResult = distributionParameters.validate();
assertTrue(validationResult.isValid());
assertEquals(restServerParameters.getHost(), distributionParameters.getRestServerParameters().getHost());
assertEquals(restServerParameters.getPort(), distributionParameters.getRestServerParameters().getPort());
assertEquals(restServerParameters.getUserName(),
- distributionParameters.getRestServerParameters().getUserName());
+ distributionParameters.getRestServerParameters().getUserName());
assertEquals(restServerParameters.getPassword(),
- distributionParameters.getRestServerParameters().getPassword());
+ distributionParameters.getRestServerParameters().getPassword());
assertEquals(CommonTestData.DISTRIBUTION_GROUP_NAME, distributionParameters.getName());
- assertEquals(
- receptionHandlerParameters.get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY).getReceptionHandlerType(),
- distributionParameters.getReceptionHandlerParameters().get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
- .getReceptionHandlerType());
- assertEquals(
- receptionHandlerParameters.get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
+ assertEquals(receptionHandlerParameters.get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
+ .getReceptionHandlerType(),
+ distributionParameters.getReceptionHandlerParameters()
+ .get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY).getReceptionHandlerType());
+ assertEquals(receptionHandlerParameters.get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
.getReceptionHandlerClassName(),
- distributionParameters.getReceptionHandlerParameters().get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
- .getReceptionHandlerClassName());
- assertEquals(
- receptionHandlerParameters.get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY).getPluginHandlerParameters(),
- distributionParameters.getReceptionHandlerParameters().get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
- .getPluginHandlerParameters());
+ distributionParameters.getReceptionHandlerParameters()
+ .get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
+ .getReceptionHandlerClassName());
+ assertEquals(receptionHandlerParameters.get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
+ .getPluginHandlerParameters(),
+ distributionParameters.getReceptionHandlerParameters()
+ .get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY).getPluginHandlerParameters());
}
@Test
public void testDistributionParameterGroup_NullName() {
final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false);
- final Map<String, ReceptionHandlerParameters> receptionHandlerParameters =
- commonTestData.getReceptionHandlerParameters(false);
+ final Map<String, ReceptionHandlerParameters> receptionHandlerParameters = commonTestData
+ .getReceptionHandlerParameters(false);
- final DistributionParameterGroup distributionParameters =
- new DistributionParameterGroup(null, restServerParameters, receptionHandlerParameters);
+ final DistributionParameterGroup distributionParameters = new DistributionParameterGroup(null,
+ restServerParameters, receptionHandlerParameters);
final GroupValidationResult validationResult = distributionParameters.validate();
assertFalse(validationResult.isValid());
assertEquals(null, distributionParameters.getName());
- assertEquals(
- receptionHandlerParameters.get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY).getReceptionHandlerType(),
- distributionParameters.getReceptionHandlerParameters().get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
- .getReceptionHandlerType());
- assertEquals(
- receptionHandlerParameters.get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
+ assertEquals(receptionHandlerParameters.get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
+ .getReceptionHandlerType(),
+ distributionParameters.getReceptionHandlerParameters()
+ .get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY).getReceptionHandlerType());
+ assertEquals(receptionHandlerParameters.get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
.getReceptionHandlerClassName(),
- distributionParameters.getReceptionHandlerParameters().get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
- .getReceptionHandlerClassName());
- assertEquals(
- 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"));
+ distributionParameters.getReceptionHandlerParameters()
+ .get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
+ .getReceptionHandlerClassName());
+ assertEquals(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"));
}
@Test
public void testDistributionParameterGroup_EmptyName() {
final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false);
- final Map<String, ReceptionHandlerParameters> receptionHandlerParameters =
- commonTestData.getReceptionHandlerParameters(false);
+ final Map<String, ReceptionHandlerParameters> receptionHandlerParameters = commonTestData
+ .getReceptionHandlerParameters(false);
- final DistributionParameterGroup distributionParameters =
- new DistributionParameterGroup("", restServerParameters, receptionHandlerParameters);
+ final DistributionParameterGroup distributionParameters = new DistributionParameterGroup("",
+ restServerParameters, receptionHandlerParameters);
final GroupValidationResult validationResult = distributionParameters.validate();
assertFalse(validationResult.isValid());
assertEquals("", distributionParameters.getName());
- assertEquals(
- receptionHandlerParameters.get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY).getReceptionHandlerType(),
- distributionParameters.getReceptionHandlerParameters().get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
- .getReceptionHandlerType());
- assertEquals(
- receptionHandlerParameters.get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
+ assertEquals(receptionHandlerParameters.get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
+ .getReceptionHandlerType(),
+ distributionParameters.getReceptionHandlerParameters()
+ .get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY).getReceptionHandlerType());
+ assertEquals(receptionHandlerParameters.get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
.getReceptionHandlerClassName(),
- distributionParameters.getReceptionHandlerParameters().get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
- .getReceptionHandlerClassName());
- assertEquals(
- 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"));
+ distributionParameters.getReceptionHandlerParameters()
+ .get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
+ .getReceptionHandlerClassName());
+ assertEquals(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"));
}
@Test
public void testDistributionParameterGroup_NullReceptionHandlerParameters() {
final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false);
try {
- final DistributionParameterGroup distributionParameters =
- new DistributionParameterGroup(CommonTestData.DISTRIBUTION_GROUP_NAME, restServerParameters, null);
+ final DistributionParameterGroup distributionParameters = new DistributionParameterGroup(
+ CommonTestData.DISTRIBUTION_GROUP_NAME, restServerParameters, null);
distributionParameters.validate();
fail("test should throw an exception here");
} catch (final Exception e) {
@@ -144,31 +145,29 @@ public class TestDistributionParameterGroup {
@Test
public void testDistributionParameterGroup_EmptyReceptionHandlerParameters() {
final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false);
- final Map<String, ReceptionHandlerParameters> receptionHandlerParameters =
- commonTestData.getReceptionHandlerParameters(true);
- try {
- final DistributionParameterGroup distributionParameters = new DistributionParameterGroup(
- CommonTestData.DISTRIBUTION_GROUP_NAME, restServerParameters, receptionHandlerParameters);
- distributionParameters.validate();
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertTrue(e.getMessage().contains("parameter not a regular parameter: receptionHandlerParameters"));
- }
+ final Map<String, ReceptionHandlerParameters> receptionHandlerParameters = commonTestData
+ .getReceptionHandlerParameters(true);
+ final DistributionParameterGroup distributionParameters = new DistributionParameterGroup(
+ CommonTestData.DISTRIBUTION_GROUP_NAME, restServerParameters, receptionHandlerParameters);
+ distributionParameters.validate();
+ GroupValidationResult result = distributionParameters.validate();
+ assertFalse(result.isValid());
+ assertTrue(result.getResult().endsWith("must have at least one reception handler\n"));
}
@Test
public void testDistributionParameterGroup_EmptyRestServerParameters() {
final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(true);
- final Map<String, ReceptionHandlerParameters> receptionHandlerParameters =
- commonTestData.getReceptionHandlerParameters(false);
+ final Map<String, ReceptionHandlerParameters> receptionHandlerParameters = commonTestData
+ .getReceptionHandlerParameters(false);
final DistributionParameterGroup distributionParameters = new DistributionParameterGroup(
- CommonTestData.DISTRIBUTION_GROUP_NAME, restServerParameters, receptionHandlerParameters);
+ CommonTestData.DISTRIBUTION_GROUP_NAME, restServerParameters, receptionHandlerParameters);
final GroupValidationResult validationResult = distributionParameters.validate();
assertFalse(validationResult.isValid());
assertTrue(validationResult.getResult()
- .contains("\"org.onap.policy.distribution.main.parameters.RestServerParameters\" INVALID, "
- + "parameter group has status INVALID"));
+ .contains("\"org.onap.policy.distribution.main.parameters.RestServerParameters\" INVALID, "
+ + "parameter group has status INVALID"));
}
}
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 25f24211..8b474984 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
@@ -202,7 +202,7 @@ public class TestDistributionParameterHandler {
new DistributionParameterHandler().getParameters(arguments);
fail("test should throw an exception here");
} catch (final Exception e) {
- assertTrue(e.getMessage().contains("parameter not a regular parameter: receptionHandlerParameters"));
+ assertTrue(e.getMessage().contains("must have at least one reception handler\n"));
}
}
@@ -250,7 +250,7 @@ public class TestDistributionParameterHandler {
new DistributionParameterHandler().getParameters(arguments);
fail("test should throw an exception here");
} catch (final Exception e) {
- assertTrue(e.getMessage().contains("parameter not a regular parameter: policyDecoders"));
+ assertTrue(e.getMessage().contains("must have at least one policy decoder\n"));
}
}
@@ -266,7 +266,7 @@ public class TestDistributionParameterHandler {
new DistributionParameterHandler().getParameters(arguments);
fail("test should throw an exception here");
} catch (final Exception e) {
- assertTrue(e.getMessage().contains("parameter not a regular parameter: policyForwarders"));
+ assertTrue(e.getMessage().endsWith("must have at least one policy forwarder\n"));
}
}
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 5e94dc90..552ee50c 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
@@ -21,6 +21,7 @@
package org.onap.policy.distribution.main.parameters;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -47,9 +48,9 @@ public class TestPluginHandlerParameters {
final PluginHandlerParameters pHParameters = new PluginHandlerParameters(policyDecoders, policyForwarders);
final GroupValidationResult validationResult = pHParameters.validate();
assertEquals(policyDecoders.get(CommonTestData.DUMMY_DECODER_KEY),
- pHParameters.getPolicyDecoders().get(CommonTestData.DUMMY_DECODER_KEY));
+ pHParameters.getPolicyDecoders().get(CommonTestData.DUMMY_DECODER_KEY));
assertEquals(policyForwarders.get(CommonTestData.DUMMY_ENGINE_FORWARDER_KEY),
- pHParameters.getPolicyForwarders().get(CommonTestData.DUMMY_ENGINE_FORWARDER_KEY));
+ pHParameters.getPolicyForwarders().get(CommonTestData.DUMMY_ENGINE_FORWARDER_KEY));
assertTrue(validationResult.isValid());
}
@@ -79,27 +80,21 @@ public class TestPluginHandlerParameters {
@Test
public void testPluginHandlerParameters_EmptyPolicyDecoders() {
- try {
- final Map<String, PolicyDecoderParameters> policyDecoders = commonTestData.getPolicyDecoders(true);
- final Map<String, PolicyForwarderParameters> policyForwarders = commonTestData.getPolicyForwarders(false);
- final PluginHandlerParameters pHParameters = new PluginHandlerParameters(policyDecoders, policyForwarders);
- pHParameters.validate();
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertTrue(e.getMessage().contains("parameter not a regular parameter: policyDecoders"));
- }
+ 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();
+ assertFalse(result.isValid());
+ assertTrue(result.getResult().endsWith("must have at least one policy decoder\n"));
}
@Test
public void testPluginHandlerParameters_EmptyPolicyForwarders() {
- try {
- final Map<String, PolicyForwarderParameters> policyForwarders = commonTestData.getPolicyForwarders(true);
- final Map<String, PolicyDecoderParameters> policyDecoders = commonTestData.getPolicyDecoders(false);
- final PluginHandlerParameters pHParameters = new PluginHandlerParameters(policyDecoders, policyForwarders);
- pHParameters.validate();
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertTrue(e.getMessage().contains("parameter not a regular parameter: policyForwarders"));
- }
+ 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();
+ assertFalse(result.isValid());
+ assertTrue(result.getResult().endsWith("must have at least one policy forwarder\n"));
}
}
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 960629e4..ab86cb65 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
@@ -23,7 +23,6 @@ package org.onap.policy.distribution.main.parameters;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import org.junit.Test;
import org.onap.policy.common.parameters.GroupValidationResult;
@@ -42,11 +41,11 @@ public class TestReceptionHandlerParameters {
@Test
public void testReceptionHandlerParameters() {
final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
- final PssdConfigurationParametersGroup pssdConfiguration =
- commonTestData.getPssdConfigurationParametersGroup(false);
- final ReceptionHandlerParameters rHParameters =
- new ReceptionHandlerParameters(CommonTestData.RECEPTION_HANDLER_TYPE,
- CommonTestData.RECEPTION_HANDLER_CLASS_NAME, pssdConfiguration, pHParameters);
+ final PssdConfigurationParametersGroup pssdConfiguration = commonTestData
+ .getPssdConfigurationParametersGroup(false);
+ final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters(
+ CommonTestData.RECEPTION_HANDLER_TYPE, CommonTestData.RECEPTION_HANDLER_CLASS_NAME,
+ pssdConfiguration, pHParameters);
final GroupValidationResult validationResult = rHParameters.validate();
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType());
assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME, rHParameters.getReceptionHandlerClassName());
@@ -58,10 +57,10 @@ public class TestReceptionHandlerParameters {
@Test
public void testReceptionHandlerParameters_NullReceptionHandlerType() {
final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
- final PssdConfigurationParametersGroup pssdConfiguration =
- commonTestData.getPssdConfigurationParametersGroup(false);
+ final PssdConfigurationParametersGroup pssdConfiguration = commonTestData
+ .getPssdConfigurationParametersGroup(false);
final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters(null,
- CommonTestData.RECEPTION_HANDLER_CLASS_NAME, pssdConfiguration, pHParameters);
+ CommonTestData.RECEPTION_HANDLER_CLASS_NAME, pssdConfiguration, pHParameters);
final GroupValidationResult validationResult = rHParameters.validate();
assertEquals(null, rHParameters.getReceptionHandlerType());
assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME, rHParameters.getReceptionHandlerClassName());
@@ -69,52 +68,53 @@ public class TestReceptionHandlerParameters {
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"));
+ .contains("field \"receptionHandlerType\" type \"java.lang.String\" value \"null\" INVALID, "
+ + "must be a non-blank string"));
}
@Test
public void testReceptionHandlerParameters_NullReceptionHandlerClassName() {
final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
- final PssdConfigurationParametersGroup pssdConfiguration =
- commonTestData.getPssdConfigurationParametersGroup(false);
+ final PssdConfigurationParametersGroup pssdConfiguration = commonTestData
+ .getPssdConfigurationParametersGroup(false);
final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters(
- CommonTestData.RECEPTION_HANDLER_TYPE, null, pssdConfiguration, pHParameters);
+ CommonTestData.RECEPTION_HANDLER_TYPE, null, pssdConfiguration, pHParameters);
final GroupValidationResult validationResult = rHParameters.validate();
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType());
assertEquals(null, rHParameters.getReceptionHandlerClassName());
assertEquals(pssdConfiguration, rHParameters.getPssdConfigurationParametersGroup());
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"));
+ 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"));
}
@Test
public void testReceptionHandlerParameters_EmptyReceptionHandlerType() {
final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
- final PssdConfigurationParametersGroup pssdConfiguration =
- commonTestData.getPssdConfigurationParametersGroup(false);
+ final PssdConfigurationParametersGroup pssdConfiguration = commonTestData
+ .getPssdConfigurationParametersGroup(false);
final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters("",
- CommonTestData.RECEPTION_HANDLER_CLASS_NAME, pssdConfiguration, pHParameters);
+ CommonTestData.RECEPTION_HANDLER_CLASS_NAME, pssdConfiguration, pHParameters);
final GroupValidationResult 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"));
+ .contains("field \"receptionHandlerType\" type \"java.lang.String\" value \"\" INVALID, "
+ + "must be a non-blank string"));
}
@Test
public void testReceptionHandlerParameters_EmptyReceptionHandlerClassName() {
final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
- final PssdConfigurationParametersGroup pssdConfiguration =
- commonTestData.getPssdConfigurationParametersGroup(false);
+ final PssdConfigurationParametersGroup pssdConfiguration = commonTestData
+ .getPssdConfigurationParametersGroup(false);
final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters(
- CommonTestData.RECEPTION_HANDLER_TYPE, "", pssdConfiguration, pHParameters);
+ CommonTestData.RECEPTION_HANDLER_TYPE, "", pssdConfiguration, pHParameters);
final GroupValidationResult validationResult = rHParameters.validate();
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType());
assertEquals("", rHParameters.getReceptionHandlerClassName());
@@ -122,38 +122,36 @@ public class TestReceptionHandlerParameters {
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"));
+ .contains("field \"receptionHandlerClassName\" type \"java.lang.String\" value \"\" INVALID, "
+ + "must be a non-blank string containing full class name "
+ + "of the reception handler"));
}
@Test
public void testReceptionHandlerParameters_EmptyPluginHandler() {
- try {
- final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(true);
- final PssdConfigurationParametersGroup pssdConfiguration =
- commonTestData.getPssdConfigurationParametersGroup(false);
- final ReceptionHandlerParameters rHParameters =
- new ReceptionHandlerParameters(CommonTestData.RECEPTION_HANDLER_TYPE,
- CommonTestData.RECEPTION_HANDLER_CLASS_NAME, pssdConfiguration, pHParameters);
- rHParameters.validate();
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertTrue(e.getMessage().contains("parameter not a regular parameter: policyDecoders"));
- }
+ final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(true);
+ final PssdConfigurationParametersGroup pssdConfiguration = commonTestData
+ .getPssdConfigurationParametersGroup(false);
+ final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters(
+ CommonTestData.RECEPTION_HANDLER_TYPE, CommonTestData.RECEPTION_HANDLER_CLASS_NAME,
+ pssdConfiguration, pHParameters);
+ GroupValidationResult result = rHParameters.validate();
+ assertFalse(result.isValid());
+ assertTrue(result.getResult().endsWith("must have at least one policy forwarder\n"));
}
@Test
public void testReceptionHandlerParameters_InvalidReceptionHandlerClass() {
final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
- final PssdConfigurationParametersGroup pssdConfiguration =
- commonTestData.getPssdConfigurationParametersGroup(false);
- final ReceptionHandlerParameters rHParameters =
- new ReceptionHandlerParameters(CommonTestData.RECEPTION_HANDLER_TYPE,
- CommonTestData.RECEPTION_HANDLER_CLASS_NAME + "Invalid", pssdConfiguration, pHParameters);
+ final PssdConfigurationParametersGroup pssdConfiguration = commonTestData
+ .getPssdConfigurationParametersGroup(false);
+ final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters(
+ CommonTestData.RECEPTION_HANDLER_TYPE, CommonTestData.RECEPTION_HANDLER_CLASS_NAME + "Invalid",
+ pssdConfiguration, pHParameters);
final GroupValidationResult validationResult = rHParameters.validate();
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType());
assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME + "Invalid",
- rHParameters.getReceptionHandlerClassName());
+ rHParameters.getReceptionHandlerClassName());
assertEquals(pssdConfiguration, rHParameters.getPssdConfigurationParametersGroup());
assertEquals(pHParameters, rHParameters.getPluginHandlerParameters());
assertFalse(validationResult.isValid());
diff --git a/main/src/test/resources/expectedValidationResults/InvalidDecoderAndForwarderParameters.txt b/main/src/test/resources/expectedValidationResults/InvalidDecoderAndForwarderParameters.txt
index 41c7b2d0..392f8456 100644
--- a/main/src/test/resources/expectedValidationResults/InvalidDecoderAndForwarderParameters.txt
+++ b/main/src/test/resources/expectedValidationResults/InvalidDecoderAndForwarderParameters.txt
@@ -4,14 +4,14 @@ parameter group "SDCDistributionGroup" type "org.onap.policy.distribution.main.p
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 has status INVALID
- parameter group "null" type "org.onap.policy.distribution.reception.parameters.PolicyDecoderParameters" INVALID, parameter group 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 "null" type "org.onap.policy.distribution.reception.parameters.PolicyDecoderParameters" INVALID, parameter group has status INVALID
+ 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 has status INVALID
- parameter group "null" type "org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters" INVALID, parameter group 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 "null" 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
+ 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
diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderParameters.java b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderParameters.java
index 2d60b85e..0b7ae0b7 100644
--- a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderParameters.java
+++ b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderParameters.java
@@ -72,7 +72,15 @@ public class PolicyDecoderParameters implements ParameterGroup {
*/
@Override
public String getName() {
- return null;
+ return decoderType;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setName(final String name) {
+ this.decoderType = name;
}
/**