* ============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.
* Removes a set of PDPs from all policies within the tracker.
*
* @param notifyData data identifying the policy and the PDPs to be removed from it
- * @param statusList status messages are added here if policies become complete as a
- * result of this operation
*/
- public void removeData(PolicyPdpNotificationData notifyData, List<PolicyStatus> statusList) {
+ public void removeData(PolicyPdpNotificationData notifyData) {
policy2data.computeIfPresent(notifyData.getPolicyId(), (policyId, data) -> {
return data;
}
- // this policy is complete - notify
- statusList.add(makeStatus(policyId, data));
-
+ // this policy is complete
return (shouldRemove(data) ? null : data);
});
}
* ============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.
* @param data data to be added
*/
public synchronized void addDeploymentData(PolicyPdpNotificationData data) {
- PolicyNotification notification = new PolicyNotification();
-
- undeployTracker.removeData(data, notification.getDeleted());
+ undeployTracker.removeData(data);
deployTracker.addData(data);
-
- publish(notification);
}
/**
* @param data data to be added
*/
public synchronized void addUndeploymentData(PolicyPdpNotificationData data) {
- PolicyNotification notification = new PolicyNotification();
-
- deployTracker.removeData(data, notification.getAdded());
+ deployTracker.removeData(data);
undeployTracker.addData(data);
-
- publish(notification);
}
/**
* ============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.
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());
}
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));
}
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));
}
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));
}
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;
@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