@Override public boolean hasNext() { return objects.hasNext(); }
@Override public boolean hasNext() { return source.hasNext(); }
@Override public boolean hasNext() { try { return nodes.hasNext(); } catch (RuntimeException e) { close(); throw e; } }
@Override public boolean hasNext() throws IOException { try { return iterator.hasNext(); } catch (RuntimeException e) { close(); throw e; } }
private T computeNext() { while (source.hasNext()) { T sourceNext = source.next(); if (filterFunction.apply(sourceNext)) { return sourceNext; } } return null; } };
private T computeNext() { while (source.hasNext()) { T sourceNext = source.next(); if (filterFunction.apply(sourceNext)) { return sourceNext; } } return null; } };
@Override public List<T> next() { if (!hasNext()) { throw new NoSuchElementException(); } List<T> list = new ArrayList<>(partitionSize); for (int i = 0; i < partitionSize && iterator.hasNext(); i++) { T next = iterator.next(); list.add(next); } return list; } };
@Override public T next() { if (first.hasNext()) { return first.next(); } return second.next(); }
@Override public T next() { if (first.hasNext()) { return first.next(); } return second.next(); }
@Test public void testFromIterator() { Iterator<String> original = Lists.newArrayList("item1", "item2").iterator(); try (AutoCloseableIterator<String> it = AutoCloseableIterator.fromIterator(original)) { assertTrue(it.hasNext()); assertEquals("item1", it.next()); assertEquals("item2", it.next()); assertFalse(it.hasNext()); } }
@Test public void testEmptyIterator() { try (AutoCloseableIterator<Object> it = AutoCloseableIterator.emptyIterator()) { assertFalse(it.hasNext()); assertEquals(null, it.next()); } }
@Test public void testNullTrees() { try (AutoCloseableIterator<DiffEntry> diffs = diffTree.setOldTree(ObjectId.NULL) .setNewTree(ObjectId.NULL).call()) { assertFalse(diffs.hasNext()); } }
@Test public void testNullTrees() { try (AutoCloseableIterator<DiffEntry> diffs = diffTree.setOldTree(ObjectId.NULL) .setNewTree(ObjectId.NULL).call()) { assertFalse(diffs.hasNext()); } }
@Test public void testEmptyRepo() throws Exception { try (AutoCloseableIterator<DiffEntry> difflist = diffOp .setOldVersion(ObjectId.NULL.toString()).call()) { assertNotNull(difflist); assertFalse(difflist.hasNext()); } }
@Test public void testEmptyRepo() throws Exception { try (AutoCloseableIterator<DiffEntry> difflist = diffOp .setOldVersion(ObjectId.NULL.toString()).call()) { assertNotNull(difflist); assertFalse(difflist.hasNext()); } }
@Test public void testNoChangeSameCommit() throws Exception { insertAndAdd(points1); final RevCommit commit = geogig.command(CommitOp.class).setAll(true).call(); assertFalse(diffOp.setOldVersion(commit.getId().toString()) .setNewVersion(commit.getId().toString()).call().hasNext()); }
@Test public void testFilterNamespaceNoChanges() throws Exception { // two commits on different trees insertAndAdd(points1); final RevCommit commit1 = geogig.command(CommitOp.class).setAll(true).call(); insertAndAdd(lines1); final RevCommit commit2 = geogig.command(CommitOp.class).setAll(true).call(); diffOp.setOldVersion(commit1.getId()).setNewVersion(commit2.getId()); diffOp.setFilter(pointsName); try (AutoCloseableIterator<DiffEntry> diffs = diffOp.call()) { assertFalse(diffs.hasNext()); } }
@Test public void testFilterTypeNameNoChanges() throws Exception { // two commits on different trees insertAndAdd(points1); final RevCommit commit1 = geogig.command(CommitOp.class).setAll(true).call(); insertAndAdd(lines1); final RevCommit commit2 = geogig.command(CommitOp.class).setAll(true).call(); diffOp.setOldVersion(commit1.getId()).setNewVersion(commit2.getId()); diffOp.setFilter(pointsName); try (AutoCloseableIterator<DiffEntry> diffs = diffOp.call()) { assertFalse(diffs.hasNext()); } }
@Test public void testFilterNamespaceNoChanges() throws Exception { // two commits on different trees insertAndAdd(points1); final RevCommit commit1 = geogig.command(CommitOp.class).setAll(true).call(); insertAndAdd(lines1); final RevCommit commit2 = geogig.command(CommitOp.class).setAll(true).call(); diffOp.setOldVersion(commit1.getId()).setNewVersion(commit2.getId()); diffOp.setFilter(pointsName); try (AutoCloseableIterator<DiffEntry> diffs = diffOp.call()) { assertFalse(diffs.hasNext()); } }