### Question:
ObservableBuffer extends ObservableListBase<E> implements Queue<E> { @Override public boolean add(final E e) { if (remainingCapacity() == 0) { throw new IllegalStateException("Queue full"); } boolean changed = false; synchronized (myQueue) { beginChange(); try { if (myQueue.add(e)) { changed = true; nextAdd(myQueue.size() - 1, myQueue.size()); } } finally { 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 testAddOne() { myObservableBuffer.add("one"); Object[] array = myObservableBuffer.toArray(); assertEquals(1, array.length); assertEquals("one", array[0]); }
@Test public void testAddUnderCapacity() { myObservableBuffer.add("one"); myObservableBuffer.add("two"); myObservableBuffer.add("three"); myObservableBuffer.add("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(expected = IllegalStateException.class) public void testAddOverCapacity() { myObservableBuffer.add("one"); myObservableBuffer.add("two"); myObservableBuffer.add("three"); myObservableBuffer.add("four"); myObservableBuffer.add("five"); myObservableBuffer.add("six"); myObservableBuffer.add("seven"); }