### Question:
RingBuffer extends ArrayDeque<T> { @Override public boolean add(T item) { boolean result = super.add(item); resize(); return result; } RingBuffer(@IntRange(from = 0) int maxSize); @Override boolean add(T item); @Override void addFirst(T item); @Override void addLast(T item); @Override boolean addAll(Collection<? extends T> collection); @Override void push(T item);  }### Answer:
@Test public void testLifoOrder() { RingBuffer<Integer> buffer = new RingBuffer<>(1); buffer.add(1); buffer.add(2); assertEquals(1, buffer.size()); assertEquals(2, buffer.pop(), DELTA); }
@Test public void testFifo() throws Exception { RingBuffer<Integer> buffer = new RingBuffer<>(2); buffer.add(1); buffer.add(2); assertEquals(2, buffer.size()); assertEquals(1, buffer.pop(), DELTA); }
@Test public void testPeek() { RingBuffer<Integer> buffer = new RingBuffer<>(2); buffer.add(1); buffer.add(2); buffer.add(3); assertEquals(2, buffer.size()); assertEquals(2, buffer.peekFirst(), DELTA); assertEquals(3, buffer.peekLast(), DELTA); }