summaryrefslogtreecommitdiffstats
path: root/main/src/test/java/org
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-05-04 20:13:11 -0400
committerJim Hahn <jrh3@att.com>2020-05-04 20:19:11 -0400
commit26df07d10d9b0a7e6e9e9ab2d9cc14ed735c0d1d (patch)
treead4887722c794b6e8b5b8b87ac894aaf60107803 /main/src/test/java/org
parented81ba9cc8e54c3c2d8c70972a6307a1b5bbe86a (diff)
Eliminate spurious notifications from PAP
Tracked it down to the following sequence: - policies were deployed to the pdp - received a request to undeploy a policy - generated a notification for the formerly deployed policy - this should not have been generated - undeployed the policy - received a response from the pdp indicating the policy had been undeployed - generated a notification indicating the policy was undeployed Removed the code that generated a notification when a policy is initially moved from deployed to undeployed (or vice versa). Issue-ID: POLICY-2539 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: If175974b5fa5ccda6a1e1ab8fa1326b263bb8005
Diffstat (limited to 'main/src/test/java/org')
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/notification/PolicyCommonTrackerTest.java24
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/notification/PolicyNotifierTest.java17
2 files changed, 8 insertions, 33 deletions
diff --git a/main/src/test/java/org/onap/policy/pap/main/notification/PolicyCommonTrackerTest.java b/main/src/test/java/org/onap/policy/pap/main/notification/PolicyCommonTrackerTest.java
index e8c03d1d..fc43c7a9 100644
--- a/main/src/test/java/org/onap/policy/pap/main/notification/PolicyCommonTrackerTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/notification/PolicyCommonTrackerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 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.
@@ -141,9 +141,7 @@ public class PolicyCommonTrackerTest extends PolicyCommonSupport {
tracker.addData(makeData(policy2, PDP1, PDP3));
// remove a policy that isn't in the map
- List<PolicyStatus> statusList = new ArrayList<>();
- tracker.removeData(makeData(policy3, PDP1), statusList);
- assertTrue(statusList.isEmpty());
+ tracker.removeData(makeData(policy3, PDP1));
assertEquals(2, map.size());
}
@@ -155,10 +153,8 @@ public class PolicyCommonTrackerTest extends PolicyCommonSupport {
tracker.addData(makeData(policy1, PDP1, PDP2));
tracker.addData(makeData(policy2, PDP1, PDP3));
- // remove some PDPs from a policy - no notifications and no changes to the map
- List<PolicyStatus> statusList = new ArrayList<>();
- tracker.removeData(makeData(policy2, PDP1), statusList);
- assertTrue(statusList.isEmpty());
+ // remove some PDPs from a policy - no changes to the map
+ tracker.removeData(makeData(policy2, PDP1));
assertTrue(map.containsKey(policy1));
assertTrue(map.containsKey(policy2));
}
@@ -180,11 +176,7 @@ public class PolicyCommonTrackerTest extends PolicyCommonSupport {
tracker.addData(makeData(policy2, PDP1, PDP3));
// remove all the PDPs from one policy, but do NOT remove the policy
- List<PolicyStatus> statusList = new ArrayList<>();
- tracker.removeData(makeData(policy2, PDP1, PDP3), statusList);
- assertEquals(1, statusList.size());
- assertEquals(policy2, statusList.get(0).getPolicy());
- assertEquals(type, statusList.get(0).getPolicyType());
+ tracker.removeData(makeData(policy2, PDP1, PDP3));
assertTrue(map.containsKey(policy1));
assertTrue(map.containsKey(policy2));
}
@@ -198,11 +190,7 @@ public class PolicyCommonTrackerTest extends PolicyCommonSupport {
tracker.addData(makeData(policy2, PDP1, PDP3));
// remove all the PDPs from one policy, and remove the policy
- List<PolicyStatus> statusList = new ArrayList<>();
- tracker.removeData(makeData(policy1, PDP1, PDP2, PDP3), statusList);
- assertEquals(1, statusList.size());
- assertEquals(policy1, statusList.get(0).getPolicy());
- assertEquals(type, statusList.get(0).getPolicyType());
+ tracker.removeData(makeData(policy1, PDP1, PDP2, PDP3));
assertFalse(map.containsKey(policy1));
assertTrue(map.containsKey(policy2));
}
diff --git a/main/src/test/java/org/onap/policy/pap/main/notification/PolicyNotifierTest.java b/main/src/test/java/org/onap/policy/pap/main/notification/PolicyNotifierTest.java
index 478c63c9..1305f27e 100644
--- a/main/src/test/java/org/onap/policy/pap/main/notification/PolicyNotifierTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/notification/PolicyNotifierTest.java
@@ -22,7 +22,6 @@ package org.onap.policy.pap.main.notification;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
@@ -223,32 +222,20 @@ public class PolicyNotifierTest extends PolicyCommonSupport {
@Test
public void testAddDeploymentData() {
- doAnswer(addStatus(1, status1, status2)).when(undeploy).removeData(any(), any());
-
PolicyPdpNotificationData data = makeData(policy1, PDP1, PDP2);
notifier.addDeploymentData(data);
verify(deploy).addData(data);
- verify(undeploy).removeData(eq(data), any());
-
- PolicyNotification notification = getNotification();
- assertEquals(Arrays.asList(status1, status2), notification.getDeleted());
- assertTrue(notification.getAdded().isEmpty());
+ verify(undeploy).removeData(eq(data));
}
@Test
public void testAddUndeploymentData() {
- doAnswer(addStatus(1, status1, status2)).when(deploy).removeData(any(), any());
-
PolicyPdpNotificationData data = makeData(policy1, PDP1, PDP2);
notifier.addUndeploymentData(data);
verify(undeploy).addData(data);
- verify(deploy).removeData(eq(data), any());
-
- PolicyNotification notification = getNotification();
- assertEquals(Arrays.asList(status1, status2), notification.getAdded());
- assertTrue(notification.getDeleted().isEmpty());
+ verify(deploy).removeData(eq(data));
}
@Test