From 9eba753aed9d5575fa24ab8806e4d614668c75cb Mon Sep 17 00:00:00 2001 From: Ram Krishna Verma Date: Wed, 7 Jul 2021 14:21:34 -0400 Subject: Use lombok in policy/distribution Use lombok for getter, setter, constructor & builder functions. Remove unused classes. Remove duplicate classes for testing exceptions. Issue-ID: POLICY-3393 Change-Id: I8a565bc6a5699b8716982f84e03b6a11d08ce65b Signed-off-by: Ram Krishna Verma --- forwarding/pom.xml | 5 + .../parameters/PolicyForwarderParameters.java | 17 +-- .../forwarding/PolicyDecodingExceptionTest.java | 43 ------- .../distribution/forwarding/TestExceptions.java | 32 +++++ .../org/onap/policy/distribution/model/Csar.java | 20 +--- .../distribution/model/OptimizationPolicy.java | 71 ----------- .../policy/distribution/model/PolicyAsString.java | 44 +------ .../org/onap/policy/distribution/model/Tosca.java | 26 ++-- .../file/PolicyDecoderFileInCsarToPolicy.java | 5 +- .../reception/handling/file/FileClientHandler.java | 15 +-- .../handling/sdc/ComponentDoneStatusMessage.java | 15 +-- .../sdc/ComponentDoneStatusMessageBuilder.java | 112 ----------------- .../handling/sdc/DistributionStatusMessage.java | 16 +-- .../sdc/DistributionStatusMessageBuilder.java | 132 --------------------- .../reception/handling/sdc/SdcConfiguration.java | 14 +-- .../handling/sdc/SdcReceptionHandler.java | 16 +-- .../sdc/exceptions/ArtifactInstallerException.java | 53 --------- .../sdc/exceptions/PssdControllerException.java | 53 --------- .../sdc/exceptions/PssdParametersException.java | 53 --------- .../reception/handling/sdc/DummyDecoder.java | 3 +- .../sdc/TestComponentDoneStatusMessage.java | 30 +++-- .../sdc/TestDistributionStatusMessage.java | 37 +++--- .../exceptions/ArtifactDownloadExceptionTest.java | 35 ------ .../exceptions/ArtifactInstallerExceptionTest.java | 35 ------ .../exceptions/PssdControllerExceptionTest.java | 35 ------ .../exceptions/PssdParametersExceptionTest.java | 35 ------ .../handling/sdc/exceptions/TestExceptions.java | 32 +++++ .../parameters/PolicyDecoderParameters.java | 17 +-- .../PluginInitializationExceptionTest.java | 50 -------- .../decoding/PluginTerminationExceptionTest.java | 49 -------- .../decoding/PolicyDecodingExceptionTest.java | 43 ------- .../reception/decoding/TestExceptions.java | 34 ++++++ 32 files changed, 187 insertions(+), 990 deletions(-) delete mode 100644 forwarding/src/test/java/org/onap/policy/distribution/forwarding/PolicyDecodingExceptionTest.java create mode 100644 forwarding/src/test/java/org/onap/policy/distribution/forwarding/TestExceptions.java delete mode 100644 model/src/main/java/org/onap/policy/distribution/model/OptimizationPolicy.java delete mode 100644 plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/ComponentDoneStatusMessageBuilder.java delete mode 100644 plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/DistributionStatusMessageBuilder.java delete mode 100644 plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactInstallerException.java delete mode 100644 plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdControllerException.java delete mode 100644 plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdParametersException.java delete mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactDownloadExceptionTest.java delete mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactInstallerExceptionTest.java delete mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdControllerExceptionTest.java delete mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdParametersExceptionTest.java create mode 100644 plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/TestExceptions.java delete mode 100644 reception/src/test/java/org/onap/policy/distribution/reception/decoding/PluginInitializationExceptionTest.java delete mode 100644 reception/src/test/java/org/onap/policy/distribution/reception/decoding/PluginTerminationExceptionTest.java delete mode 100644 reception/src/test/java/org/onap/policy/distribution/reception/decoding/PolicyDecodingExceptionTest.java create mode 100644 reception/src/test/java/org/onap/policy/distribution/reception/decoding/TestExceptions.java diff --git a/forwarding/pom.xml b/forwarding/pom.xml index 8fed5855..62b473fe 100644 --- a/forwarding/pom.xml +++ b/forwarding/pom.xml @@ -41,6 +41,11 @@ common-parameters ${policy.common.version} + + org.onap.policy.common + utils-test + ${policy.common.version} + org.onap.policy.models policy-models-tosca 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 bc8041a4..7e7718a1 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 @@ -3,6 +3,7 @@ * Copyright (C) 2018 Ericsson. All rights reserved. * Copyright (C) 2019 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Bell Canada. 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. @@ -22,6 +23,7 @@ package org.onap.policy.distribution.forwarding.parameters; +import lombok.AllArgsConstructor; import lombok.Getter; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.common.parameters.BeanValidator; @@ -37,26 +39,13 @@ import org.onap.policy.common.parameters.annotations.NotNull; */ @Getter @NotBlank +@AllArgsConstructor public class PolicyForwarderParameters implements ParameterGroup { private @NotNull String forwarderType; private @NotNull @ClassName String forwarderClassName; private String forwarderConfigurationName; - /** - * Constructor for instantiating PolicyForwarderParameters. - * - * @param forwarderType the policy forwarder type - * @param forwarderClassName the policy forwarder class name - * @param forwarderConfigurationName the name of the configuration for the policy forwarder - */ - public PolicyForwarderParameters(final String forwarderType, final String forwarderClassName, - final String forwarderConfigurationName) { - this.forwarderType = forwarderType; - this.forwarderClassName = forwarderClassName; - this.forwarderConfigurationName = forwarderConfigurationName; - } - /** * {@inheritDoc}. */ 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 deleted file mode 100644 index af820883..00000000 --- a/forwarding/src/test/java/org/onap/policy/distribution/forwarding/PolicyDecodingExceptionTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============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.forwarding; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class PolicyDecodingExceptionTest { - - @Test - public void testPolicyDecodingExceptionString() { - final PolicyForwardingException policyDecodingException = new PolicyForwardingException("error message"); - assertEquals("error message", policyDecodingException.getMessage()); - } - - @Test - public void testPolicyDecodingExceptionStringThrowable() { - 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/forwarding/src/test/java/org/onap/policy/distribution/forwarding/TestExceptions.java b/forwarding/src/test/java/org/onap/policy/distribution/forwarding/TestExceptions.java new file mode 100644 index 00000000..66e16651 --- /dev/null +++ b/forwarding/src/test/java/org/onap/policy/distribution/forwarding/TestExceptions.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Bell Canada. 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.forwarding; + +import org.junit.Test; +import org.onap.policy.common.utils.test.ExceptionsTester; + +public class TestExceptions { + + @Test + public void test() { + new ExceptionsTester().test(PolicyForwardingException.class); + } +} diff --git a/model/src/main/java/org/onap/policy/distribution/model/Csar.java b/model/src/main/java/org/onap/policy/distribution/model/Csar.java index df7eaf28..652d84cb 100644 --- a/model/src/main/java/org/onap/policy/distribution/model/Csar.java +++ b/model/src/main/java/org/onap/policy/distribution/model/Csar.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2021 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,24 +21,15 @@ package org.onap.policy.distribution.model; +import lombok.AllArgsConstructor; +import lombok.Getter; + /** * Represents a CSAR file that a {@link Policy} can be decoded from. */ +@Getter +@AllArgsConstructor public class Csar implements PolicyInput { private String csarFilePath; - - public Csar(final String csarFilePath) { - this.csarFilePath = csarFilePath; - } - - /** - * Get the path to the CSAR file. - * - * @return the path of the CSAR file - */ - public String getCsarPath() { - return csarFilePath; - } - } diff --git a/model/src/main/java/org/onap/policy/distribution/model/OptimizationPolicy.java b/model/src/main/java/org/onap/policy/distribution/model/OptimizationPolicy.java deleted file mode 100644 index d39c8dd9..00000000 --- a/model/src/main/java/org/onap/policy/distribution/model/OptimizationPolicy.java +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * ============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.model; - -import java.util.Date; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.apache.commons.lang3.NotImplementedException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; - -/** - * An optimization policy. - */ -@Getter -@Setter -@ToString -@EqualsAndHashCode(callSuper = true) -public class OptimizationPolicy extends ToscaEntity { - - private static final String OPTIMIZATION = "Optimization"; - private String policyName; - private String policyDescription; - private String onapName; - private String configBody; - private String configBodyType; - private Date timetolive; - private String guard; - private String riskLevel; - private String riskType; - - @Override - public String getName() { - return policyName; - } - - @Override - public void setName(final String name) { - this.policyName = name; - } - - @Override - public String getVersion() { - // Utilizing this method to return the policy type instead of version for the old model. - return OPTIMIZATION; - } - - @Override - public void setVersion(final String version) { - throw new NotImplementedException("Not supported"); - } -} diff --git a/model/src/main/java/org/onap/policy/distribution/model/PolicyAsString.java b/model/src/main/java/org/onap/policy/distribution/model/PolicyAsString.java index 1600d8f7..22dd8f57 100644 --- a/model/src/main/java/org/onap/policy/distribution/model/PolicyAsString.java +++ b/model/src/main/java/org/onap/policy/distribution/model/PolicyAsString.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2021 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,51 +21,18 @@ package org.onap.policy.distribution.model; +import lombok.AllArgsConstructor; +import lombok.Getter; + /** * This class represents a policy which can be decoded by a relevant {@link PolicyDecoder}. * * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com) */ +@Getter +@AllArgsConstructor public class PolicyAsString implements Policy { private String policyName; private String policyType; private String policy; - - /** - * Constructor for creating instance of {@link PolicyAsString}. - * - * @param policyName the policy file name - * @param policyType the policy type - * @param policy the policy - */ - public PolicyAsString(final String policyName, final String policyType, final String policy) { - this.policyName = policyName; - this.policyType = policyType; - this.policy = policy; - } - - /** - * Returns the policy of this {@link PolicyAsString} instance. - * - * @return the policy - */ - public String getPolicy() { - return policy; - } - - /** - * {@inheritDoc}. - */ - @Override - public String getPolicyName() { - return policyName; - } - - /** - * {@inheritDoc}. - */ - @Override - public String getPolicyType() { - return policyType; - } } diff --git a/model/src/main/java/org/onap/policy/distribution/model/Tosca.java b/model/src/main/java/org/onap/policy/distribution/model/Tosca.java index b7b14c4f..a1996b77 100644 --- a/model/src/main/java/org/onap/policy/distribution/model/Tosca.java +++ b/model/src/main/java/org/onap/policy/distribution/model/Tosca.java @@ -1,43 +1,35 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2021 Bell Canada. 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.model; +import lombok.AllArgsConstructor; +import lombok.Getter; + /** * Represents a TOSCA file that a {@link Policy} can be decoded from. */ +@Getter +@AllArgsConstructor public class Tosca implements PolicyInput { private String toscaFilePath; - - public Tosca(String toscaFilePath) { - this.toscaFilePath = toscaFilePath; - } - - /** - * Get the path to the TOSCA file. - * - * @return the path of the TOSCA file - */ - String getToscaFilePath() { - return toscaFilePath; - } - } diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java index fe7f2dcc..a552bbcc 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java @@ -3,6 +3,7 @@ * Copyright (C) 2018 Ericsson. All rights reserved. * Copyright (C) 2019 Nordix Foundation. * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Bell Canada. 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. @@ -74,7 +75,7 @@ public class PolicyDecoderFileInCsarToPolicy implements PolicyDecoder decode(final Csar csar) throws PolicyDecodingException { final Collection policyList = new ArrayList<>(); - try (var zipFile = new ZipFile(csar.getCsarPath())) { + try (var zipFile = new ZipFile(csar.getCsarFilePath())) { final Enumeration entries = zipFile.entries(); while (entries.hasMoreElements()) { // @@ -83,7 +84,7 @@ public class PolicyDecoderFileInCsarToPolicy implements PolicyDecoder { */ @Override public Collection decode(final Csar input) throws PolicyDecodingException { - final DummyPolicy dummyPolicy = new DummyPolicy(input.getCsarPath()); + final DummyPolicy dummyPolicy = new DummyPolicy(input.getCsarFilePath()); decodedPolicy = dummyPolicy; return Arrays.asList(dummyPolicy); } diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestComponentDoneStatusMessage.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestComponentDoneStatusMessage.java index 75e32243..c5935822 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestComponentDoneStatusMessage.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestComponentDoneStatusMessage.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Intel. All rights reserved. + * Modifications Copyright (C) 2021 Bell Canada. 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. @@ -27,34 +28,31 @@ import org.onap.sdc.utils.DistributionStatusEnum; public class TestComponentDoneStatusMessage { + private static final String CONSUMER_ID = "dummyId"; + private static final String DISTRIBUTION_ID = "dummyDistribution"; + @Test public void testComponentDoneStatusMessage_Success() { - final String consumerId = "dummyId"; - final String distributionId = "dummyDistribution"; final long timestamp = System.currentTimeMillis(); - final ComponentDoneStatusMessageBuilder messageBuilder = - new ComponentDoneStatusMessageBuilder().setConsumerId(consumerId).setDistributionId(distributionId) - .setDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK).setTimestamp(timestamp); - final ComponentDoneStatusMessage message = new ComponentDoneStatusMessage(messageBuilder); + final ComponentDoneStatusMessage message = ComponentDoneStatusMessage.builder().consumerId(CONSUMER_ID) + .distributionId(DISTRIBUTION_ID).distributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK) + .timestamp(timestamp).build(); assertEquals("POLICY", message.getComponentName()); - assertEquals(consumerId, message.getConsumerID()); - assertEquals(distributionId, message.getDistributionID()); + assertEquals(CONSUMER_ID, message.getConsumerID()); + assertEquals(DISTRIBUTION_ID, message.getDistributionID()); assertEquals(DistributionStatusEnum.COMPONENT_DONE_OK, message.getStatus()); assertEquals(timestamp, message.getTimestamp()); } @Test public void testComponentDoneStatusMessage_Failure() { - final String consumerId = "dummyId"; - final String distributionId = "dummyDistribution"; final long timestamp = System.currentTimeMillis(); - final ComponentDoneStatusMessageBuilder messageBuilder = - new ComponentDoneStatusMessageBuilder().setConsumerId(consumerId).setDistributionId(distributionId) - .setDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR).setTimestamp(timestamp); - final ComponentDoneStatusMessage message = new ComponentDoneStatusMessage(messageBuilder); + final ComponentDoneStatusMessage message = ComponentDoneStatusMessage.builder().consumerId(CONSUMER_ID) + .distributionId(DISTRIBUTION_ID).distributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR) + .timestamp(timestamp).build(); assertEquals("POLICY", message.getComponentName()); - assertEquals(consumerId, message.getConsumerID()); - assertEquals(distributionId, message.getDistributionID()); + assertEquals(CONSUMER_ID, message.getConsumerID()); + assertEquals(DISTRIBUTION_ID, message.getDistributionID()); assertEquals(DistributionStatusEnum.COMPONENT_DONE_ERROR, message.getStatus()); assertEquals(timestamp, message.getTimestamp()); } diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestDistributionStatusMessage.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestDistributionStatusMessage.java index be127776..62cf0f3d 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestDistributionStatusMessage.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestDistributionStatusMessage.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Intel. All rights reserved. + * Modifications Copyright (C) 2021 Bell Canada. 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. @@ -27,38 +28,34 @@ import org.onap.sdc.utils.DistributionStatusEnum; public class TestDistributionStatusMessage { + private static final String ARTIFACT_URL = "http://dummyurl"; + private static final String CONSUMER_ID = "dummyId"; + private static final String DISTRIBUTION_ID = "dummyDistribution"; + @Test public void testDistributionStatusMessage_Download() { - final String artifactUrl = "http://dummyurl"; - final String consumerId = "dummyId"; - final String distributionId = "dummyDistribution"; final long timestamp = System.currentTimeMillis(); - final DistributionStatusMessageBuilder messageBuilder = new DistributionStatusMessageBuilder() - .setArtifactUrl(artifactUrl).setConsumerId(consumerId).setDistributionId(distributionId) - .setDistributionStatus(DistributionStatusEnum.DOWNLOAD_OK).setTimestamp(timestamp); - final DistributionStatusMessage message = new DistributionStatusMessage(messageBuilder); - assertEquals(artifactUrl, message.getArtifactURL()); - assertEquals(consumerId, message.getConsumerID()); - assertEquals(distributionId, message.getDistributionID()); + final DistributionStatusMessage message = DistributionStatusMessage.builder().artifactUrl(ARTIFACT_URL) + .consumerId(CONSUMER_ID).distributionId(DISTRIBUTION_ID) + .distributionStatus(DistributionStatusEnum.DOWNLOAD_OK).timestamp(timestamp).build(); + assertEquals(ARTIFACT_URL, message.getArtifactURL()); + assertEquals(CONSUMER_ID, message.getConsumerID()); + assertEquals(DISTRIBUTION_ID, message.getDistributionID()); assertEquals(DistributionStatusEnum.DOWNLOAD_OK, message.getStatus()); assertEquals(timestamp, message.getTimestamp()); } @Test public void testDistributionStatusMessage_Deploy() { - final String artifactUrl = "http://dummyurl"; - final String consumerId = "dummyId"; - final String distributionId = "dummyDistribution"; final long timestamp = System.currentTimeMillis(); - final DistributionStatusMessageBuilder messageBuilder = new DistributionStatusMessageBuilder() - .setArtifactUrl(artifactUrl).setConsumerId(consumerId).setDistributionId(distributionId) - .setDistributionStatus(DistributionStatusEnum.DEPLOY_OK).setTimestamp(timestamp); - final DistributionStatusMessage message = new DistributionStatusMessage(messageBuilder); - assertEquals(artifactUrl, message.getArtifactURL()); - assertEquals(consumerId, message.getConsumerID()); - assertEquals(distributionId, message.getDistributionID()); + final DistributionStatusMessage message = DistributionStatusMessage.builder().artifactUrl(ARTIFACT_URL) + .consumerId(CONSUMER_ID).distributionId(DISTRIBUTION_ID) + .distributionStatus(DistributionStatusEnum.DEPLOY_OK).timestamp(timestamp).build(); + assertEquals(ARTIFACT_URL, message.getArtifactURL()); + assertEquals(CONSUMER_ID, message.getConsumerID()); + assertEquals(DISTRIBUTION_ID, message.getDistributionID()); assertEquals(DistributionStatusEnum.DEPLOY_OK, message.getStatus()); assertEquals(timestamp, message.getTimestamp()); } diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactDownloadExceptionTest.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactDownloadExceptionTest.java deleted file mode 100644 index 492dbfd6..00000000 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactDownloadExceptionTest.java +++ /dev/null @@ -1,35 +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.handling.sdc.exceptions; - -import static org.junit.Assert.assertNotNull; - -import java.io.IOException; -import org.junit.Test; - -public class ArtifactDownloadExceptionTest { - - @Test - public void test() { - assertNotNull(new ArtifactDownloadException("Message")); - assertNotNull(new ArtifactDownloadException("Message", new IOException())); - } -} diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactInstallerExceptionTest.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactInstallerExceptionTest.java deleted file mode 100644 index 32a2f2d8..00000000 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactInstallerExceptionTest.java +++ /dev/null @@ -1,35 +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.handling.sdc.exceptions; - -import static org.junit.Assert.assertNotNull; - -import java.io.IOException; -import org.junit.Test; - -public class ArtifactInstallerExceptionTest { - - @Test - public void test() { - assertNotNull(new ArtifactInstallerException("Message")); - assertNotNull(new ArtifactInstallerException("Message", new IOException())); - } -} 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 deleted file mode 100644 index 20fd5388..00000000 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdControllerExceptionTest.java +++ /dev/null @@ -1,35 +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.handling.sdc.exceptions; - -import static org.junit.Assert.assertNotNull; - -import java.io.IOException; -import org.junit.Test; - -public class PssdControllerExceptionTest { - - @Test - public void test() { - 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/PssdParametersExceptionTest.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdParametersExceptionTest.java deleted file mode 100644 index 66038d77..00000000 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdParametersExceptionTest.java +++ /dev/null @@ -1,35 +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.handling.sdc.exceptions; - -import static org.junit.Assert.assertNotNull; - -import java.io.IOException; -import org.junit.Test; - -public class PssdParametersExceptionTest { - - @Test - public void test() { - assertNotNull(new PssdParametersException("Message")); - assertNotNull(new PssdParametersException("Message", new IOException())); - } -} diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/TestExceptions.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/TestExceptions.java new file mode 100644 index 00000000..2b6c98dc --- /dev/null +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/TestExceptions.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Bell Canada. 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.handling.sdc.exceptions; + +import org.junit.Test; +import org.onap.policy.common.utils.test.ExceptionsTester; + +public class TestExceptions { + + @Test + public void test() { + new ExceptionsTester().test(ArtifactDownloadException.class); + } +} 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 492e2e05..23fac03d 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 @@ -3,6 +3,7 @@ * Copyright (C) 2018 Ericsson. All rights reserved. * Copyright (C) 2019 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Bell Canada. 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. @@ -22,6 +23,7 @@ package org.onap.policy.distribution.reception.parameters; +import lombok.AllArgsConstructor; import lombok.Getter; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.common.parameters.BeanValidator; @@ -37,25 +39,12 @@ import org.onap.policy.common.parameters.annotations.NotNull; */ @Getter @NotBlank +@AllArgsConstructor public class PolicyDecoderParameters implements ParameterGroup { private @NotNull String decoderType; private @NotNull @ClassName String decoderClassName; private String decoderConfigurationName; - /** - * Constructor for instantiating PolicyDecoderParameters. - * - * @param decoderType the policy decoder type - * @param decoderClassName the policy decoder class name - * @param decoderConfigurationName the policy decoder configuration name - */ - public PolicyDecoderParameters(final String decoderType, final String decoderClassName, - final String decoderConfigurationName) { - this.decoderType = decoderType; - this.decoderClassName = decoderClassName; - this.decoderConfigurationName = decoderConfigurationName; - } - /** * {@inheritDoc}. */ diff --git a/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PluginInitializationExceptionTest.java b/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PluginInitializationExceptionTest.java deleted file mode 100644 index b63e6677..00000000 --- a/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PluginInitializationExceptionTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============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 {@link PluginInitializationException}. - * - * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com) - */ -public class PluginInitializationExceptionTest { - - @Test - public void testPluginInitializationExceptionString() { - final PluginInitializationException pluginInitializationException = - new PluginInitializationException("error message"); - assertEquals("error message", pluginInitializationException.getMessage()); - } - - @Test - public void testPluginInitializationExceptionStringThrowable() { - final Exception cause = new IllegalArgumentException(); - final PluginInitializationException pluginInitializationException = - new PluginInitializationException("error message", cause); - assertEquals("error message", pluginInitializationException.getMessage()); - assertEquals(cause, pluginInitializationException.getCause()); - } - -} diff --git a/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PluginTerminationExceptionTest.java b/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PluginTerminationExceptionTest.java deleted file mode 100644 index c2fc6a94..00000000 --- a/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PluginTerminationExceptionTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============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 {@link PluginTerminationException}. - * - * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com) - */ -public class PluginTerminationExceptionTest { - - @Test - public void testPluginTerminationExceptionString() { - final PluginTerminationException pluginTerminationException = new PluginTerminationException("error message"); - assertEquals("error message", pluginTerminationException.getMessage()); - } - - @Test - public void testPluginTerminationExceptionStringThrowable() { - final Exception cause = new IllegalArgumentException(); - final PluginTerminationException pluginTerminationException = new PluginTerminationException("error message", - cause); - assertEquals("error message", pluginTerminationException.getMessage()); - assertEquals(cause, pluginTerminationException.getCause()); - } - -} diff --git a/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PolicyDecodingExceptionTest.java b/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PolicyDecodingExceptionTest.java deleted file mode 100644 index a5bc072e..00000000 --- a/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PolicyDecodingExceptionTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============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; - -public class PolicyDecodingExceptionTest { - - @Test - public void testPolicyDecodingExceptionString() { - final PolicyDecodingException policyDecodingException = new PolicyDecodingException("error message"); - assertEquals("error message", policyDecodingException.getMessage()); - } - - @Test - public void testPolicyDecodingExceptionStringThrowable() { - final Exception cause = new IllegalArgumentException(); - final PolicyDecodingException policyDecodingException = new PolicyDecodingException("error message", cause); - assertEquals("error message", policyDecodingException.getMessage()); - assertEquals(cause, policyDecodingException.getCause()); - } - -} diff --git a/reception/src/test/java/org/onap/policy/distribution/reception/decoding/TestExceptions.java b/reception/src/test/java/org/onap/policy/distribution/reception/decoding/TestExceptions.java new file mode 100644 index 00000000..2b52eb27 --- /dev/null +++ b/reception/src/test/java/org/onap/policy/distribution/reception/decoding/TestExceptions.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Bell Canada. 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 org.junit.Test; +import org.onap.policy.common.utils.test.ExceptionsTester; + +public class TestExceptions { + + @Test + public void test() { + new ExceptionsTester().test(PluginInitializationException.class); + new ExceptionsTester().test(PluginTerminationException.class); + new ExceptionsTester().test(PolicyDecodingException.class); + } +} -- cgit 1.2.3-korg