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 --- .../parameters/PolicyDecoderParameters.java | 17 ++------ .../PluginInitializationExceptionTest.java | 50 ---------------------- .../decoding/PluginTerminationExceptionTest.java | 49 --------------------- .../decoding/PolicyDecodingExceptionTest.java | 43 ------------------- .../reception/decoding/TestExceptions.java | 34 +++++++++++++++ 5 files changed, 37 insertions(+), 156 deletions(-) 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 (limited to 'reception/src') 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