### Question:
SpillingResettableIterator implements ResettableIterator<T> { @Override public boolean hasNext() { if (this.next == null) { if (this.inView != null) { if (this.currentElementNum < this.elementCount) { try { this.instance = this.serializer.deserialize(this.instance, this.inView); } catch (IOException e) { throw new RuntimeException("SpillingIterator: Error reading element from buffer.", e); } this.next = this.instance; this.currentElementNum++; return true; } else { return false; } } else { if (this.input.hasNext()) { this.next = this.input.next(); try { this.serializer.serialize(this.next, this.buffer); } catch (IOException e) { throw new RuntimeException("SpillingIterator: Error writing element to buffer.", e); } this.elementCount++; return true; } else { return false; } } } else { return true; } } SpillingResettableIterator(Iterator<T> input, TypeSerializer<T> serializer, 
			MemoryManager memoryManager, IOManager ioManager,
			int numPages, AbstractInvokable parentTask);  SpillingResettableIterator(Iterator<T> input, TypeSerializer<T> serializer,
			MemoryManager memoryManager, IOManager ioManager, List<MemorySegment> memory); private  SpillingResettableIterator(Iterator<T> input, TypeSerializer<T> serializer,
			MemoryManager memoryManager, IOManager ioManager,
			List<MemorySegment> memory, boolean releaseMemOnClose); void open(); void reset(); @Override boolean hasNext(); @Override T next(); @Override void remove(); List<MemorySegment> close();  }### Answer:
@Test public void testHasNext() { try { SpillingResettableIterator<IntValue> iterator = new SpillingResettableIterator<IntValue>( this.reader, this.serializer, this.memman, this.ioman, 2, this.memOwner); iterator.open(); int cnt = 0; while (iterator.hasNext()) { iterator.hasNext(); iterator.next(); cnt++; } Assert.assertTrue(cnt + " elements read from iterator, but " + NUM_TESTRECORDS + " expected", cnt == NUM_TESTRECORDS); iterator.close(); } catch (Exception ex) { ex.printStackTrace(); Assert.fail("Test encountered an exception."); } }