### Question:
RingBuffer extends AbstractQueue<T> { @Override public T poll() { if (size == 0) { return null; } T item = items[head]; items[head] = null; size--; head = (head + 1) % items.length; return item; } @SuppressWarnings("unchecked")  RingBuffer(int capacity); @Override Iterator<T> iterator(); @Override boolean offer(T value); @Override T peek(); @Override T poll(); @Override int size(); @Override String toString();  }### Answer:
@Test public void testPoll() { RingBuffer<String> test = new RingBuffer<String>(1000); for (int i = 0; i < 1000; i++) { test.add(String.format("Add: %s", i)); } for (int i = 0; i < 1000; i++) { assertEquals("Invalid size", 1000 - i, test.size()); assertEquals(String.format("Add: %s", i), test.poll()); } assertNull(test.poll()); }
@Test public void testPollOrder() { RingBuffer<String> test = new RingBuffer<String>(1000); for (int i = 0; i < 1000; i++) { test.add(String.format("Offer: %s", i)); } for (int i = 0; i < 1000; i++) { String element = test.poll(); assertEquals(String.format("Offer: %s", i), element); } }