From e705197bb18af558fb7ea853b01e1297521763f2 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Wed, 29 Aug 2018 16:20:52 +0100 Subject: 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 --- .../parameters/TestDistributionParameterGroup.java | 139 ++++++++++----------- .../TestDistributionParameterHandler.java | 6 +- .../parameters/TestPluginHandlerParameters.java | 35 +++--- .../parameters/TestReceptionHandlerParameters.java | 88 +++++++------ 4 files changed, 130 insertions(+), 138 deletions(-) (limited to 'main/src/test/java') 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 receptionHandlerParameters = - commonTestData.getReceptionHandlerParameters(false); + final Map 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 receptionHandlerParameters = - commonTestData.getReceptionHandlerParameters(false); + final Map 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 receptionHandlerParameters = - commonTestData.getReceptionHandlerParameters(false); + final Map 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 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 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 receptionHandlerParameters = - commonTestData.getReceptionHandlerParameters(false); + final Map 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 policyDecoders = commonTestData.getPolicyDecoders(true); - final Map 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 policyDecoders = commonTestData.getPolicyDecoders(true); + final Map 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 policyForwarders = commonTestData.getPolicyForwarders(true); - final Map 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 policyForwarders = commonTestData.getPolicyForwarders(true); + final Map 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()); -- cgit 1.2.3-korg