### Question:
SelectFilter extends TokenFilter { public final boolean incrementToken() throws IOException { int skippedPositions = 0; while (input.incrementToken()) { if (includeWords.contains(termAtt.termBuffer(), 0, termAtt.termLength())) { if (posIncrAtt.getPositionIncrement() == 0 && firstToken) posIncrAtt.setPositionIncrement(1); if (enablePositionIncrements) { posIncrAtt.setPositionIncrement(posIncrAtt .getPositionIncrement() + skippedPositions); } firstToken = false; return true; } skippedPositions += posIncrAtt.getPositionIncrement(); } return false; } SelectFilter(boolean enablePositionIncrements, TokenStream input,
			Set<?> includeWords, boolean ignoreCase); final boolean incrementToken();  }### Answer:
@Test public void testWithEnablePositionIncrement() throws IOException { inputTokenStream.reset(); SelectFilter selectFilter = new SelectFilter(true, inputTokenStream, selectedWords, true); TermAttribute tAtt = (TermAttribute) selectFilter .addAttribute(TermAttribute.class); PositionIncrementAttribute posAtt = (PositionIncrementAttribute) selectFilter .addAttribute(PositionIncrementAttribute.class); selectFilter.incrementToken(); assertEquals("Selected Token 1", "positive3", tAtt.term()); assertEquals("Position increment one token skipped", 2, posAtt.getPositionIncrement()); selectFilter.incrementToken(); assertEquals("Selected Token 2", "positive1", tAtt.term()); assertEquals("Position increment next contigous token", 1, posAtt.getPositionIncrement()); selectFilter.incrementToken(); assertEquals("Selected Token 3", "positive2", tAtt.term()); assertEquals("Position increment one token skipped", 2, posAtt.getPositionIncrement()); }
@Test public void testWithoutEnablePositionIncrement() throws IOException { inputTokenStream.reset(); SelectFilter selectFilter = new SelectFilter(false, inputTokenStream, selectedWords, true); TermAttribute tAtt = (TermAttribute) selectFilter .addAttribute(TermAttribute.class); PositionIncrementAttribute posAtt = (PositionIncrementAttribute) selectFilter .addAttribute(PositionIncrementAttribute.class); selectFilter.incrementToken(); assertEquals("Selected Token 1", "positive3", tAtt.term()); assertEquals("Position increment without skipping", 1, posAtt.getPositionIncrement()); selectFilter.incrementToken(); assertEquals("Selected Token 2", "positive1", tAtt.term()); assertEquals("Position increment without skipping", 1, posAtt.getPositionIncrement()); selectFilter.incrementToken(); assertEquals("Selected Token 3", "positive2", tAtt.term()); assertEquals("Position increment without skipping", 1, posAtt.getPositionIncrement()); }