From: Chris Ramstad Date: Tue, 17 Mar 2020 18:52:02 +0000 (-0700) Subject: Misc simple sonar issue fixes X-Git-Tag: 2.2.1~10^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=8fdfe4bdac025f450d6b9ea70d7c48afa98fc37e;p=policy%2Fmodels.git Misc simple sonar issue fixes Issue-ID: POLICY-2389 Signed-off-by: Chris Ramstad Change-Id: I7ce91e331a128aaadaab5ac837e19873a3388164 --- diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfUtils.java b/models-base/src/main/java/org/onap/policy/models/base/PfUtils.java index 8f1040bfe..fa7d21f9d 100644 --- a/models-base/src/main/java/org/onap/policy/models/base/PfUtils.java +++ b/models-base/src/main/java/org/onap/policy/models/base/PfUtils.java @@ -26,7 +26,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.function.Function; +import java.util.function.UnaryOperator; import java.util.stream.Collectors; import javax.ws.rs.core.Response; @@ -76,7 +76,7 @@ public final class PfUtils { * @param defaultValue value to be returned if source is {@code null} * @return a new list, containing mappings of all of the items in the original list */ - public static List mapList(List source, Function mapFunc, List defaultValue) { + public static List mapList(List source, UnaryOperator mapFunc, List defaultValue) { if (source == null) { return defaultValue; } @@ -93,7 +93,7 @@ public final class PfUtils { * @return a new list, containing mappings of all of the items in the original list, * or {@code null} if the source is {@code null} */ - public static List mapList(List source, Function mapFunc) { + public static List mapList(List source, UnaryOperator mapFunc) { return mapList(source, mapFunc, null); } @@ -106,7 +106,7 @@ public final class PfUtils { * @param defaultValue value to be returned if source is {@code null} * @return a new map, containing mappings of all of the items in the original map */ - public static Map mapMap(Map source, Function mapFunc, + public static Map mapMap(Map source, UnaryOperator mapFunc, Map defaultValue) { if (source == null) { return defaultValue; @@ -129,7 +129,7 @@ public final class PfUtils { * @return a new map, containing mappings of all of the items in the original map, * or {@code null} if the source is {@code null} */ - public static Map mapMap(Map source, Function mapFunc) { + public static Map mapMap(Map source, UnaryOperator mapFunc) { return mapMap(source, mapFunc, null); } diff --git a/models-base/src/main/java/org/onap/policy/models/base/Validated.java b/models-base/src/main/java/org/onap/policy/models/base/Validated.java index 7a0a8377b..26a8a5260 100644 --- a/models-base/src/main/java/org/onap/policy/models/base/Validated.java +++ b/models-base/src/main/java/org/onap/policy/models/base/Validated.java @@ -70,6 +70,7 @@ public class Validated { * @param result where to place the result * @return the result */ + @SuppressWarnings("java:S3252") // squelch sonar warning for using PkConceptKey instead of PfKeyImpl public PfValidationResult validateNotNull(@NonNull PfConceptKey value, @NonNull PfValidationResult result) { if (PfConceptKey.NULL_KEY_NAME.equals(value.getName())) { diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java b/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java index 6707e70a2..d78172436 100644 --- a/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java +++ b/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java @@ -586,7 +586,7 @@ public class DefaultPfDao implements PfDao { * @return the updated query string */ private String setQueryTable(final String queryString, final Class tableClass) { - return queryString.replaceAll(TABLE_TOKEN, tableClass.getSimpleName()); + return queryString.replace(TABLE_TOKEN, tableClass.getSimpleName()); } /** diff --git a/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java b/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java index ac700c866..dcb5d1772 100644 --- a/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java +++ b/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java @@ -29,10 +29,10 @@ public class ControlLoopTargetTypeTest { @Test public void test() { - assertEquals("VM", ControlLoopTargetType.VM); - assertEquals("VF", ControlLoopTargetType.VF); - assertEquals("VFC", ControlLoopTargetType.VFC); - assertEquals("VNF", ControlLoopTargetType.VNF); - assertEquals("PNF", ControlLoopTargetType.PNF); + assertEquals(ControlLoopTargetType.VM, "VM"); + assertEquals(ControlLoopTargetType.VF, "VF"); + assertEquals(ControlLoopTargetType.VFC, "VFC"); + assertEquals(ControlLoopTargetType.VNF, "VNF"); + assertEquals(ControlLoopTargetType.PNF, "PNF"); } }