@Test @SuppressWarnings("NullAway") public void testSingleSiblingWithDelete() throws Exception { final NotificationListObject list = new NotificationListObject("test"); list.addNotification(Notification.create("1")); list.deleteNotification("1"); final List<NotificationListObject> siblings = Collections.singletonList(list); final NotificationListObject actual = resolver.resolve(siblings); assertThat(actual.getDeletedIds()).isEmpty(); assertThat(actual.getNotifications()).isEmpty(); }
@Override @Nullable public NotificationListObject resolve(final List<NotificationListObject> siblings) throws UnresolvedConflictException { LOGGER.debug("Found {} siblings", siblings.size()); siblingCounts.update(siblings.size()); if (siblings.size() > 1) { final Iterator<NotificationListObject> iterator = siblings.iterator(); final NotificationListObject resolved = iterator.next(); final Set<String> deletedIds = resolved.getDeletedIds(); while (iterator.hasNext()) { final NotificationListObject sibling = iterator.next(); resolved.addNotifications(sibling.getNotifications()); deletedIds.addAll(sibling.getDeletedIds()); } if (!deletedIds.isEmpty()) { LOGGER.debug("IDs to delete: {}", deletedIds); removeNotifications(resolved.getNotifications(), deletedIds); } return resolved; } else if (siblings.size() == 1) { final NotificationListObject resolved = siblings.get(0); if (!resolved.getDeletedIds().isEmpty()) { LOGGER.debug("IDs to delete: {}", resolved.getDeletedIds()); removeNotifications(resolved.getNotifications(), resolved.getDeletedIds()); } return resolved; } else { return null; } }
NotificationListResolver implements ConflictResolver<NotificationListObject> { @Override @Nullable public NotificationListObject resolve(final List<NotificationListObject> siblings) throws UnresolvedConflictException { LOGGER.debug("Found {} siblings", siblings.size()); siblingCounts.update(siblings.size()); if (siblings.size() > 1) { final Iterator<NotificationListObject> iterator = siblings.iterator(); final NotificationListObject resolved = iterator.next(); final Set<String> deletedIds = resolved.getDeletedIds(); while (iterator.hasNext()) { final NotificationListObject sibling = iterator.next(); resolved.addNotifications(sibling.getNotifications()); deletedIds.addAll(sibling.getDeletedIds()); } if (!deletedIds.isEmpty()) { LOGGER.debug("IDs to delete: {}", deletedIds); removeNotifications(resolved.getNotifications(), deletedIds); } return resolved; } else if (siblings.size() == 1) { final NotificationListObject resolved = siblings.get(0); if (!resolved.getDeletedIds().isEmpty()) { LOGGER.debug("IDs to delete: {}", resolved.getDeletedIds()); removeNotifications(resolved.getNotifications(), resolved.getDeletedIds()); } return resolved; } else { return null; } } }
NotificationListResolver implements ConflictResolver<NotificationListObject> { @Override @Nullable public NotificationListObject resolve(final List<NotificationListObject> siblings) throws UnresolvedConflictException { LOGGER.debug("Found {} siblings", siblings.size()); siblingCounts.update(siblings.size()); if (siblings.size() > 1) { final Iterator<NotificationListObject> iterator = siblings.iterator(); final NotificationListObject resolved = iterator.next(); final Set<String> deletedIds = resolved.getDeletedIds(); while (iterator.hasNext()) { final NotificationListObject sibling = iterator.next(); resolved.addNotifications(sibling.getNotifications()); deletedIds.addAll(sibling.getDeletedIds()); } if (!deletedIds.isEmpty()) { LOGGER.debug("IDs to delete: {}", deletedIds); removeNotifications(resolved.getNotifications(), deletedIds); } return resolved; } else if (siblings.size() == 1) { final NotificationListObject resolved = siblings.get(0); if (!resolved.getDeletedIds().isEmpty()) { LOGGER.debug("IDs to delete: {}", resolved.getDeletedIds()); removeNotifications(resolved.getNotifications(), resolved.getDeletedIds()); } return resolved; } else { return null; } } NotificationListResolver(); }
NotificationListResolver implements ConflictResolver<NotificationListObject> { @Override @Nullable public NotificationListObject resolve(final List<NotificationListObject> siblings) throws UnresolvedConflictException { LOGGER.debug("Found {} siblings", siblings.size()); siblingCounts.update(siblings.size()); if (siblings.size() > 1) { final Iterator<NotificationListObject> iterator = siblings.iterator(); final NotificationListObject resolved = iterator.next(); final Set<String> deletedIds = resolved.getDeletedIds(); while (iterator.hasNext()) { final NotificationListObject sibling = iterator.next(); resolved.addNotifications(sibling.getNotifications()); deletedIds.addAll(sibling.getDeletedIds()); } if (!deletedIds.isEmpty()) { LOGGER.debug("IDs to delete: {}", deletedIds); removeNotifications(resolved.getNotifications(), deletedIds); } return resolved; } else if (siblings.size() == 1) { final NotificationListObject resolved = siblings.get(0); if (!resolved.getDeletedIds().isEmpty()) { LOGGER.debug("IDs to delete: {}", resolved.getDeletedIds()); removeNotifications(resolved.getNotifications(), resolved.getDeletedIds()); } return resolved; } else { return null; } } NotificationListResolver(); @Override @Nullable NotificationListObject resolve(final List<NotificationListObject> siblings); static void removeNotifications(
      final Collection<Notification> notifications, final Collection<String> ids); }
NotificationListResolver implements ConflictResolver<NotificationListObject> { @Override @Nullable public NotificationListObject resolve(final List<NotificationListObject> siblings) throws UnresolvedConflictException { LOGGER.debug("Found {} siblings", siblings.size()); siblingCounts.update(siblings.size()); if (siblings.size() > 1) { final Iterator<NotificationListObject> iterator = siblings.iterator(); final NotificationListObject resolved = iterator.next(); final Set<String> deletedIds = resolved.getDeletedIds(); while (iterator.hasNext()) { final NotificationListObject sibling = iterator.next(); resolved.addNotifications(sibling.getNotifications()); deletedIds.addAll(sibling.getDeletedIds()); } if (!deletedIds.isEmpty()) { LOGGER.debug("IDs to delete: {}", deletedIds); removeNotifications(resolved.getNotifications(), deletedIds); } return resolved; } else if (siblings.size() == 1) { final NotificationListObject resolved = siblings.get(0); if (!resolved.getDeletedIds().isEmpty()) { LOGGER.debug("IDs to delete: {}", resolved.getDeletedIds()); removeNotifications(resolved.getNotifications(), resolved.getDeletedIds()); } return resolved; } else { return null; } } NotificationListResolver(); @Override @Nullable NotificationListObject resolve(final List<NotificationListObject> siblings); static void removeNotifications(
      final Collection<Notification> notifications, final Collection<String> ids);  }