From 9ede89131044d171187c5be906aefee615a0e568 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Tue, 9 Apr 2019 11:55:57 +0000 Subject: Complete unit test for models-pdp This review completes the unit test for the models-pdp module, for persistence of PDP groups and for PDP group filtering. Added unit test of filters for TOSCA policy types and policies. Added fix to allow filters to pass when the value being checked is null. Issue-ID: POLICY-1095 Change-Id: I982400ef39f0282d813d49e484a58207e03b8a63 Signed-off-by: liamfallon --- .../src/main/java/org/onap/policy/models/base/PfObjectFilter.java | 4 ++-- .../test/java/org/onap/policy/models/base/PfObjectFilterTest.java | 8 -------- 2 files changed, 2 insertions(+), 10 deletions(-) (limited to 'models-base/src') 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 501d9c353..10ce4ea60 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 @@ -49,8 +49,8 @@ public interface PfObjectFilter> { * @param pattern the pattern to check against * @return match or not */ - public default boolean filterString(@NonNull final String value, final String pattern) { - return pattern == null || value.equals(pattern); + public default boolean filterString(final String value, final String pattern) { + return value == null || pattern == null || value.equals(pattern); } /** diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfObjectFilterTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfObjectFilterTest.java index 3d16f8e3f..c13140726 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/PfObjectFilterTest.java +++ b/models-base/src/test/java/org/onap/policy/models/base/PfObjectFilterTest.java @@ -84,14 +84,6 @@ public class PfObjectFilterTest { assertFalse(dof.filterString("Hello", "Goodbye")); assertTrue(dof.filterString("Hello", "Hello")); - assertThatThrownBy(() -> { - dof.filterString(null, null); - }).hasMessage("value is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - dof.filterString(null, "hello"); - }).hasMessage("value is marked @NonNull but is null"); - assertEquals(false, dof.filterString("Hello", "Goodbye")); assertEquals(true, dof.filterString("Hello", "Hello")); assertEquals(true, dof.filterString("Hello", null)); -- cgit 1.2.3-korg