### Question:
RopeVariantStream implements VariantStream<T> { @Override public void put(long characterPosition, T val) throws MalformedSpanException { if (val == null) { throw new IllegalArgumentException("invariant span is null"); } if (characterPosition < 1) { throw new IndexOutOfBoundsException("put position must be greater than 0"); } if (val.getWidth() < 1) { throw new MalformedSpanException("invariant span must have a width greater than 0"); } insert(characterPosition, new Node<T>(val)); } 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 put() throws Exception { VariantStream<InvariantSpan> stream = new RopeVariantStream<>(documentHash, getA()); stream.put(12, new InvariantSpan(500, 34, documentHash)); List<InvariantSpan> spans = stream.getStreamElements(); assertEquals(new InvariantSpan(100, 6, documentHash), spans.get(0)); assertEquals(new InvariantSpan(200, 3, documentHash), spans.get(1)); assertEquals(new InvariantSpan(250, 2, documentHash), spans.get(2)); assertEquals(new InvariantSpan(500, 34, documentHash), spans.get(3)); assertEquals(new InvariantSpan(300, 4, documentHash), spans.get(4)); assertEquals(new InvariantSpan(350, 1, documentHash), spans.get(5)); assertEquals(new InvariantSpan(360, 6, documentHash), spans.get(6)); }