### Question:
CapacityQueue extends AbstractQueue<E> { @Override public boolean offer(E e) { if (mDropPolicy == DROP_POLICY_TAIL) { return mDeque.size() < mMaxCapacity && mDeque.offerLast(e); } if (mDeque.size() >= mMaxCapacity) { Log.d(TAG, "Dropping from head"); mDeque.removeFirst(); } return mDeque.offerLast(e); } CapacityQueue(int maxCapacity, @DropPolicy int dropPolicy); @Override int size(); @Override boolean offer(E e); @Override E poll(); @Override E peek(); @Override @NonNull Iterator<E> iterator();  }### Answer:
@Test public void testOfferOne() { CapacityQueue<Integer> queue = new CapacityQueue<>(DEFAULT_CAPACITY, DEFAULT_DROP_POLICY); assertThat(queue.offer(0)).isTrue(); }
@Test public void testOfferToCapacityHeadDrop() { CapacityQueue<Integer> queue = new CapacityQueue<>( DEFAULT_CAPACITY, CapacityQueue.DROP_POLICY_HEAD); for (int i = 0; i < DEFAULT_CAPACITY; i++) { assertThat(queue.offer(i)).isTrue(); } }
@Test public void testOfferTailDropToCapacity() { CapacityQueue<Integer> queue = new CapacityQueue<>( DEFAULT_CAPACITY, CapacityQueue.DROP_POLICY_TAIL); for (int i = 0; i < DEFAULT_CAPACITY; i++) { assertThat(queue.offer(i)).isTrue(); } }
@Test public void testOfferTailDropAtCapacity() { CapacityQueue<Integer> queue = new CapacityQueue<>( DEFAULT_CAPACITY, CapacityQueue.DROP_POLICY_TAIL); for (int i = 0; i < DEFAULT_CAPACITY; i++) { queue.offer(i); } assertThat(queue.offer(10)).isFalse(); }