@Test
public void testIterableSomeNoiseTermVectors() throws IOException {

  //get noise vectors
  RAMDirectory directory = createTestIndex(TYPE_TERM_VECTORS, new RAMDirectory(), 0);
  //get real vectors
  createTestIndex(TYPE_NO_TERM_VECTORS, directory, 5);
  IndexReader reader = DirectoryReader.open(directory);
  Weight weight = new TFIDF();
  TermInfo termInfo = new CachedTermInfo(reader, "content", 1, 100);
  
  boolean exceptionThrown;
  //0 percent tolerance
  LuceneIterable iterable = new LuceneIterable(reader, "id", "content", termInfo, weight);
  try {
    Iterables.skip(iterable, Iterables.size(iterable));
    exceptionThrown = false;
  }
  catch(IllegalStateException ise) {
      exceptionThrown = true;
  }
  assertTrue(exceptionThrown);
  
  //100 percent tolerance
  iterable = new LuceneIterable(reader, "id", "content", termInfo,weight, -1, 1.0);
  try {
    Iterables.skip(iterable, Iterables.size(iterable));
    exceptionThrown = false;
  }
  catch(IllegalStateException ise) {
      exceptionThrown = true;
  }
  assertFalse(exceptionThrown);
  
  //50 percent tolerance
  iterable = new LuceneIterable(reader, "id", "content", termInfo,weight, -1, 0.5);
  Iterator<Vector> iterator = iterable.iterator();
  Iterators.advance(iterator, 5);
  try {
    Iterators.advance(iterator, Iterators.size(iterator));
    exceptionThrown = false;
  }
  catch(IllegalStateException ise) {
    exceptionThrown = true;
  }
  assertTrue(exceptionThrown);
}