From 899d7fc8108e249a1de815024b98055adaf65bfe Mon Sep 17 00:00:00 2001 From: ramverma Date: Tue, 18 Sep 2018 20:15:02 +0100 Subject: Fix sonar & add test cases for models * As per jacoco, the try-with-resources coverage issue is fixed in 0.8.0 release - https://www.jacoco.org/jacoco/trunk/doc/changes.html * Adding openpojo test for all the models in distribution-model * Removed jacoco version from distribution pom as oparent 1.2.1 already comes with jacoco 0.8.2 Change-Id: I55e2891a0dad1f10113730b46f10d760a883bea6 Issue-ID: POLICY-922 Signed-off-by: ramverma --- model/pom.xml | 5 +++ .../distribution/model/OptimizationPolicy.java | 2 +- .../onap/policy/distribution/model/TestModels.java | 43 ++++++++++++++++++++++ .../file/PolicyDecoderFileInCsarToPolicy.java | 2 +- 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 model/src/test/java/org/onap/policy/distribution/model/TestModels.java diff --git a/model/pom.xml b/model/pom.xml index f3e26234..6ccfa6b2 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -31,5 +31,10 @@ [${project.parent.artifactId}] module provides the model for policy distribution + + org.onap.policy.common + utils + ${policy.common.version} + 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 index 71b7cef7..2ca3c945 100644 --- a/model/src/main/java/org/onap/policy/distribution/model/OptimizationPolicy.java +++ b/model/src/main/java/org/onap/policy/distribution/model/OptimizationPolicy.java @@ -61,7 +61,7 @@ public class OptimizationPolicy implements Policy { } public String getPolicyConfigType() { - return OPTIMIZATION; + return getPolicyType(); } public String getOnapName() { diff --git a/model/src/test/java/org/onap/policy/distribution/model/TestModels.java b/model/src/test/java/org/onap/policy/distribution/model/TestModels.java new file mode 100644 index 00000000..060ab36f --- /dev/null +++ b/model/src/test/java/org/onap/policy/distribution/model/TestModels.java @@ -0,0 +1,43 @@ +/*- + * ============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 com.openpojo.reflection.filters.FilterPackageInfo; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; + +import org.junit.Test; + +/** + * Class to perform unit testing of all policy models. + * + * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com) + */ +public class TestModels { + + @Test + public void testAllModels() { + final Validator validator = ValidatorBuilder.create().with(new SetterTester()).with(new GetterTester()).build(); + validator.validate(Policy.class.getPackage().getName(), new FilterPackageInfo()); + } +} 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 06a57a39..482ac80b 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 @@ -83,7 +83,7 @@ public class PolicyDecoderFileInCsarToPolicy implements PolicyDecoder