use of org.apache.lucene.analysis.tokenattributes.BytesTermAttribute in project lucene-solr by apache.
the class TestGraphTokenStreamFiniteStrings method assertTokenStream.
private void assertTokenStream(TokenStream ts, String[] terms, int[] increments) throws Exception {
// verify no nulls and arrays same length
assertNotNull(ts);
assertNotNull(terms);
assertNotNull(increments);
assertEquals(terms.length, increments.length);
BytesTermAttribute termAtt = ts.getAttribute(BytesTermAttribute.class);
PositionIncrementAttribute incrAtt = ts.getAttribute(PositionIncrementAttribute.class);
int offset = 0;
while (ts.incrementToken()) {
// verify term and increment
assert offset < terms.length;
assertEquals(terms[offset], termAtt.getBytesRef().utf8ToString());
assertEquals(increments[offset], incrAtt.getPositionIncrement());
offset++;
}
// make sure we processed all items
assertEquals(offset, terms.length);
}
Aggregations