diff options
37 files changed, 733 insertions, 608 deletions
diff --git a/forwarding/pom.xml b/forwarding/pom.xml index 830f3724..4335a046 100644 --- a/forwarding/pom.xml +++ b/forwarding/pom.xml @@ -40,12 +40,12 @@ <dependency> <groupId>org.onap.policy.common</groupId> <artifactId>common-parameters</artifactId> - <version>1.3.0-SNAPSHOT</version> + <version>${policy.common.version}</version> </dependency> <dependency> <groupId>org.onap.policy.common</groupId> <artifactId>ONAP-Logging</artifactId> - <version>1.3.0-SNAPSHOT</version> + <version>${policy.common.version}</version> </dependency> </dependencies> </project> 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 57d04248..7306cc64 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 @@ -67,14 +67,16 @@ public class PolicyForwarderParameters implements ParameterGroup { return forwarderClassName; } + /** + * {@inheritDoc} + */ @Override public String getName() { return null; } /** - * Validate the policy forwarder parameters. - * + * {@inheritDoc} */ @Override public GroupValidationResult validate() { @@ -95,7 +97,7 @@ public class PolicyForwarderParameters implements ParameterGroup { try { Class.forName(forwarderClassName); } catch (final ClassNotFoundException exp) { - LOGGER.error("policy forwarder class not found in classpath", exp); + LOGGER.trace("policy forwarder class not found in classpath", exp); validationResult.setResult("forwarderClassName", ValidationStatus.INVALID, "policy forwarder class not found in classpath"); } diff --git a/forwarding/src/test/java/org/onap/policy/distribution/forwarding/PolicyDecodingExceptionTest.java b/forwarding/src/test/java/org/onap/policy/distribution/forwarding/PolicyDecodingExceptionTest.java index 4b9ed273..af820883 100644 --- a/forwarding/src/test/java/org/onap/policy/distribution/forwarding/PolicyDecodingExceptionTest.java +++ b/forwarding/src/test/java/org/onap/policy/distribution/forwarding/PolicyDecodingExceptionTest.java @@ -5,15 +5,15 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -21,20 +21,21 @@ package org.onap.policy.distribution.forwarding; import static org.junit.Assert.assertEquals; + import org.junit.Test; public class PolicyDecodingExceptionTest { @Test public void testPolicyDecodingExceptionString() { - PolicyForwardingException policyDecodingException = new PolicyForwardingException("error message"); + final PolicyForwardingException policyDecodingException = new PolicyForwardingException("error message"); assertEquals("error message", policyDecodingException.getMessage()); } @Test public void testPolicyDecodingExceptionStringThrowable() { - Exception cause = new IllegalArgumentException(); - PolicyForwardingException policyDecodingException = new PolicyForwardingException("error message", cause); + final Exception cause = new IllegalArgumentException(); + final PolicyForwardingException policyDecodingException = new PolicyForwardingException("error message", cause); assertEquals("error message", policyDecodingException.getMessage()); assertEquals(cause, policyDecodingException.getCause()); } diff --git a/main/pom.xml b/main/pom.xml index e027e44c..2b00e323 100644 --- a/main/pom.xml +++ b/main/pom.xml @@ -44,23 +44,13 @@ </dependency> <dependency> <groupId>org.onap.policy.common</groupId> - <artifactId>utils</artifactId> - <version>1.3.0-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.onap.policy.common</groupId> - <artifactId>common-parameters</artifactId> - <version>1.3.0-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.onap.policy.common</groupId> <artifactId>capabilities</artifactId> - <version>1.3.0-SNAPSHOT</version> + <version>${policy.common.version}</version> </dependency> <dependency> <groupId>org.onap.policy.common</groupId> <artifactId>policy-endpoints</artifactId> - <version>1.3.0-SNAPSHOT</version> + <version>${policy.common.version}</version> </dependency> <dependency> <groupId>commons-cli</groupId> diff --git a/main/src/main/java/org/onap/policy/distribution/main/PolicyDistributionException.java b/main/src/main/java/org/onap/policy/distribution/main/PolicyDistributionException.java index 807fd936..041f87cb 100644 --- a/main/src/main/java/org/onap/policy/distribution/main/PolicyDistributionException.java +++ b/main/src/main/java/org/onap/policy/distribution/main/PolicyDistributionException.java @@ -5,15 +5,15 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -39,9 +39,9 @@ public class PolicyDistributionException extends Exception { * Instantiates a new policy distribution exception with a message and a caused by exception. * * @param message the message - * @param e the exception that caused this exception to be thrown + * @param exp the exception that caused this exception to be thrown */ - public PolicyDistributionException(final String message, final Exception e) { - super(message, e); + public PolicyDistributionException(final String message, final Exception exp) { + super(message, exp); } } diff --git a/main/src/main/java/org/onap/policy/distribution/main/PolicyDistributionRuntimeException.java b/main/src/main/java/org/onap/policy/distribution/main/PolicyDistributionRuntimeException.java index 5999e680..385505a0 100644 --- a/main/src/main/java/org/onap/policy/distribution/main/PolicyDistributionRuntimeException.java +++ b/main/src/main/java/org/onap/policy/distribution/main/PolicyDistributionRuntimeException.java @@ -5,15 +5,15 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -39,9 +39,9 @@ public class PolicyDistributionRuntimeException extends RuntimeException { * Instantiates a new policy distribution runtime exception with a message and a caused by exception. * * @param message the message - * @param e the exception that caused this exception to be thrown + * @param exp the exception that caused this exception to be thrown */ - public PolicyDistributionRuntimeException(final String message, final Exception e) { - super(message, e); + public PolicyDistributionRuntimeException(final String message, final Exception exp) { + super(message, exp); } } diff --git a/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java b/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java index 62314bdf..70724a12 100644 --- a/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java +++ b/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java @@ -26,11 +26,10 @@ import java.util.Map; import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.common.parameters.ParameterService; -import org.onap.policy.distribution.forwarding.PolicyForwardingException; import org.onap.policy.distribution.main.PolicyDistributionException; import org.onap.policy.distribution.main.parameters.DistributionParameterGroup; import org.onap.policy.distribution.main.rest.DistributionRestServer; -import org.onap.policy.distribution.reception.decoding.PolicyDecodingException; +import org.onap.policy.distribution.reception.decoding.PluginInitializationException; import org.onap.policy.distribution.reception.handling.AbstractReceptionHandler; import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters; @@ -79,9 +78,9 @@ public class DistributionActivator { final AbstractReceptionHandler receptionHandler = receptionHandlerClass.newInstance(); receptionHandler.initialize(receptionHandlerParameters.getName()); receptionHandlersMap.put(receptionHandlerParameters.getName(), receptionHandler); - alive = true; + DistributionActivator.setAlive(true); } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException - | PolicyDecodingException | PolicyForwardingException exp) { + | PluginInitializationException exp) { throw new PolicyDistributionException(exp.getMessage(), exp); } } @@ -114,7 +113,7 @@ public class DistributionActivator { } receptionHandlersMap.clear(); deregisterToParameterService(distributionParameterGroup); - alive = false; + DistributionActivator.setAlive(true); // Stop the distribution rest server restServer.stop(); @@ -143,10 +142,10 @@ public class DistributionActivator { for (final ReceptionHandlerParameters params : distributionParameterGroup.getReceptionHandlerParameters() .values()) { params.setName(distributionParameterGroup.getName()); - params.getPSSDConfigurationParametersGroup().setName(distributionParameterGroup.getName()); + params.getPssdConfigurationParametersGroup().setName(distributionParameterGroup.getName()); params.getPluginHandlerParameters().setName(distributionParameterGroup.getName()); ParameterService.register(params); - ParameterService.register(params.getPSSDConfigurationParametersGroup()); + ParameterService.register(params.getPssdConfigurationParametersGroup()); ParameterService.register(params.getPluginHandlerParameters()); } } @@ -161,7 +160,7 @@ public class DistributionActivator { for (final ReceptionHandlerParameters params : distributionParameterGroup.getReceptionHandlerParameters() .values()) { ParameterService.deregister((params.getName())); - ParameterService.deregister((params.getPSSDConfigurationParametersGroup().getName())); + ParameterService.deregister((params.getPssdConfigurationParametersGroup().getName())); ParameterService.deregister((params.getPluginHandlerParameters().getName())); } } @@ -174,4 +173,13 @@ public class DistributionActivator { public static boolean isAlive() { return alive; } + + /** + * Change the alive status of distribution service. + * + * @param status the status + */ + public static void setAlive(final boolean status) { + alive = status; + } } diff --git a/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionCommandLineArguments.java b/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionCommandLineArguments.java index 7bd1d06d..b805456e 100644 --- a/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionCommandLineArguments.java +++ b/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionCommandLineArguments.java @@ -5,15 +5,15 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -69,7 +69,8 @@ public class DistributionCommandLineArguments { .build()); options.addOption(Option.builder("c") .longOpt("config-file") - .desc("the full path to the configuration file to use, the configuration file must be a Json file containing the policy distribution parameters") + .desc("the full path to the configuration file to use, " + + "the configuration file must be a Json file containing the policy distribution parameters") .hasArg() .argName("CONFIG_FILE") .required(false) @@ -117,7 +118,8 @@ public class DistributionCommandLineArguments { final String[] remainingArgs = commandLine.getArgs(); if (remainingArgs.length > 0 && commandLine.hasOption('c') || remainingArgs.length > 0) { - throw new PolicyDistributionException("too many command line arguments specified : " + Arrays.toString(args)); + throw new PolicyDistributionException( + "too many command line arguments specified : " + Arrays.toString(args)); } if (remainingArgs.length == 1) { @@ -150,7 +152,7 @@ public class DistributionCommandLineArguments { /** * Print version information for policy distribution. - * + * * @return the version string */ public String version() { @@ -166,10 +168,10 @@ public class DistributionCommandLineArguments { public String help(final String mainClassName) { final HelpFormatter helpFormatter = new HelpFormatter(); final StringWriter stringWriter = new StringWriter(); - final PrintWriter stringPW = new PrintWriter(stringWriter); + final PrintWriter printWriter = new PrintWriter(stringWriter); - helpFormatter.printHelp(stringPW, HELP_LINE_LENGTH, mainClassName + " [options...]", "options", options, 0, 0, - ""); + helpFormatter.printHelp(printWriter, HELP_LINE_LENGTH, mainClassName + " [options...]", "options", options, 0, + 0, ""); return stringWriter.toString(); } @@ -224,17 +226,18 @@ public class DistributionCommandLineArguments { } // The file name refers to a resource on the local file system - final URL fileURL = ResourceUtils.getUrl4Resource(fileName); - if (fileURL == null) { + final URL fileUrl = ResourceUtils.getUrl4Resource(fileName); + if (fileUrl == null) { throw new PolicyDistributionException(fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" does not exist"); } - final File theFile = new File(fileURL.getPath()); + final File theFile = new File(fileUrl.getPath()); if (!theFile.exists()) { throw new PolicyDistributionException(fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" does not exist"); } if (!theFile.isFile()) { - throw new PolicyDistributionException(fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" is not a normal file"); + throw new PolicyDistributionException( + fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" is not a normal file"); } if (!theFile.canRead()) { throw new PolicyDistributionException(fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" is ureadable"); diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java index 59f551cf..62ad0674 100644 --- a/main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java +++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java @@ -26,9 +26,9 @@ import java.util.List; import java.util.Map; import org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters; -import org.onap.policy.distribution.reception.parameters.PSSDConfigurationParametersGroup; import org.onap.policy.distribution.reception.parameters.PluginHandlerParameters; import org.onap.policy.distribution.reception.parameters.PolicyDecoderParameters; +import org.onap.policy.distribution.reception.parameters.PssdConfigurationParametersGroup; import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters; /** @@ -85,7 +85,7 @@ public class CommonTestData { if (!isEmpty) { final Map<String, PolicyDecoderParameters> policyDecoders = getPolicyDecoders(isEmpty); final Map<String, PolicyForwarderParameters> policyForwarders = getPolicyForwarders(isEmpty); - final PSSDConfigurationParametersGroup pssdConfiguration = getPSSDConfigurationParametersGroup(isEmpty);; + final PssdConfigurationParametersGroup pssdConfiguration = getPssdConfigurationParametersGroup(isEmpty);; final PluginHandlerParameters pHParameters = new PluginHandlerParameters(policyDecoders, policyForwarders); final ReceptionHandlerParameters rhParameters = new ReceptionHandlerParameters(RECEPTION_HANDLER_TYPE, RECEPTION_HANDLER_CLASS_NAME, pssdConfiguration, pHParameters); @@ -95,26 +95,26 @@ public class CommonTestData { } /** - * Returns an instance of PSSDConfigurationParametersGroup for test cases. + * Returns an instance of PssdConfigurationParametersGroup for test cases. * * @param isEmpty boolean value to represent that object created should be empty or not - * @return the PSSDConfigurationParametersGroup object + * @return the PssdConfigurationParametersGroup object */ - public PSSDConfigurationParametersGroup getPSSDConfigurationParametersGroup(final boolean isEmpty) { - final PSSDConfigurationParametersGroup pssdConfiguration; + public PssdConfigurationParametersGroup getPssdConfigurationParametersGroup(final boolean isEmpty) { + final PssdConfigurationParametersGroup pssdConfiguration; if (!isEmpty) { final List<String> messageBusAddress = new ArrayList<>(); messageBusAddress.add("localhost"); final List<String> artifactTypes = new ArrayList<>(); artifactTypes.add("TOSCA_CSAR"); - pssdConfiguration = new PSSDConfigurationParametersGroup.PSSDConfigurationBuilder() + pssdConfiguration = new PssdConfigurationParametersGroup.PssdConfigurationBuilder() .setAsdcAddress("localhost").setMessageBusAddress(messageBusAddress).setUser("policy") .setPassword("policy").setPollingInterval(20).setPollingTimeout(30).setConsumerId("policy-id") .setArtifactTypes(artifactTypes).setConsumerGroup("policy-group").setEnvironmentName("TEST") .setKeystorePath("").setKeystorePassword("").setActiveserverTlsAuth(false) .setIsFilterinEmptyResources(true).setIsUseHttpsWithDmaap(false).build(); } else { - pssdConfiguration = new PSSDConfigurationParametersGroup.PSSDConfigurationBuilder().build(); + pssdConfiguration = new PssdConfigurationParametersGroup.PssdConfigurationBuilder().build(); } return pssdConfiguration; } 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 69ff0f14..a324e3da 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 @@ -36,7 +36,8 @@ import org.onap.policy.distribution.main.startstop.DistributionCommandLineArgume public class TestDistributionParameterHandler { @Test public void testParameterHandlerNoParameterFile() throws PolicyDistributionException { - final String[] noArgumentString = { "-c", "parameters/NoParameterFile.json" }; + final String[] noArgumentString = + { "-c", "parameters/NoParameterFile.json" }; final DistributionCommandLineArguments noArguments = new DistributionCommandLineArguments(); noArguments.parse(noArgumentString); @@ -51,7 +52,8 @@ public class TestDistributionParameterHandler { @Test public void testParameterHandlerEmptyParameters() throws PolicyDistributionException { - final String[] emptyArgumentString = { "-c", "parameters/EmptyParameters.json" }; + final String[] emptyArgumentString = + { "-c", "parameters/EmptyParameters.json" }; final DistributionCommandLineArguments emptyArguments = new DistributionCommandLineArguments(); emptyArguments.parse(emptyArgumentString); @@ -66,7 +68,8 @@ public class TestDistributionParameterHandler { @Test public void testParameterHandlerBadParameters() throws PolicyDistributionException { - final String[] badArgumentString = { "-c", "parameters/BadParameters.json" }; + final String[] badArgumentString = + { "-c", "parameters/BadParameters.json" }; final DistributionCommandLineArguments badArguments = new DistributionCommandLineArguments(); badArguments.parse(badArgumentString); @@ -83,7 +86,8 @@ public class TestDistributionParameterHandler { @Test public void testParameterHandlerInvalidParameters() throws PolicyDistributionException { - final String[] invalidArgumentString = { "-c", "parameters/InvalidParameters.json" }; + final String[] invalidArgumentString = + { "-c", "parameters/InvalidParameters.json" }; final DistributionCommandLineArguments invalidArguments = new DistributionCommandLineArguments(); invalidArguments.parse(invalidArgumentString); @@ -100,7 +104,8 @@ public class TestDistributionParameterHandler { @Test public void testParameterHandlerNoParameters() throws PolicyDistributionException { - final String[] noArgumentString = { "-c", "parameters/NoParameters.json" }; + final String[] noArgumentString = + { "-c", "parameters/NoParameters.json" }; final DistributionCommandLineArguments noArguments = new DistributionCommandLineArguments(); noArguments.parse(noArgumentString); @@ -115,7 +120,8 @@ public class TestDistributionParameterHandler { @Test public void testParameterHandlerMinumumParameters() throws PolicyDistributionException { - final String[] minArgumentString = { "-c", "parameters/MinimumParameters.json" }; + final String[] minArgumentString = + { "-c", "parameters/MinimumParameters.json" }; final DistributionCommandLineArguments minArguments = new DistributionCommandLineArguments(); minArguments.parse(minArgumentString); @@ -126,7 +132,8 @@ public class TestDistributionParameterHandler { @Test public void testDistributionParameterGroup() throws PolicyDistributionException { - final String[] distributionConfigParameters = { "-c", "parameters/DistributionConfigParameters.json" }; + final String[] distributionConfigParameters = + { "-c", "parameters/DistributionConfigParameters.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); arguments.parse(distributionConfigParameters); @@ -148,7 +155,7 @@ public class TestDistributionParameterHandler { @Test public void testDistributionParameterGroup_InvalidName() throws PolicyDistributionException { final String[] distributionConfigParameters = - { "-c", "parameters/DistributionConfigParameters_InvalidName.json" }; + { "-c", "parameters/DistributionConfigParameters_InvalidName.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); arguments.parse(distributionConfigParameters); @@ -165,7 +172,7 @@ public class TestDistributionParameterHandler { @Test public void testDistributionParameterGroup_InvalidReceptionHandlerType() throws PolicyDistributionException { final String[] distributionConfigParameters = - { "-c", "parameters/DistributionConfigParameters_InvalidReceptionHandlerType.json" }; + { "-c", "parameters/DistributionConfigParameters_InvalidReceptionHandlerType.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); arguments.parse(distributionConfigParameters); @@ -183,7 +190,7 @@ public class TestDistributionParameterHandler { @Test public void testDistributionParameterGroup_InvalidPolicyDecoderType() throws PolicyDistributionException { final String[] distributionConfigParameters = - { "-c", "parameters/DistributionConfigParameters_InvalidPolicyDecoderType.json" }; + { "-c", "parameters/DistributionConfigParameters_InvalidPolicyDecoderType.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); arguments.parse(distributionConfigParameters); @@ -200,7 +207,7 @@ public class TestDistributionParameterHandler { @Test public void testDistributionParameterGroup_InvalidPolicyForwarderType() throws PolicyDistributionException { final String[] distributionConfigParameters = - { "-c", "parameters/DistributionConfigParameters_InvalidPolicyForwarderType.json" }; + { "-c", "parameters/DistributionConfigParameters_InvalidPolicyForwarderType.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); arguments.parse(distributionConfigParameters); @@ -217,7 +224,7 @@ public class TestDistributionParameterHandler { @Test public void testDistributionParameterGroup_NoReceptionHandler() throws PolicyDistributionException { final String[] distributionConfigParameters = - { "-c", "parameters/DistributionConfigParameters_NoReceptionHandler.json" }; + { "-c", "parameters/DistributionConfigParameters_NoReceptionHandler.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); arguments.parse(distributionConfigParameters); @@ -233,7 +240,7 @@ public class TestDistributionParameterHandler { @Test public void testDistributionParameterGroup_EmptyReceptionHandler() throws PolicyDistributionException { final String[] distributionConfigParameters = - { "-c", "parameters/DistributionConfigParameters_EmptyReceptionHandler.json" }; + { "-c", "parameters/DistributionConfigParameters_EmptyReceptionHandler.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); arguments.parse(distributionConfigParameters); @@ -249,7 +256,7 @@ public class TestDistributionParameterHandler { @Test public void testDistributionParameterGroup_NoPolicyDecoder() throws PolicyDistributionException { final String[] distributionConfigParameters = - { "-c", "parameters/DistributionConfigParameters_NoPolicyDecoder.json" }; + { "-c", "parameters/DistributionConfigParameters_NoPolicyDecoder.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); arguments.parse(distributionConfigParameters); @@ -265,7 +272,7 @@ public class TestDistributionParameterHandler { @Test public void testDistributionParameterGroup_NoPolicyForwarder() throws PolicyDistributionException { final String[] distributionConfigParameters = - { "-c", "parameters/DistributionConfigParameters_NoPolicyForwarder.json" }; + { "-c", "parameters/DistributionConfigParameters_NoPolicyForwarder.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); arguments.parse(distributionConfigParameters); @@ -281,7 +288,7 @@ public class TestDistributionParameterHandler { @Test public void testDistributionParameterGroup_EmptyPolicyDecoder() throws PolicyDistributionException { final String[] distributionConfigParameters = - { "-c", "parameters/DistributionConfigParameters_EmptyPolicyDecoder.json" }; + { "-c", "parameters/DistributionConfigParameters_EmptyPolicyDecoder.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); arguments.parse(distributionConfigParameters); @@ -297,7 +304,7 @@ public class TestDistributionParameterHandler { @Test public void testDistributionParameterGroup_EmptyPolicyForwarder() throws PolicyDistributionException { final String[] distributionConfigParameters = - { "-c", "parameters/DistributionConfigParameters_EmptyPolicyForwarder.json" }; + { "-c", "parameters/DistributionConfigParameters_EmptyPolicyForwarder.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); arguments.parse(distributionConfigParameters); @@ -313,7 +320,7 @@ public class TestDistributionParameterHandler { @Test public void testDistributionParameterGroup_InvalidReceptionHandlerClass() throws PolicyDistributionException { final String[] distributionConfigParameters = - { "-c", "parameters/DistributionConfigParameters_InvalidReceptionHandlerClass.json" }; + { "-c", "parameters/DistributionConfigParameters_InvalidReceptionHandlerClass.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); arguments.parse(distributionConfigParameters); @@ -329,7 +336,7 @@ public class TestDistributionParameterHandler { @Test public void testDistributionParameterGroup_InvalidPolicyDecoderClass() throws PolicyDistributionException { final String[] distributionConfigParameters = - { "-c", "parameters/DistributionConfigParameters_InvalidPolicyDecoderClass.json" }; + { "-c", "parameters/DistributionConfigParameters_InvalidPolicyDecoderClass.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); arguments.parse(distributionConfigParameters); @@ -345,7 +352,7 @@ public class TestDistributionParameterHandler { @Test public void testDistributionParameterGroup_InvalidPolicyForwarderClass() throws PolicyDistributionException { final String[] distributionConfigParameters = - { "-c", "parameters/DistributionConfigParameters_InvalidPolicyForwarderClass.json" }; + { "-c", "parameters/DistributionConfigParameters_InvalidPolicyForwarderClass.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); arguments.parse(distributionConfigParameters); @@ -361,7 +368,7 @@ public class TestDistributionParameterHandler { @Test public void testDistributionParameterGroup_InvalidRestServerHost() throws PolicyDistributionException { final String[] distributionConfigParameters = - { "-c", "parameters/DistributionConfigParameters_InvalidRestServerHost.json" }; + { "-c", "parameters/DistributionConfigParameters_InvalidRestServerHost.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); arguments.parse(distributionConfigParameters); @@ -378,7 +385,7 @@ public class TestDistributionParameterHandler { @Test public void testDistributionParameterGroup_InvalidRestServerPort() throws PolicyDistributionException { final String[] distributionConfigParameters = - { "-c", "parameters/DistributionConfigParameters_InvalidRestServerPort.json" }; + { "-c", "parameters/DistributionConfigParameters_InvalidRestServerPort.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); arguments.parse(distributionConfigParameters); @@ -395,7 +402,7 @@ public class TestDistributionParameterHandler { @Test public void testDistributionParameterGroup_InvalidRestServerUser() throws PolicyDistributionException { final String[] distributionConfigParameters = - { "-c", "parameters/DistributionConfigParameters_InvalidRestServerUser.json" }; + { "-c", "parameters/DistributionConfigParameters_InvalidRestServerUser.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); arguments.parse(distributionConfigParameters); @@ -412,7 +419,7 @@ public class TestDistributionParameterHandler { @Test public void testDistributionParameterGroup_InvalidRestServerPassword() throws PolicyDistributionException { final String[] distributionConfigParameters = - { "-c", "parameters/DistributionConfigParameters_InvalidRestServerPassword.json" }; + { "-c", "parameters/DistributionConfigParameters_InvalidRestServerPassword.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); arguments.parse(distributionConfigParameters); 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 c902c9b5..960629e4 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 @@ -27,8 +27,8 @@ import static org.junit.Assert.fail; import org.junit.Test; import org.onap.policy.common.parameters.GroupValidationResult; -import org.onap.policy.distribution.reception.parameters.PSSDConfigurationParametersGroup; import org.onap.policy.distribution.reception.parameters.PluginHandlerParameters; +import org.onap.policy.distribution.reception.parameters.PssdConfigurationParametersGroup; import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters; /** @@ -42,15 +42,15 @@ 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()); - assertEquals(pssdConfiguration, rHParameters.getPSSDConfigurationParametersGroup()); + assertEquals(pssdConfiguration, rHParameters.getPssdConfigurationParametersGroup()); assertEquals(pHParameters, rHParameters.getPluginHandlerParameters()); assertTrue(validationResult.isValid()); } @@ -58,15 +58,14 @@ public class TestReceptionHandlerParameters { @Test public void testReceptionHandlerParameters_NullReceptionHandlerType() { final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false); - final PSSDConfigurationParametersGroup pssdConfiguration = - commonTestData.getPSSDConfigurationParametersGroup(false); - final ReceptionHandlerParameters rHParameters = - new ReceptionHandlerParameters(null, CommonTestData.RECEPTION_HANDLER_CLASS_NAME, - pssdConfiguration, pHParameters); + final PssdConfigurationParametersGroup pssdConfiguration = + commonTestData.getPssdConfigurationParametersGroup(false); + final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters(null, + CommonTestData.RECEPTION_HANDLER_CLASS_NAME, pssdConfiguration, pHParameters); final GroupValidationResult validationResult = rHParameters.validate(); assertEquals(null, rHParameters.getReceptionHandlerType()); assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME, rHParameters.getReceptionHandlerClassName()); - assertEquals(pssdConfiguration, rHParameters.getPSSDConfigurationParametersGroup()); + assertEquals(pssdConfiguration, rHParameters.getPssdConfigurationParametersGroup()); assertEquals(pHParameters, rHParameters.getPluginHandlerParameters()); assertFalse(validationResult.isValid()); assertTrue(validationResult.getResult() @@ -77,15 +76,14 @@ public class TestReceptionHandlerParameters { @Test public void testReceptionHandlerParameters_NullReceptionHandlerClassName() { final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false); - final PSSDConfigurationParametersGroup pssdConfiguration = - commonTestData.getPSSDConfigurationParametersGroup(false); - final ReceptionHandlerParameters rHParameters = - new ReceptionHandlerParameters(CommonTestData.RECEPTION_HANDLER_TYPE, null, - pssdConfiguration, pHParameters); + final PssdConfigurationParametersGroup pssdConfiguration = + commonTestData.getPssdConfigurationParametersGroup(false); + final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters( + 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(pssdConfiguration, rHParameters.getPssdConfigurationParametersGroup()); assertEquals(pHParameters, rHParameters.getPluginHandlerParameters()); assertFalse(validationResult.isValid()); assertTrue(validationResult.getResult() @@ -96,11 +94,10 @@ public class TestReceptionHandlerParameters { @Test public void testReceptionHandlerParameters_EmptyReceptionHandlerType() { final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false); - final PSSDConfigurationParametersGroup pssdConfiguration = - commonTestData.getPSSDConfigurationParametersGroup(false); - final ReceptionHandlerParameters rHParameters = - new ReceptionHandlerParameters("", CommonTestData.RECEPTION_HANDLER_CLASS_NAME, - pssdConfiguration, pHParameters); + final PssdConfigurationParametersGroup pssdConfiguration = + commonTestData.getPssdConfigurationParametersGroup(false); + final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters("", + CommonTestData.RECEPTION_HANDLER_CLASS_NAME, pssdConfiguration, pHParameters); final GroupValidationResult validationResult = rHParameters.validate(); assertEquals("", rHParameters.getReceptionHandlerType()); assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME, rHParameters.getReceptionHandlerClassName()); @@ -114,14 +111,14 @@ public class TestReceptionHandlerParameters { @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); final GroupValidationResult validationResult = rHParameters.validate(); assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType()); assertEquals("", rHParameters.getReceptionHandlerClassName()); - assertEquals(pssdConfiguration, rHParameters.getPSSDConfigurationParametersGroup()); + assertEquals(pssdConfiguration, rHParameters.getPssdConfigurationParametersGroup()); assertEquals(pHParameters, rHParameters.getPluginHandlerParameters()); assertFalse(validationResult.isValid()); assertTrue(validationResult.getResult() @@ -133,11 +130,11 @@ public class TestReceptionHandlerParameters { 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); + 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) { @@ -148,16 +145,16 @@ public class TestReceptionHandlerParameters { @Test public void testReceptionHandlerParameters_InvalidReceptionHandlerClass() { 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, 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()); - assertEquals(pssdConfiguration, rHParameters.getPSSDConfigurationParametersGroup()); + assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME + "Invalid", + rHParameters.getReceptionHandlerClassName()); + assertEquals(pssdConfiguration, rHParameters.getPssdConfigurationParametersGroup()); assertEquals(pHParameters, rHParameters.getPluginHandlerParameters()); assertFalse(validationResult.isValid()); assertTrue(validationResult.getResult().contains("reception handler class not found in classpath")); diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java index df585574..d02139f2 100644 --- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java +++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java @@ -33,6 +33,8 @@ import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; import org.junit.Test; import org.onap.policy.common.endpoints.report.HealthCheckReport; +import org.onap.policy.common.logging.flexlogger.FlexLogger; +import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.distribution.main.PolicyDistributionException; import org.onap.policy.distribution.main.parameters.CommonTestData; import org.onap.policy.distribution.main.parameters.RestServerParameters; @@ -45,6 +47,7 @@ import org.onap.policy.distribution.main.startstop.Main; */ public class TestDistributionRestServer { + private static final Logger LOGGER = FlexLogger.getLogger(TestDistributionRestServer.class); private static final String NOT_ALIVE = "not alive"; private static final String ALIVE = "alive"; private static final String SELF = "self"; @@ -83,7 +86,7 @@ public class TestDistributionRestServer { } private HealthCheckReport performHealthCheck() throws InterruptedException { - HealthCheckReport response; + HealthCheckReport response = null; final ClientConfig clientConfig = new ClientConfig(); final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34"); @@ -93,14 +96,13 @@ public class TestDistributionRestServer { final WebTarget webTarget = client.target("http://localhost:6969/healthcheck"); final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON); - try { - response = invocationBuilder.get(HealthCheckReport.class); - } catch (final Exception exp) { - // may be the server is not started yet. Wait for couple of seconds and retry. - Thread.sleep(2000); - response = invocationBuilder.get(HealthCheckReport.class); + while (response == null) { + try { + response = invocationBuilder.get(HealthCheckReport.class); + } catch (final Exception exp) { + LOGGER.info("the server is not started yet. We will retry again"); + } } - return response; } diff --git a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionActivator.java b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionActivator.java index 25133cfe..7cfb5ef3 100644 --- a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionActivator.java +++ b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionActivator.java @@ -40,8 +40,8 @@ public class TestDistributionActivator { public void testDistributionActivator() throws PolicyDistributionException { final String[] distributionConfigParameters = { "-c", "parameters/DistributionConfigParameters.json" }; - final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); - arguments.parse(distributionConfigParameters); + final DistributionCommandLineArguments arguments = + new DistributionCommandLineArguments(distributionConfigParameters); final DistributionParameterGroup parGroup = new DistributionParameterHandler().getParameters(arguments); diff --git a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java index 124f49a6..e1c5d22b 100644 --- a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java +++ b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java @@ -36,7 +36,8 @@ public class TestMain { @Test public void testMain() throws PolicyDistributionException { - final String[] distributionConfigParameters = { "-c", "parameters/DistributionConfigParameters.json" }; + final String[] distributionConfigParameters = + { "-c", "parameters/DistributionConfigParameters.json" }; final Main main = new Main(distributionConfigParameters); assertTrue(main.getParameters().isValid()); assertEquals(CommonTestData.DISTRIBUTION_GROUP_NAME, main.getParameters().getName()); @@ -45,28 +46,31 @@ public class TestMain { @Test public void testMain_NoArguments() { - final String[] distributionConfigParameters = {}; + final String[] distributionConfigParameters = + {}; final Main main = new Main(distributionConfigParameters); assertTrue(main.getParameters() == null); } @Test public void testMain_InvalidArguments() { - final String[] distributionConfigParameters = { "parameters/DistributionConfigParameters.json" }; + final String[] distributionConfigParameters = + { "parameters/DistributionConfigParameters.json" }; final Main main = new Main(distributionConfigParameters); assertTrue(main.getParameters() == null); } @Test public void testMain_Help() { - final String[] distributionConfigParameters = { "-h" }; + final String[] distributionConfigParameters = + { "-h" }; Main.main(distributionConfigParameters); } @Test public void testMain_InvalidParameters() { final String[] distributionConfigParameters = - { "-c", "parameters/DistributionConfigParameters_InvalidName.json" }; + { "-c", "parameters/DistributionConfigParameters_InvalidName.json" }; final Main main = new Main(distributionConfigParameters); assertTrue(main.getParameters() == null); } diff --git a/plugins/reception-plugins/pom.xml b/plugins/reception-plugins/pom.xml index a44ff777..388477e9 100644 --- a/plugins/reception-plugins/pom.xml +++ b/plugins/reception-plugins/pom.xml @@ -52,10 +52,5 @@ </exclusion> </exclusions> </dependency> - <dependency> - <groupId>org.onap.policy.common</groupId> - <artifactId>common-parameters</artifactId> - <version>1.3.0-SNAPSHOT</version> - </dependency> </dependencies> </project> diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PdpxPolicy.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PdpxPolicy.java index 14d686be..6e0eb3bd 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PdpxPolicy.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PdpxPolicy.java @@ -5,15 +5,15 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -24,7 +24,7 @@ import org.onap.policy.distribution.model.Policy; import org.onap.policy.distribution.reception.decoding.PolicyDecoder; /** - * A PDP-X Policy, decoded by a {@link PolicyDecoder} + * A PDP-X Policy, decoded by a {@link PolicyDecoder}. */ public class PdpxPolicy implements Policy { diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfiguration.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/PssdConfiguration.java index baba4d42..c5c877e1 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfiguration.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/PssdConfiguration.java @@ -23,25 +23,25 @@ package org.onap.policy.distribution.reception.handling.sdc; import java.util.List; import org.onap.sdc.api.consumer.IConfiguration; -import org.onap.policy.distribution.reception.parameters.PSSDConfigurationParametersGroup; +import org.onap.policy.distribution.reception.parameters.PssdConfigurationParametersGroup; /** * Properties for the handling Sdc * */ -public class PSSDConfiguration implements IConfiguration { +public class PssdConfiguration implements IConfiguration { // Configuration file structure // Configuration file properties - private PSSDConfigurationParametersGroup configParameters = null; + private PssdConfigurationParametersGroup configParameters = null; /** * Original constructor * * @param configParameters properties needed to be configured for the model loader */ - public PSSDConfiguration(final PSSDConfigurationParametersGroup configParameters) { + public PssdConfiguration(final PssdConfigurationParametersGroup configParameters) { this.configParameters = configParameters; } diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDControllerException.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdControllerException.java index ff9acfd0..9dece808 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDControllerException.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdControllerException.java @@ -22,9 +22,9 @@ package org.onap.policy.distribution.reception.handling.sdc.exceptions; /** - * Exception of the PSSD controller. + * Exception of the Pssd controller. */ -public class PSSDControllerException extends Exception { +public class PssdControllerException extends Exception { /** * serialization id. @@ -32,22 +32,22 @@ public class PSSDControllerException extends Exception { private static final long serialVersionUID = -8507246953751956974L; /** - * Constructor for creating PSSDControllerException using message. + * Constructor for creating PssdControllerException using message. * * @param message The message to dump */ - public PSSDControllerException (final String message) { + public PssdControllerException (final String message) { super (message); } /** - * Constructor for creating PSSDControllerException using message and exception. + * Constructor for creating PssdControllerException using message and exception. * * @param message The message to dump * @param e the exception that caused this exception to be thrown */ - public PSSDControllerException (final String message, final Exception e) { + public PssdControllerException (final String message, final Exception e) { super (message, e); } diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDDownloadException.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdDownloadException.java index f95179c1..14c6b5ea 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDDownloadException.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdDownloadException.java @@ -22,9 +22,9 @@ package org.onap.policy.distribution.reception.handling.sdc.exceptions; /** - * Exception during download from PSSD. + * Exception during download from Pssd. */ -public class PSSDDownloadException extends Exception { +public class PssdDownloadException extends Exception { /** * serialization id. @@ -32,22 +32,22 @@ public class PSSDDownloadException extends Exception { private static final long serialVersionUID = -8507246953751956974L; /** - * Constructor for creating PSSDDownloadException using message. + * Constructor for creating PssdDownloadException using message. * * @param message The message to dump */ - public PSSDDownloadException (final String message) { + public PssdDownloadException (final String message) { super (message); } /** - * Constructor for creating PSSDDownloadException using message and exception. + * Constructor for creating PssdDownloadException using message and exception. * * @param message The message to dump * @param e the exception that caused this exception to be thrown */ - public PSSDDownloadException (final String message, final Exception e) { + public PssdDownloadException (final String message, final Exception e) { super (message, e); } diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDParametersException.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdParametersException.java index 91922d7d..ca17796c 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDParametersException.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdParametersException.java @@ -22,9 +22,9 @@ package org.onap.policy.distribution.reception.handling.sdc.exceptions; /** - * Exception of the PSSD controller. + * Exception of the Pssd controller. */ -public class PSSDParametersException extends Exception { +public class PssdParametersException extends Exception { /** * serialization id. @@ -32,22 +32,22 @@ public class PSSDParametersException extends Exception { private static final long serialVersionUID = -8507246953751956974L; /** - * Constructor for creating PSSDParametersException using message. + * Constructor for creating PssdParametersException using message. * * @param message The message to dump */ - public PSSDParametersException (final String message) { + public PssdParametersException (final String message) { super (message); } /** - * Constructor for creating PSSDParametersException using message and exception. + * Constructor for creating PssdParametersException using message and exception. * * @param message The message to dump * @param e the exception that caused this exception to be thrown */ - public PSSDParametersException (final String message, final Exception e) { + public PssdParametersException (final String message, final Exception e) { super (message, e); } diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfigurationTest.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/PssdConfigurationTest.java index 435b7577..5c24a792 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfigurationTest.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/PssdConfigurationTest.java @@ -5,15 +5,15 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -28,50 +28,48 @@ import static org.junit.Assert.fail; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import java.io.File; import java.io.FileReader; import java.io.IOException; + import org.junit.Test; import org.onap.policy.common.parameters.GroupValidationResult; -import org.onap.policy.distribution.reception.parameters.PSSDConfigurationParametersGroup; +import org.onap.policy.distribution.reception.parameters.PssdConfigurationParametersGroup; /*- - * Tests for PSSDConfiguration class + * Tests for PssdConfiguration class * */ -public class PSSDConfigurationTest { - +public class PssdConfigurationTest { + @Test - public void testPSSDConfigurationParametersGroup() throws IOException { - PSSDConfigurationParametersGroup configParameters = null; + public void testPssdConfigurationParametersGroup() throws IOException { + PssdConfigurationParametersGroup configParameters = null; try { final Gson gson = new GsonBuilder().create(); - configParameters = - gson.fromJson(new FileReader("src/test/resources/handling-sdc.json"), - PSSDConfigurationParametersGroup.class); + configParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdc.json"), + PssdConfigurationParametersGroup.class); } catch (final Exception e) { fail("test should not thrown an exception here: " + e.getMessage()); } final GroupValidationResult validationResult = configParameters.validate(); assertTrue(validationResult.isValid()); - PSSDConfiguration config = new PSSDConfiguration(configParameters); + final PssdConfiguration config = new PssdConfiguration(configParameters); assertEquals(20, config.getPollingInterval()); - assertEquals(30,config.getPollingTimeout()); + assertEquals(30, config.getPollingTimeout()); } @Test - public void testInvalidPSSDConfigurationParametersGroup() throws IOException { - PSSDConfigurationParametersGroup configParameters = null; + public void testInvalidPssdConfigurationParametersGroup() throws IOException { + PssdConfigurationParametersGroup configParameters = null; try { final Gson gson = new GsonBuilder().create(); - configParameters = - gson.fromJson(new FileReader("src/test/resources/handling-sdcInvalid.json"), - PSSDConfigurationParametersGroup.class); + configParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdcInvalid.json"), + PssdConfigurationParametersGroup.class); } catch (final Exception e) { fail("test should not thrown an exception here: " + e.getMessage()); } final GroupValidationResult validationResult = configParameters.validate(); assertFalse(validationResult.isValid()); - + } } diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDControllerExceptionTest.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdControllerExceptionTest.java index b467cbad..5f8e507a 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDControllerExceptionTest.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdControllerExceptionTest.java @@ -26,11 +26,11 @@ import java.io.IOException; import org.junit.Test; -public class PSSDControllerExceptionTest { +public class PssdControllerExceptionTest { @Test public void test() { - assertNotNull(new PSSDControllerException("Message")); - assertNotNull(new PSSDControllerException("Message", new IOException())); + assertNotNull(new PssdControllerException("Message")); + assertNotNull(new PssdControllerException("Message", new IOException())); } } diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDDownloadExceptionTest.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdDownloadExceptionTest.java index 0ca4330d..9f76b375 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDDownloadExceptionTest.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdDownloadExceptionTest.java @@ -26,11 +26,11 @@ import java.io.IOException; import org.junit.Test; -public class PSSDDownloadExceptionTest { +public class PssdDownloadExceptionTest { @Test public void test() { - assertNotNull(new PSSDDownloadException("Message")); - assertNotNull(new PSSDDownloadException("Message", new IOException())); + assertNotNull(new PssdDownloadException("Message")); + assertNotNull(new PssdDownloadException("Message", new IOException())); } } diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDParametersExceptionTest.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdParametersExceptionTest.java index 040895e6..7a1f5512 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PSSDParametersExceptionTest.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdParametersExceptionTest.java @@ -26,11 +26,11 @@ import java.io.IOException; import org.junit.Test; -public class PSSDParametersExceptionTest { +public class PssdParametersExceptionTest { @Test public void test() { - assertNotNull(new PSSDParametersException("Message")); - assertNotNull(new PSSDParametersException("Message", new IOException())); + assertNotNull(new PssdParametersException("Message")); + assertNotNull(new PssdParametersException("Message", new IOException())); } } @@ -39,11 +39,13 @@ <properties> <!-- sonar/jacoco overrides --> - <!-- Overriding oparent default sonar/jacoco settings Combine all our reports + <!-- Overriding oparent default sonar/jacoco settings Combine all our reports into one file shared across sub-modules --> <sonar.jacoco.reportPath>${project.basedir}/../target/code-coverage/jacoco-ut.exec</sonar.jacoco.reportPath> <sonar.jacoco.itReportPath>${project.basedir}/../target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPath> <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis> + + <policy.common.version>1.3.0-SNAPSHOT</policy.common.version> </properties> <modules> @@ -114,6 +116,42 @@ </execution> </executions> </plugin> + <plugin> + <artifactId>maven-checkstyle-plugin</artifactId> + <executions> + <execution> + <id>onap-java-style</id> + <goals> + <goal>check</goal> + </goals> + <phase>process-sources</phase> + <configuration> + <!-- Use Google Java Style Guide: + https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml + with minor changes --> + <configLocation>onap-checkstyle/onap-java-style.xml</configLocation> + <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory --> + <sourceDirectory>${project.build.sourceDirectory}/src/main/java</sourceDirectory> + <includeResources>true</includeResources> + <includeTestSourceDirectory>true</includeTestSourceDirectory> + <includeTestResources>true</includeTestResources> + <excludes> + </excludes> + <consoleOutput>true</consoleOutput> + <failOnViolation>true</failOnViolation> + <violationSeverity>warning</violationSeverity> + </configuration> + </execution> + </executions> + <dependencies> + <dependency> + <groupId>org.onap.oparent</groupId> + <artifactId>checkstyle</artifactId> + <version>1.1.0</version> + <scope>compile</scope> + </dependency> + </dependencies> + </plugin> </plugins> <pluginManagement> <plugins> diff --git a/reception/pom.xml b/reception/pom.xml index b0b07012..f8924036 100644 --- a/reception/pom.xml +++ b/reception/pom.xml @@ -44,13 +44,8 @@ </dependency> <dependency> <groupId>org.onap.policy.common</groupId> - <artifactId>common-parameters</artifactId> - <version>1.3.0-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.onap.policy.common</groupId> - <artifactId>ONAP-Logging</artifactId> - <version>1.3.0-SNAPSHOT</version> + <artifactId>utils</artifactId> + <version>${policy.common.version}</version> </dependency> </dependencies> </project> diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/decoding/PluginInitializationException.java b/reception/src/main/java/org/onap/policy/distribution/reception/decoding/PluginInitializationException.java new file mode 100644 index 00000000..4dd36a7c --- /dev/null +++ b/reception/src/main/java/org/onap/policy/distribution/reception/decoding/PluginInitializationException.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.distribution.reception.decoding; + +/** + * This exception will be called if an error occurs while initializing distribution plugins. + * + * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com) + */ +public class PluginInitializationException extends Exception { + + private static final long serialVersionUID = 3809376274411309160L; + + /** + * Construct an instance with the given message. + * + * @param message the error message + */ + public PluginInitializationException(final String message) { + super(message); + } + + /** + * Construct an instance with the given message and cause. + * + * @param message the error message + * @param cause the cause + */ + public PluginInitializationException(final String message, final Throwable cause) { + super(message, cause); + } + +} diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/decoding/PolicyDecoder.java b/reception/src/main/java/org/onap/policy/distribution/reception/decoding/PolicyDecoder.java index 8306b630..2a07ec72 100644 --- a/reception/src/main/java/org/onap/policy/distribution/reception/decoding/PolicyDecoder.java +++ b/reception/src/main/java/org/onap/policy/distribution/reception/decoding/PolicyDecoder.java @@ -5,15 +5,15 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -21,6 +21,7 @@ package org.onap.policy.distribution.reception.decoding; import java.util.Collection; + import org.onap.policy.distribution.model.Policy; import org.onap.policy.distribution.model.PolicyInput; @@ -34,15 +35,15 @@ public interface PolicyDecoder<S extends PolicyInput, T extends Policy> { /** * Can the decoder handle input of the specified type. - * + * * @param policyInput the type - * @return <code>true</code if the decoder can handle the specified type + * @return <code>true</code> if the decoder can handle the specified type */ boolean canHandle(PolicyInput policyInput); /** - * Decode policies from the given input - * + * Decode policies from the given input. + * * @param input the input * @return the generated policies * @throws PolicyDecodingException if an error occurs during decoding diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java b/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java index eeb1ead1..b189a2ab 100644 --- a/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java +++ b/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java @@ -30,6 +30,7 @@ import org.onap.policy.distribution.forwarding.PolicyForwarder; import org.onap.policy.distribution.forwarding.PolicyForwardingException; import org.onap.policy.distribution.model.Policy; import org.onap.policy.distribution.model.PolicyInput; +import org.onap.policy.distribution.reception.decoding.PluginInitializationException; import org.onap.policy.distribution.reception.decoding.PolicyDecoder; import org.onap.policy.distribution.reception.decoding.PolicyDecodingException; import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters; @@ -45,8 +46,11 @@ public abstract class AbstractReceptionHandler implements ReceptionHandler { private PluginHandler pluginHandler; + /** + * {@inheritDoc} + */ @Override - public void initialize(final String parameterGroupName) throws PolicyDecodingException, PolicyForwardingException { + public void initialize(final String parameterGroupName) throws PluginInitializationException { final ReceptionHandlerParameters receptionHandlerParameters = (ReceptionHandlerParameters) ParameterService.get(parameterGroupName); pluginHandler = new PluginHandler(receptionHandlerParameters.getPluginHandlerParameters().getName()); diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java b/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java index 37638b59..eb1a33a5 100644 --- a/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java +++ b/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java @@ -28,12 +28,11 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.distribution.forwarding.PolicyForwarder; -import org.onap.policy.distribution.forwarding.PolicyForwardingException; import org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters; import org.onap.policy.distribution.model.Policy; import org.onap.policy.distribution.model.PolicyInput; +import org.onap.policy.distribution.reception.decoding.PluginInitializationException; import org.onap.policy.distribution.reception.decoding.PolicyDecoder; -import org.onap.policy.distribution.reception.decoding.PolicyDecodingException; import org.onap.policy.distribution.reception.parameters.PluginHandlerParameters; import org.onap.policy.distribution.reception.parameters.PolicyDecoderParameters; @@ -51,10 +50,9 @@ public class PluginHandler { * Create an instance to instantiate plugins based on the given parameter group. * * @param parameterGroupName the name of the parameter group - * @throws PolicyDecodingException exception if it occurs - * @throws PolicyForwardingException exception if it occurs + * @throws PluginInitializationException exception if it occurs */ - public PluginHandler(final String parameterGroupName) throws PolicyDecodingException, PolicyForwardingException { + public PluginHandler(final String parameterGroupName) throws PluginInitializationException { final PluginHandlerParameters params = (PluginHandlerParameters) ParameterService.get(parameterGroupName); initializePolicyDecoders(params.getPolicyDecoders()); initializePolicyForwarders(params.getPolicyForwarders()); @@ -82,11 +80,11 @@ public class PluginHandler { * Initialize policy decoders. * * @param policyDecoderParameters exception if it occurs - * @throws PolicyDecodingException exception if it occurs + * @throws PluginInitializationException exception if it occurs */ @SuppressWarnings("unchecked") private void initializePolicyDecoders(final Map<String, PolicyDecoderParameters> policyDecoderParameters) - throws PolicyDecodingException { + throws PluginInitializationException { policyDecoders = new ArrayList<>(); for (final PolicyDecoderParameters decoderParameters : policyDecoderParameters.values()) { try { @@ -97,7 +95,7 @@ public class PluginHandler { policyDecoders.add(decoder); } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException exp) { LOGGER.error("exception occured while initializing decoders", exp); - throw new PolicyDecodingException(exp.getMessage(), exp.getCause()); + throw new PluginInitializationException(exp.getMessage(), exp.getCause()); } } } @@ -106,11 +104,11 @@ public class PluginHandler { * Initialize policy forwarders. * * @param policyForwarderParameters exception if it occurs - * @throws PolicyForwardingException exception if it occurs + * @throws PluginInitializationException exception if it occurs */ @SuppressWarnings("unchecked") private void initializePolicyForwarders(final Map<String, PolicyForwarderParameters> policyForwarderParameters) - throws PolicyForwardingException { + throws PluginInitializationException { policyForwarders = new ArrayList<>(); for (final PolicyForwarderParameters forwarderParameters : policyForwarderParameters.values()) { try { @@ -119,7 +117,7 @@ public class PluginHandler { policyForwarders.add(policyForwarderClass.newInstance()); } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException exp) { LOGGER.error("exception occured while initializing forwarders", exp); - throw new PolicyForwardingException(exp.getMessage(), exp.getCause()); + throw new PluginInitializationException(exp.getMessage(), exp.getCause()); } } } diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/handling/ReceptionHandler.java b/reception/src/main/java/org/onap/policy/distribution/reception/handling/ReceptionHandler.java index 5f2e3716..5fcfb9c0 100644 --- a/reception/src/main/java/org/onap/policy/distribution/reception/handling/ReceptionHandler.java +++ b/reception/src/main/java/org/onap/policy/distribution/reception/handling/ReceptionHandler.java @@ -20,8 +20,7 @@ package org.onap.policy.distribution.reception.handling; -import org.onap.policy.distribution.forwarding.PolicyForwardingException; -import org.onap.policy.distribution.reception.decoding.PolicyDecodingException; +import org.onap.policy.distribution.reception.decoding.PluginInitializationException; /** * Handles input into Policy Distribution which may be decoded into a Policy. @@ -32,10 +31,9 @@ public interface ReceptionHandler { * Initialize the reception handler with the given parameters. * * @param parameterGroupName the name of the parameter group containing the configuration for the reception handler - * @throws PolicyDecodingException exception if it occurs - * @throws PolicyForwardingException exception if it occurs + * @throws PluginInitializationException exception if it occurs */ - void initialize(String parameterGroupName) throws PolicyDecodingException, PolicyForwardingException; + void initialize(String parameterGroupName) throws PluginInitializationException; /** * Destroy the reception handler, removing any subscriptions and releasing all resources. diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PSSDConfigurationParametersGroup.java b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PSSDConfigurationParametersGroup.java deleted file mode 100644 index 529cc9e4..00000000 --- a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PSSDConfigurationParametersGroup.java +++ /dev/null @@ -1,362 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Intel. 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.distribution.reception.parameters; - -import java.util.List; -import java.util.UUID; - -import org.onap.policy.common.parameters.GroupValidationResult; -import org.onap.policy.common.parameters.ParameterGroup; -import org.onap.policy.common.parameters.ValidationStatus; - -/** - * This class handles reading, parsing and validating of the Policy SDC Service Distribution parameters from Json - * format, which strictly adheres to the interface:IConfiguration, defined by SDC SDK. - */ -public class PSSDConfigurationParametersGroup implements ParameterGroup { - - // Policy SDC Service Distribution specified field. - private String name; - - // Interface of IConfiguration item - private String asdcAddress; - private List<String> messageBusAddress; - private String user; - private String password; - private int pollingInterval; - private int pollingTimeout; - private String consumerId; - private List<String> artifactTypes; - private String consumerGroup; - private String environmentName; - private String keystorePath; - private String keystorePassword; - private boolean activeserverTlsAuth; - private boolean isFilterinEmptyResources; - private Boolean isUseHttpsWithDmaap; - - /** - *Inner static class is to used as a Builder - * - */ - public static class PSSDConfigurationBuilder { - private String asdcAddress; - private List<String> messageBusAddress; - private String user; - private String password; - private int pollingInterval; - private int pollingTimeout; - private String consumerId; - private List<String> artifactTypes; - private String consumerGroup; - private String environmentName; - private String keystorePath; - private String keystorePassword; - private boolean activeserverTlsAuth; - private boolean isFilterinEmptyResources; - private Boolean isUseHttpsWithDmaap; - - public PSSDConfigurationBuilder setAsdcAddress(String val) { - asdcAddress = val; - return this; - } - - public PSSDConfigurationBuilder setMessageBusAddress(List<String> val) { - messageBusAddress = val; - return this; - } - - public PSSDConfigurationBuilder setUser(String val) { - user = val; - return this; - } - - public PSSDConfigurationBuilder setPassword(String val) { - password = val; - return this; - } - - public PSSDConfigurationBuilder setPollingInterval(int val) { - pollingInterval = val; - return this; - } - - public PSSDConfigurationBuilder setPollingTimeout(int val) { - pollingTimeout = val; - return this; - } - - public PSSDConfigurationBuilder setConsumerId(String val) { - consumerId = val; - return this; - } - - public PSSDConfigurationBuilder setArtifactTypes(List<String> val) { - artifactTypes = val; - return this; - } - - public PSSDConfigurationBuilder setConsumerGroup(String val) { - consumerGroup = val; - return this; - } - - public PSSDConfigurationBuilder setEnvironmentName(String val) { - environmentName = val; - return this; - } - - public PSSDConfigurationBuilder setKeystorePath(String val) { - keystorePath = val; - return this; - } - - public PSSDConfigurationBuilder setKeystorePassword(String val) { - keystorePassword = val; - return this; - } - - public PSSDConfigurationBuilder setActiveserverTlsAuth(boolean val) { - activeserverTlsAuth = val; - return this; - } - - public PSSDConfigurationBuilder setIsFilterinEmptyResources(boolean val) { - isFilterinEmptyResources = val; - return this; - } - - public PSSDConfigurationBuilder setIsUseHttpsWithDmaap(Boolean val) { - isUseHttpsWithDmaap = val; - return this; - } - - /** - * it is to create a new PSSDConfigurationParametersGroup instance. - */ - public PSSDConfigurationParametersGroup build() { - return new PSSDConfigurationParametersGroup(this); - } - } - - /** - * The constructor for instantiating PSSDConfigurationParametersGroup it is a private - * so that it could ONLY be instantiated by PSSDConfigurationBuilder - * - * @param builder stores all the values used by PSSDConfigurationParametersGroup - */ - private PSSDConfigurationParametersGroup(PSSDConfigurationBuilder builder) { - asdcAddress = builder.asdcAddress; - messageBusAddress = builder.messageBusAddress; - user = builder.user; - password = builder.password; - pollingInterval = builder.pollingInterval; - pollingTimeout = builder.pollingTimeout; - consumerId = builder.consumerId; - artifactTypes = builder.artifactTypes; - consumerGroup = builder.consumerGroup; - environmentName = builder.environmentName; - keystorePath = builder.keystorePath; - keystorePassword = builder.keystorePassword; - activeserverTlsAuth = builder.activeserverTlsAuth; - isFilterinEmptyResources = builder.isFilterinEmptyResources; - isUseHttpsWithDmaap = builder.isUseHttpsWithDmaap; - - } - - public String getAsdcAddress() { - return asdcAddress; - } - - public List<String> getMsgBusAddress() { - return messageBusAddress; - } - - public String getUser() { - return user; - } - - public String getPassword() { - return password; - } - - public int getPollingInterval() { - return pollingInterval; - } - - public int getPollingTimeout() { - return pollingTimeout; - } - - public String getConsumerID() { - return consumerId; - } - - public List<String> getArtifactTypes() { - return artifactTypes; - } - - public String getConsumerGroup() { - return consumerGroup; - } - - public String getEnvironmentName() { - return environmentName; - } - - public String getKeyStorePassword() { - return keystorePassword; - } - - public String getKeyStorePath() { - return keystorePath; - } - - public boolean activateServerTLSAuth() { - return activeserverTlsAuth; - } - - public boolean isFilterInEmptyResources() { - return isFilterinEmptyResources; - } - - public Boolean isUseHttpsWithDmaap() { - return isUseHttpsWithDmaap; - } - - /** - * Return a string representation of the object - * - * @return textually represents this object - */ - @Override - public String toString() { - return "name =" + name + ",TestParameters:[asdcAddress = " + asdcAddress + ", messageBusAddress = " - + messageBusAddress + ", user = " + user + "]"; - } - - /** - * Return the name of this parameter group instance - * - * @return name the parameter group name - */ - @Override - public String getName() { - return name ; - } - - /** - * Validate all the int Elements - * - */ - private void validateIntElement(final GroupValidationResult validationResult) { - if (pollingInterval <= 0) { - validationResult.setResult("pollingInterval", ValidationStatus.INVALID, - "pollingInterval must be a positive integer"); - } - - if (pollingTimeout <= 0) { - validationResult.setResult("pollingTimeout", ValidationStatus.INVALID, - "pollingTimeout must be a positive integer"); - } - } - - /** - * Validate all the String List Elements - * - */ - private void validateStringListElement(final GroupValidationResult validationResult) { - if (messageBusAddress == null) { - validationResult.setResult("messageBusAddress", ValidationStatus.INVALID, - "messageBusAddress must be a list of non-blank string"); - } else { - for (final String temp : messageBusAddress) { - if (temp.trim().length() == 0) { - validationResult.setResult("messageBusAddress", ValidationStatus.INVALID, - "the string of messageBusAddress must be a non-blank string"); - } - } - } - - if (artifactTypes == null) { - validationResult.setResult("artifactTypes", ValidationStatus.INVALID, - "artifactTypes must be a list of non-blank string"); - } else { - for (final String temp : artifactTypes) { - if (temp.trim().length() == 0) { - validationResult.setResult("artifactTypes", ValidationStatus.INVALID, - "the string of artifactTypes must be a non-blank string"); - } - } - } - } - - /** - * Validate the parameter group - * @return the result of the validation - */ - @Override - public GroupValidationResult validate() { - final GroupValidationResult validationResult = new GroupValidationResult(this); - - if (asdcAddress == null || asdcAddress.trim().length() == 0) { - validationResult.setResult("asdcAddress", ValidationStatus.INVALID, - "asdcAddress must be a non-blank string"); - } - - if (user == null || user.trim().length() == 0) { - validationResult.setResult("user", ValidationStatus.INVALID, "user must be a non-blank string"); - } - - if (consumerId == null || consumerId.trim().length() == 0) { - validationResult.setResult("consumerId", ValidationStatus.INVALID, "consumerId must be a non-blank string"); - } - - if (consumerGroup == null || consumerGroup.trim().length() == 0) { - validationResult.setResult("consumerGroup", ValidationStatus.INVALID, - "consumerGroup must be a non-blank string"); - } - - if (keystorePath == null || keystorePath.trim().length() == 0) { - validationResult.setResult("keystorePath", ValidationStatus.INVALID, - "keystorePath must be a non-blank string"); - } - - if (keystorePassword == null || keystorePassword.trim().length() == 0) { - validationResult.setResult("keystorePassword", ValidationStatus.INVALID, - "keystorePassword must be a non-blank string"); - } - - validateIntElement(validationResult); - validateStringListElement(validationResult); - return validationResult; - } - - /** - * Set the name of this group. - * - * @param name the name to set. - */ - public void setName(final String name) { - this.name = name + "_" + UUID.randomUUID().toString(); - } -} - 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 6157b8b6..2d60b85e 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 @@ -67,14 +67,16 @@ public class PolicyDecoderParameters implements ParameterGroup { return decoderClassName; } + /** + * {@inheritDoc} + */ @Override public String getName() { return null; } /** - * Validate the policy decoder parameters. - * + * {@inheritDoc} */ @Override public GroupValidationResult validate() { @@ -95,7 +97,7 @@ public class PolicyDecoderParameters implements ParameterGroup { try { Class.forName(decoderClassName); } catch (final ClassNotFoundException exp) { - LOGGER.error("policy decoder class not found in classpath", exp); + LOGGER.trace("policy decoder class not found in classpath", exp); validationResult.setResult("decoderClassName", ValidationStatus.INVALID, "policy decoder class not found in classpath"); } diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PssdConfigurationParametersGroup.java b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PssdConfigurationParametersGroup.java new file mode 100644 index 00000000..93e3f628 --- /dev/null +++ b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PssdConfigurationParametersGroup.java @@ -0,0 +1,343 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Intel. 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.distribution.reception.parameters; + +import java.util.List; +import java.util.UUID; + +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; + +/** + * This class handles reading, parsing and validating of the Policy SDC Service Distribution parameters from Json + * format, which strictly adheres to the interface:IConfiguration, defined by SDC SDK. + */ +public class PssdConfigurationParametersGroup implements ParameterGroup { + + // Policy SDC Service Distribution specified field. + private String name; + + // Interface of IConfiguration item + private String asdcAddress; + private List<String> messageBusAddress; + private String user; + private String password; + private int pollingInterval; + private int pollingTimeout; + private String consumerId; + private List<String> artifactTypes; + private String consumerGroup; + private String environmentName; + private String keystorePath; + private String keystorePassword; + private boolean activeserverTlsAuth; + private boolean isFilterinEmptyResources; + private Boolean isUseHttpsWithDmaap; + + /** + * Inner static class is to used as a Builder. + * + */ + public static class PssdConfigurationBuilder { + private String asdcAddress; + private List<String> messageBusAddress; + private String user; + private String password; + private int pollingInterval; + private int pollingTimeout; + private String consumerId; + private List<String> artifactTypes; + private String consumerGroup; + private String environmentName; + private String keystorePath; + private String keystorePassword; + private boolean activeserverTlsAuth; + private boolean isFilterinEmptyResources; + private Boolean isUseHttpsWithDmaap; + + public PssdConfigurationBuilder setAsdcAddress(final String val) { + asdcAddress = val; + return this; + } + + public PssdConfigurationBuilder setMessageBusAddress(final List<String> val) { + messageBusAddress = val; + return this; + } + + public PssdConfigurationBuilder setUser(final String val) { + user = val; + return this; + } + + public PssdConfigurationBuilder setPassword(final String val) { + password = val; + return this; + } + + public PssdConfigurationBuilder setPollingInterval(final int val) { + pollingInterval = val; + return this; + } + + public PssdConfigurationBuilder setPollingTimeout(final int val) { + pollingTimeout = val; + return this; + } + + public PssdConfigurationBuilder setConsumerId(final String val) { + consumerId = val; + return this; + } + + public PssdConfigurationBuilder setArtifactTypes(final List<String> val) { + artifactTypes = val; + return this; + } + + public PssdConfigurationBuilder setConsumerGroup(final String val) { + consumerGroup = val; + return this; + } + + public PssdConfigurationBuilder setEnvironmentName(final String val) { + environmentName = val; + return this; + } + + public PssdConfigurationBuilder setKeystorePath(final String val) { + keystorePath = val; + return this; + } + + public PssdConfigurationBuilder setKeystorePassword(final String val) { + keystorePassword = val; + return this; + } + + public PssdConfigurationBuilder setActiveserverTlsAuth(final boolean val) { + activeserverTlsAuth = val; + return this; + } + + public PssdConfigurationBuilder setIsFilterinEmptyResources(final boolean val) { + isFilterinEmptyResources = val; + return this; + } + + public PssdConfigurationBuilder setIsUseHttpsWithDmaap(final Boolean val) { + isUseHttpsWithDmaap = val; + return this; + } + + /** + * Creates a new PssdConfigurationParametersGroup instance. + */ + public PssdConfigurationParametersGroup build() { + return new PssdConfigurationParametersGroup(this); + } + } + + /** + * The constructor for instantiating PssdConfigurationParametersGroup. It is kept private so that it could only be + * called by PssdConfigurationBuilder. + * + * @param builder stores all the values used by PssdConfigurationParametersGroup + */ + private PssdConfigurationParametersGroup(final PssdConfigurationBuilder builder) { + asdcAddress = builder.asdcAddress; + messageBusAddress = builder.messageBusAddress; + user = builder.user; + password = builder.password; + pollingInterval = builder.pollingInterval; + pollingTimeout = builder.pollingTimeout; + consumerId = builder.consumerId; + artifactTypes = builder.artifactTypes; + consumerGroup = builder.consumerGroup; + environmentName = builder.environmentName; + keystorePath = builder.keystorePath; + keystorePassword = builder.keystorePassword; + activeserverTlsAuth = builder.activeserverTlsAuth; + isFilterinEmptyResources = builder.isFilterinEmptyResources; + isUseHttpsWithDmaap = builder.isUseHttpsWithDmaap; + + } + + public String getAsdcAddress() { + return asdcAddress; + } + + public List<String> getMsgBusAddress() { + return messageBusAddress; + } + + public String getUser() { + return user; + } + + public String getPassword() { + return password; + } + + public int getPollingInterval() { + return pollingInterval; + } + + public int getPollingTimeout() { + return pollingTimeout; + } + + public String getConsumerID() { + return consumerId; + } + + public List<String> getArtifactTypes() { + return artifactTypes; + } + + public String getConsumerGroup() { + return consumerGroup; + } + + public String getEnvironmentName() { + return environmentName; + } + + public String getKeyStorePassword() { + return keystorePassword; + } + + public String getKeyStorePath() { + return keystorePath; + } + + public boolean activateServerTLSAuth() { + return activeserverTlsAuth; + } + + public boolean isFilterInEmptyResources() { + return isFilterinEmptyResources; + } + + public Boolean isUseHttpsWithDmaap() { + return isUseHttpsWithDmaap; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return "name =" + name + ",TestParameters:[asdcAddress = " + asdcAddress + ", messageBusAddress = " + + messageBusAddress + ", user = " + user + "]"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return name; + } + + /** + * Set the name of this group. + * + * @param name the name to set. + */ + public void setName(final String name) { + this.name = name + "_" + UUID.randomUUID().toString(); + } + + /** + * {@inheritDoc} + */ + @Override + public GroupValidationResult validate() { + final GroupValidationResult validationResult = new GroupValidationResult(this); + validateStringElement(validationResult, asdcAddress, "asdcAddress"); + validateStringElement(validationResult, user, "user"); + validateStringElement(validationResult, consumerId, "consumerId"); + validateStringElement(validationResult, consumerGroup, "consumerGroup"); + validateStringElement(validationResult, keystorePath, "keystorePath"); + validateStringElement(validationResult, keystorePassword, "keystorePassword"); + validateIntElement(validationResult, pollingInterval, "pollingInterval"); + validateIntElement(validationResult, pollingTimeout, "pollingTimeout"); + validateStringListElement(validationResult, messageBusAddress, "messageBusAddress"); + validateStringListElement(validationResult, artifactTypes, "artifactTypes"); + return validationResult; + } + + /** + * Validate the integer Element. + * + * @param validationResult the result object + * @param element the element to validate + * @param elementName the element name for error message + */ + private void validateIntElement(final GroupValidationResult validationResult, final int element, + final String elementName) { + if (!ParameterValidationUtils.validateIntParameter(element)) { + validationResult.setResult(elementName, ValidationStatus.INVALID, + elementName + " must be a positive integer"); + } + } + + /** + * Validate the String List Element. + * + * @param validationResult the result object + * @param element the element to validate + * @param elementName the element name for error message + */ + private void validateStringListElement(final GroupValidationResult validationResult, final List<String> element, + final String elementName) { + if (element == null) { + validationResult.setResult(elementName, ValidationStatus.INVALID, + elementName + " must be a list of non-blank string"); + } else { + for (final String temp : element) { + if (!ParameterValidationUtils.validateStringParameter(temp)) { + validationResult.setResult(elementName, ValidationStatus.INVALID, + "the string of " + elementName + "must be a non-blank string"); + } + } + } + } + + /** + * Validate the string element. + * + * @param validationResult the result object + * @param element the element to validate + * @param elementName the element name for error message + */ + private void validateStringElement(final GroupValidationResult validationResult, final String element, + final String elementName) { + if (!ParameterValidationUtils.validateStringParameter(asdcAddress)) { + validationResult.setResult(elementName, ValidationStatus.INVALID, + elementName + " must be a non-blank string"); + } + } +} + diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java index 93a02b3b..6464eeb6 100644 --- a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java +++ b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java @@ -38,7 +38,7 @@ public class ReceptionHandlerParameters implements ParameterGroup { private String name; private String receptionHandlerType; private String receptionHandlerClassName; - private PSSDConfigurationParametersGroup pssdConfiguration; + private PssdConfigurationParametersGroup pssdConfiguration; private PluginHandlerParameters pluginHandlerParameters; /** @@ -49,7 +49,7 @@ public class ReceptionHandlerParameters implements ParameterGroup { * @param pluginHandlerParameters the plugin handler parameters */ public ReceptionHandlerParameters(final String receptionHandlerType, final String receptionHandlerClassName, - final PSSDConfigurationParametersGroup pssdConfiguration, + final PssdConfigurationParametersGroup pssdConfiguration, final PluginHandlerParameters pluginHandlerParameters) { this.receptionHandlerType = receptionHandlerType; this.receptionHandlerClassName = receptionHandlerClassName; @@ -76,11 +76,11 @@ public class ReceptionHandlerParameters implements ParameterGroup { } /** - * Return the PSSDConfigurationParametersGroup of this ReceptionHandlerParameters instance. + * Return the PssdConfigurationParametersGroup of this ReceptionHandlerParameters instance. * - * @return the PSSDConfigurationParametersGroup + * @return the PssdConfigurationParametersGroup */ - public PSSDConfigurationParametersGroup getPSSDConfigurationParametersGroup() { + public PssdConfigurationParametersGroup getPssdConfigurationParametersGroup() { return pssdConfiguration; } diff --git a/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PolicyInitializationExceptionTest.java b/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PolicyInitializationExceptionTest.java new file mode 100644 index 00000000..bf327554 --- /dev/null +++ b/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PolicyInitializationExceptionTest.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.distribution.reception.decoding; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +/** + * Class to perform unit test of PluginInitializationException. + * + * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com) + */ +public class PolicyInitializationExceptionTest { + + @Test + public void testPolicyInitializationExceptionString() { + final PluginInitializationException policyInitializationException = + new PluginInitializationException("error message"); + assertEquals("error message", policyInitializationException.getMessage()); + } + + @Test + public void testPolicyInitializationExceptionStringThrowable() { + final Exception cause = new IllegalArgumentException(); + final PluginInitializationException policyInitializationException = + new PluginInitializationException("error message", cause); + assertEquals("error message", policyInitializationException.getMessage()); + assertEquals(cause, policyInitializationException.getCause()); + } + +} diff --git a/reception/src/test/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandlerTest.java b/reception/src/test/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandlerTest.java index bb9b542a..83fe5a45 100644 --- a/reception/src/test/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandlerTest.java +++ b/reception/src/test/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandlerTest.java @@ -33,10 +33,10 @@ import java.util.Map; import org.junit.Test; import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.distribution.forwarding.PolicyForwarder; -import org.onap.policy.distribution.forwarding.PolicyForwardingException; import org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters; import org.onap.policy.distribution.model.Policy; import org.onap.policy.distribution.model.PolicyInput; +import org.onap.policy.distribution.reception.decoding.PluginInitializationException; import org.onap.policy.distribution.reception.decoding.PolicyDecoder; import org.onap.policy.distribution.reception.decoding.PolicyDecodingException; import org.onap.policy.distribution.reception.parameters.PluginHandlerParameters; @@ -60,7 +60,7 @@ public class AbstractReceptionHandlerTest { @Test public void testInputReceived() throws PolicyDecodingException, NoSuchFieldException, SecurityException, - IllegalArgumentException, IllegalAccessException, PolicyForwardingException { + IllegalArgumentException, IllegalAccessException, PluginInitializationException { final AbstractReceptionHandler handler = new DummyReceptionHandler(); final Policy generatedPolicy1 = new DummyPolicy1(); @@ -96,7 +96,7 @@ public class AbstractReceptionHandlerTest { @Test(expected = PolicyDecodingException.class) public void testInputReceivedNoSupportingDecoder() throws PolicyDecodingException, NoSuchFieldException, - SecurityException, IllegalArgumentException, IllegalAccessException, PolicyForwardingException { + SecurityException, IllegalArgumentException, IllegalAccessException, PluginInitializationException { final AbstractReceptionHandler handler = new DummyReceptionHandler(); final PolicyDecoder<PolicyInput, Policy> policyDecoder = new DummyDecoder(false, Collections.emptyList()); @@ -108,7 +108,7 @@ public class AbstractReceptionHandlerTest { @Test(expected = PolicyDecodingException.class) public void testInputReceivedNoDecoder() throws PolicyDecodingException, NoSuchFieldException, SecurityException, - IllegalArgumentException, IllegalAccessException, PolicyForwardingException { + IllegalArgumentException, IllegalAccessException, PluginInitializationException { final AbstractReceptionHandler handler = new DummyReceptionHandler(); final DummyPolicyForwarder policyForwarder = new DummyPolicyForwarder(); @@ -129,7 +129,7 @@ public class AbstractReceptionHandlerTest { private void setUpPlugins(final AbstractReceptionHandler receptionHandler, final Collection<PolicyDecoder<PolicyInput, Policy>> decoders, final Collection<PolicyForwarder> forwarders) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, - PolicyDecodingException, PolicyForwardingException { + PluginInitializationException { final PluginHandlerParameters pluginParameters = getPluginHandlerParameters(); pluginParameters.setName(DISTRIBUTION_GROUP); ParameterService.register(pluginParameters); |