CursorResolver implements ConflictResolver<CursorObject> { @Nullable @Override public CursorObject resolve(final List<CursorObject> siblings) throws UnresolvedConflictException { LOGGER.debug("Found {} siblings", siblings.size()); siblingCounts.update(siblings.size()); if (siblings.size() > 1) { Collections.sort(siblings); return siblings.get(0); } else if (siblings.size() == 1) { return siblings.get(0); } else { return null; } } CursorResolver(); @Nullable @Override CursorObject resolve(final List<CursorObject> siblings);  }
@Test public void testNoSiblings() throws Exception { final List<CursorObject> siblings = Collections.emptyList(); final CursorObject actual = resolver.resolve(siblings); assertThat(actual).isNull(); }
@Test public void testSingleSibling() throws Exception { final CursorObject list = new CursorObject("test", "1"); final List<CursorObject> siblings = Collections.singletonList(list); final CursorObject actual = resolver.resolve(siblings); assertThat(actual).isEqualTo(list); }
@Test @SuppressWarnings("NullAway") public void testMultipleSibling() throws Exception { final CursorObject cursor1 = new CursorObject("test", "1"); final CursorObject cursor2 = new CursorObject("test", "2"); final CursorObject cursor3 = new CursorObject("test", "3"); final CursorObject cursor4 = new CursorObject("test", "4"); final CursorObject cursor5 = new CursorObject("test", "5"); final CursorObject cursor6 = new CursorObject("test", "6"); final List<CursorObject> siblings = Arrays.asList(cursor1, cursor2, cursor3, cursor4, cursor5, cursor6); final CursorObject actual = resolver.resolve(siblings); assertThat(actual).isEqualTo(cursor6); assertThat(actual.getValue()).isEqualTo("6"); }