Merge "Misc simple sonar issue fixes"
authorLiam Fallon <liam.fallon@est.tech>
Fri, 20 Mar 2020 09:31:29 +0000 (09:31 +0000)
committerGerrit Code Review <gerrit@onap.org>
Fri, 20 Mar 2020 09:31:29 +0000 (09:31 +0000)
models-base/src/main/java/org/onap/policy/models/base/PfUtils.java
models-base/src/main/java/org/onap/policy/models/base/Validated.java
models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java
models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java

index 8f1040b..fa7d21f 100644 (file)
@@ -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 <T> List<T> mapList(List<T> source, Function<T, T> mapFunc, List<T> defaultValue) {
+    public static <T> List<T> mapList(List<T> source, UnaryOperator<T> mapFunc, List<T> 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 <T> List<T> mapList(List<T> source, Function<T, T> mapFunc) {
+    public static <T> List<T> mapList(List<T> source, UnaryOperator<T> 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 <T> Map<String, T> mapMap(Map<String, T> source, Function<T, T> mapFunc,
+    public static <T> Map<String, T> mapMap(Map<String, T> source, UnaryOperator<T> mapFunc,
                     Map<String, T> 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 <T> Map<String, T> mapMap(Map<String, T> source, Function<T, T> mapFunc) {
+    public static <T> Map<String, T> mapMap(Map<String, T> source, UnaryOperator<T> mapFunc) {
         return mapMap(source, mapFunc, null);
     }
 
index 7a0a837..26a8a52 100644 (file)
@@ -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())) {
index 6707e70..d781724 100644 (file)
@@ -586,7 +586,7 @@ public class DefaultPfDao implements PfDao {
      * @return the updated query string
      */
     private <T extends PfConcept> String setQueryTable(final String queryString, final Class<T> tableClass) {
-        return queryString.replaceAll(TABLE_TOKEN, tableClass.getSimpleName());
+        return queryString.replace(TABLE_TOKEN, tableClass.getSimpleName());
     }
 
     /**
index ac700c8..dcb5d17 100644 (file)
@@ -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");
     }
 }