aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@est.tech>2019-10-18 09:47:22 +0000
committerGerrit Code Review <gerrit@onap.org>2019-10-18 09:47:22 +0000
commitd0cca771fa39943a46470240cd0106941056e974 (patch)
tree03efbd489314c3a963c831b66997cfb4de353f32
parente82e4dfcc6ba261cd8b0129e9d8a62642a54549b (diff)
parentdc182bf477bc1d749abd5102f90f666bca45e37e (diff)
Merge "Add PolicyNotification.isEmpty() method"
-rw-r--r--models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyNotification.java10
-rw-r--r--models-pap/src/test/java/org/onap/policy/models/pap/concepts/PolicyNotificationTest.java12
2 files changed, 22 insertions, 0 deletions
diff --git a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyNotification.java b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyNotification.java
index a9c22c463..1cdf254c4 100644
--- a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyNotification.java
+++ b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyNotification.java
@@ -45,4 +45,14 @@ public class PolicyNotification {
this.added = added;
this.deleted = deleted;
}
+
+ /**
+ * Determines if the notification is empty (i.e., has no added or delete policy
+ * notifications).
+ *
+ * @return {@code true} if the notification is empty, {@code false} otherwise
+ */
+ public boolean isEmpty() {
+ return (added.isEmpty() && deleted.isEmpty());
+ }
}
diff --git a/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PolicyNotificationTest.java b/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PolicyNotificationTest.java
index 3c7b0cab6..10c7c5fee 100644
--- a/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PolicyNotificationTest.java
+++ b/models-pap/src/test/java/org/onap/policy/models/pap/concepts/PolicyNotificationTest.java
@@ -19,9 +19,12 @@
package org.onap.policy.models.pap.concepts;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import org.junit.Test;
import org.onap.policy.common.utils.coder.CoderException;
@@ -56,5 +59,14 @@ public class PolicyNotificationTest {
// test equals() method (and verify encode/decode worked)
assertEquals(notify, notify2);
+
+ /*
+ * Test isEmpty()
+ */
+ assertFalse(notify.isEmpty());
+ assertFalse(notify2.isEmpty());
+ assertTrue(new PolicyNotification().isEmpty());
+ assertFalse(new PolicyNotification(add, Collections.emptyList()).isEmpty());
+ assertFalse(new PolicyNotification(Collections.emptyList(), del).isEmpty());
}
}