SpansAnd extends BLSpans { @Override public int advance(int doc) throws IOException { int docID0 = spans[0].docID(); currentDoc[0] = docID0 < doc ? spans[0].advance(doc) : docID0; currentStart[0] = -1; int docID1 = spans[1].docID(); currentDoc[1] = docID1 < doc ? spans[1].advance(doc) : docID1; currentStart[1] = -1; return synchronizeDoc(); } SpansAnd(BLSpans leftClause, BLSpans rightClause); @Override int docID(); @Override int startPosition(); @Override int endPosition(); @Override int nextDoc(); @Override int nextStartPosition(); @Override int advanceStartPosition(int target); @Override int advance(int doc); @Override String toString(); @Override void passHitQueryContextToClauses(HitQueryContext context); @Override void getCapturedGroups(Span[] capturedGroups); @Override int width(); @Override void collect(SpanCollector collector); @Override float positionsCost();  }
@Test public void testAndSpansAdvance() throws IOException { Spans exp = MockSpans.single(2, 10, 20); SpansAnd spans = getSpans(); Assert.assertEquals(2, spans.advance(2)); TestUtil.assertEquals(exp, spans, true); }
@Test public void testAndSpansAdvanceNoResults() throws IOException { MockSpans exp = MockSpans.emptySpans(); SpansAnd spans = getSpans(); Assert.assertEquals(DocIdSetIterator.NO_MORE_DOCS, spans.advance(3)); TestUtil.assertEquals(exp, spans, true); }
@Test public void testAndSpansAdvanceBeyond() throws IOException { MockSpans exp = MockSpans.emptySpans(); SpansAnd spans = getSpans(); Assert.assertEquals(DocIdSetIterator.NO_MORE_DOCS, spans.advance(1000)); TestUtil.assertEquals(exp, spans, true); }