summaryrefslogtreecommitdiffstats
path: root/models-base
diff options
context:
space:
mode:
Diffstat (limited to 'models-base')
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfObjectFilter.java1
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfUtils.java2
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/PfUtilsTest.java10
3 files changed, 12 insertions, 1 deletions
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfObjectFilter.java b/models-base/src/main/java/org/onap/policy/models/base/PfObjectFilter.java
index a7d8401f0..6ede4d9a3 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfObjectFilter.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfObjectFilter.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property. 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.
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 7bdd9a5f4..c33271d78 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
@@ -73,7 +73,7 @@ public final class PfUtils {
*/
public static <T> List<T> mapList(List<T> source, Function<T, T> mapFunc) {
if (source == null) {
- return new ArrayList<>();
+ return new ArrayList<>(0);
}
return source.stream().map(mapFunc).collect(Collectors.toList());
diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfUtilsTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfUtilsTest.java
index 11ddf3132..339ee9d1b 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/PfUtilsTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/PfUtilsTest.java
@@ -52,9 +52,19 @@ public class PfUtilsTest {
});
assertTrue(resultList.isEmpty());
+ // verify that we can modify the empty list without throwing an exception
+ resultList.add("xyz");
+ resultList.add("pdq");
+ resultList.remove("xyz");
+
+
List<String> origList = Arrays.asList("abc", "def");
List<String> newList = PfUtils.mapList(origList, text -> text + "X");
assertEquals(Arrays.asList("abcX", "defX"), newList);
+
+ // verify that we can modify the list without throwing an exception
+ newList.remove("abcX");
+ newList.add("something else");
}
}