### Question:
RopeVariantStream implements VariantStream<T> { @Override public T index(long characterPosition) { if (root == null) { throw new IllegalStateException("Stream is empty"); } return RopeUtils.index(characterPosition, root, 0).node.value; } RopeVariantStream(String documentHash);  RopeVariantStream(String documentHash, Node<T> root); @Override void copy(long characterPosition, VariantSpan variantSpan); @Override void delete(VariantSpan variantSpan); @Override String getDocumentHash(); @Override List<T> getStreamElements(); @Override List<T> getStreamElements(VariantSpan variantSpan); @Override List<VariantSpan> getVariantSpans(InvariantSpan targetSpan); @Override T index(long characterPosition); @Override void move(long to, VariantSpan v1); @Override void put(long characterPosition, T val); @Override void rebalance(); void save(OutputStream os); @Override void swap(VariantSpan v1, VariantSpan v2); @Override void toggleOverlay(VariantSpan variantSpan, Overlay linkType);  }### Answer:
@Test public void index() throws Exception { VariantStream<InvariantSpan> stream = new RopeVariantStream<>(documentHash, getA()); InvariantSpan span = stream.index(12); assertEquals(new InvariantSpan(300, 4, documentHash), span); }
@Test public void index11() throws Exception { VariantStream<InvariantSpan> stream = new RopeVariantStream<>(documentHash, getA()); InvariantSpan span = stream.index(11); assertEquals(new InvariantSpan(250, 2, documentHash), span); span = stream.index(10); assertEquals(new InvariantSpan(250, 2, documentHash), span); }
@Test(expected = IndexOutOfBoundsException.class) public void indexNull() throws Exception { VariantStream<InvariantSpan> stream = new RopeVariantStream<>(documentHash, getA()); InvariantSpan span = stream.index(100); assertNull(span); }