+ StdPDPNotification check = NotificationStore.getDeltaNotification(PolicyUtils.jsonStringToObject("{\"removedPolicies\":[{\"policyName\":\"com.testing\",\"versionNo\":\"1\"},{\"policyName\":\"com.testing\",\"versionNo\":\"2\"}],\"loadedPolicies\":[{\"policyName\":\"com.test\",\"versionNo\":\"3\",\"matches\":{\"test\":\"test\"},\"updateType\":\"NEW\"}],\"notificationType\":\"BOTH\"}", StdPDPNotification.class));
+ assertEquals("{\"removedPolicies\":[],\"loadedPolicies\":[],\"notificationType\":null}", PolicyUtils.objectToJsonString(check));
+ // Remove Notifications.
+ notification = new StdPDPNotification();
+ notification.setNotificationType(NotificationType.REMOVE);
+ removedPolicies = new ArrayList<>();
+ removedPolicy = new StdRemovedPolicy();
+ removedPolicy.setPolicyName("com.test.3.xml");
+ removedPolicy.setVersionNo("3");
+ removedPolicies.add(removedPolicy);
+ notification.setRemovedPolicies(removedPolicies);
+ NotificationStore.recordNotification(notification);
+ check = NotificationStore.getDeltaNotification(PolicyUtils.jsonStringToObject("{\"removedPolicies\":[{\"policyName\":\"com.test\",\"versionNo\":\"3\"},{\"policyName\":\"com.testing\",\"versionNo\":\"1\"},{\"policyName\":\"com.testing\",\"versionNo\":\"2\"}],\"loadedPolicies\":[],\"notificationType\":\"REMOVE\"}", StdPDPNotification.class));
+ assertEquals("{\"removedPolicies\":[],\"loadedPolicies\":[],\"notificationType\":null}", PolicyUtils.objectToJsonString(check));
+ // Remove on remove duplicate Notifications.
+ notification = new StdPDPNotification();
+ notification.setNotificationType(NotificationType.REMOVE);
+ removedPolicies = new ArrayList<>();
+ removedPolicy = new StdRemovedPolicy();
+ removedPolicy.setPolicyName("com.test.3.xml");
+ removedPolicy.setVersionNo("3");
+ removedPolicies.add(removedPolicy);
+ notification.setRemovedPolicies(removedPolicies);
+ NotificationStore.recordNotification(notification);
+ check = NotificationStore.getDeltaNotification(PolicyUtils.jsonStringToObject("{\"removedPolicies\":[{\"policyName\":\"com.test\",\"versionNo\":\"3\"},{\"policyName\":\"com.testing\",\"versionNo\":\"1\"},{\"policyName\":\"com.testing\",\"versionNo\":\"2\"}],\"loadedPolicies\":[],\"notificationType\":\"REMOVE\"}", StdPDPNotification.class));
+ assertEquals("{\"removedPolicies\":[],\"loadedPolicies\":[],\"notificationType\":null}", PolicyUtils.objectToJsonString(check));
+ // Update Notification
+ notification = new StdPDPNotification();
+ notification.setNotificationType(NotificationType.UPDATE);
+ loadedPolicies = new ArrayList<>();
+ loadedPolicy = new StdLoadedPolicy();
+ loadedPolicy.setPolicyName("com.test.3.xml");
+ loadedPolicy.setUpdateType(UpdateType.NEW);
+ loadedPolicy.setVersionNo("3");
+ matches = new HashMap<>();
+ matches.put("test", "test");
+ loadedPolicy.setMatches(matches);
+ loadedPolicies.add(loadedPolicy);
+ notification.setLoadedPolicies(loadedPolicies);
+ NotificationStore.recordNotification(notification);
+ check = NotificationStore.getDeltaNotification(PolicyUtils.jsonStringToObject("{\"removedPolicies\":[{\"policyName\":\"com.testing\",\"versionNo\":\"1\"},{\"policyName\":\"com.testing\",\"versionNo\":\"2\"}],\"loadedPolicies\":[{\"policyName\":\"com.test\",\"versionNo\":\"3\",\"matches\":{\"test\":\"test\"},\"updateType\":\"NEW\"}],\"notificationType\":\"BOTH\"}", StdPDPNotification.class));
+ assertEquals("{\"removedPolicies\":[],\"loadedPolicies\":[],\"notificationType\":null}", PolicyUtils.objectToJsonString(check));
+ // Update on update duplicate Notification
+ notification = new StdPDPNotification();
+ notification.setNotificationType(NotificationType.UPDATE);
+ loadedPolicies = new ArrayList<>();
+ loadedPolicy = new StdLoadedPolicy();
+ loadedPolicy.setPolicyName("com.test.3.xml");
+ loadedPolicy.setUpdateType(UpdateType.NEW);
+ loadedPolicy.setVersionNo("3");
+ matches = new HashMap<>();
+ matches.put("test", "test");
+ loadedPolicy.setMatches(matches);
+ loadedPolicies.add(loadedPolicy);
+ notification.setLoadedPolicies(loadedPolicies);
+ NotificationStore.recordNotification(notification);
+ check = NotificationStore.getDeltaNotification(PolicyUtils.jsonStringToObject("{\"removedPolicies\":[{\"policyName\":\"com.testing\",\"versionNo\":\"1\"},{\"policyName\":\"com.testing\",\"versionNo\":\"2\"}],\"loadedPolicies\":[{\"policyName\":\"com.test\",\"versionNo\":\"3\",\"matches\":{\"test\":\"test\"},\"updateType\":\"NEW\"}],\"notificationType\":\"BOTH\"}", StdPDPNotification.class));
+ assertEquals("{\"removedPolicies\":[],\"loadedPolicies\":[],\"notificationType\":null}", PolicyUtils.objectToJsonString(check));
+ //
+ // Notification Delta Tests
+ //