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 --- .../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 +++++++++++++++++++ 8 files changed, 65 insertions(+), 177 deletions(-) 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 (limited to 'plugins/reception-plugins/src/test/java/org') diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/DummyDecoder.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/DummyDecoder.java index f0e301ca..f8b87f82 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/DummyDecoder.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/DummyDecoder.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2020 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. @@ -50,7 +51,7 @@ public class DummyDecoder 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); + } +} -- cgit 1.2.3-korg