SamplingLongPrimitiveIterator extends AbstractLongPrimitiveIterator { @Override public boolean hasNext() { return hasNext; } SamplingLongPrimitiveIterator(LongPrimitiveIterator delegate, double samplingRate); @Override boolean hasNext(); @Override long nextLong(); @Override long peek(); @Override void remove(); @Override void skip(int n); static LongPrimitiveIterator maybeWrapIterator(LongPrimitiveIterator delegate, double samplingRate);  }
@Test public void testEmpty() { LongPrimitiveArrayIterator it = new LongPrimitiveArrayIterator(new long[0]); LongPrimitiveIterator sample = new SamplingLongPrimitiveIterator(it, 0.5); assertFalse(sample.hasNext()); try { sample.next(); fail("Should have thrown exception"); } catch (NoSuchElementException nsee) { } }
@Test(expected = NoSuchElementException.class) public void testEmpty() { LongPrimitiveArrayIterator it = new LongPrimitiveArrayIterator(new long[0]); LongPrimitiveIterator sample = new SamplingLongPrimitiveIterator(it, 0.5); assertFalse(sample.hasNext()); sample.next(); }