### Question:
ObservableBuffer extends ObservableListBase<E> implements Queue<E> { @Override public boolean offer(final E element) { boolean changed = false; synchronized (myQueue) { beginChange(); while (remainingCapacity() < 1) { final E removedElement = myQueue.removeFirst(); if (removedElement != null) { nextRemove(0, removedElement); } } changed = myQueue.offer(element); if (changed) { nextAdd(myQueue.size() - 1, myQueue.size()); } endChange(); } return changed; } ObservableBuffer(final int capacity); @Override boolean offer(final E element); @Override boolean add(final E e); @Override E remove(); @Override E poll(); @Override E element(); @Override E peek(); @Override E get(final int index); @Override int size(); @Override void clear();  }### Answer:
@Test public void testOfferUnderCapacity() { myObservableBuffer.offer("one"); myObservableBuffer.offer("two"); myObservableBuffer.offer("three"); myObservableBuffer.offer("four"); Object[] array = myObservableBuffer.toArray(); assertEquals(4, array.length); assertEquals("one", array[0]); assertEquals("two", array[1]); assertEquals("three", array[2]); assertEquals("four", array[3]); }
@Test public void testOfferOverCapacity() { myObservableBuffer.offer("one"); myObservableBuffer.offer("two"); myObservableBuffer.offer("three"); myObservableBuffer.offer("four"); myObservableBuffer.offer("five"); myObservableBuffer.offer("six"); myObservableBuffer.offer("seven"); Object[] array = myObservableBuffer.toArray(); assertEquals(5, array.length); assertEquals("three", array[0]); assertEquals("four", array[1]); assertEquals("five", array[2]); assertEquals("six", array[3]); assertEquals("seven", array[4]); }