NotificationListResolver implements ConflictResolver<NotificationListObject> { public static void removeNotifications( final Collection<Notification> notifications, final Collection<String> ids) { notifications.removeIf( notification -> { if (!notification.getId().isPresent()) { return true; } return ids.contains(notification.getId().get()); }); ids.clear(); } NotificationListResolver(); @Override @Nullable NotificationListObject resolve(final List<NotificationListObject> siblings); static void removeNotifications(
      final Collection<Notification> notifications, final Collection<String> ids);  }
@Test public void testRemoveNotifications() throws Exception { final List<Notification> notifications = Lists.newArrayList( Notification.create("1"), Notification.create("2"), Notification.create("3"), Notification.builder().build()); final List<Notification> expected = Arrays.asList(Notification.create("2"), Notification.create("3")); NotificationListResolver.removeNotifications(notifications, Lists.newArrayList("1")); assertThat(notifications).containsExactlyElementsOf(expected); }
@Test public void testRemoveNotificationsEmpty() throws Exception { final List<Notification> notifications = Lists.newArrayList( Notification.create("1"), Notification.create("2"), Notification.create("3"), Notification.builder().build()); final List<Notification> expected = Arrays.asList(Notification.create("1"), Notification.create("2"), Notification.create("3")); NotificationListResolver.removeNotifications(notifications, Lists.newArrayList()); assertThat(notifications).containsExactlyElementsOf(expected); }