@Override
    public T remove() {
        T item = poll();
        if (item == null) {
            throw new NoSuchElementException();
        }

        return item;
    }
@Test
    public void removeTest() {
        BlockingQueue<Integer> queue = new GrowableArrayBlockingQueue<>(4);

        assertNull(queue.poll());

        assertTrue(queue.offer(1));
        assertTrue(queue.offer(2));
        assertTrue(queue.offer(3));

        assertEquals(queue.size(), 3);

        assertFalse(queue.remove(4));
        assertEquals(queue.size(), 3);
        assertEquals(queue.toString(), "[1, 2, 3]");

        assertTrue(queue.remove(2));
        assertEquals(queue.size(), 2);
        assertEquals(queue.toString(), "[1, 3]");

        assertTrue(queue.remove(3));
        assertEquals(queue.size(), 1);
        assertEquals(queue.toString(), "[1]");

        assertTrue(queue.remove(1));
        assertEquals(queue.size(), 0);
        assertEquals(queue.toString(), "[]");

        // Test queue rollover
        queue.offer(1);
        queue.offer(2);
        queue.offer(3);

        assertEquals(queue.poll().intValue(), 1);
        assertEquals(queue.poll().intValue(), 2);

        assertTrue(queue.offer(4));
        assertTrue(queue.offer(5));

        assertTrue(queue.remove(5));
        assertEquals(queue.size(), 2);
        assertEquals(queue.toString(), "[3, 4]");

        queue.offer(6);
        queue.offer(7);
        assertTrue(queue.remove(6));
        assertEquals(queue.size(), 3);
        assertEquals(queue.toString(), "[3, 4, 7]");

        queue.offer(8);
        assertTrue(queue.remove(8));
        assertEquals(queue.size(), 3);
        assertEquals(queue.toString(), "[3, 4, 7]");

        queue.offer(8);
        assertEquals(queue.toString(), "[3, 4, 7, 8]");

        assertTrue(queue.remove(4));
        assertEquals(queue.size(), 3);
        assertEquals(queue.toString(), "[3, 7, 8]");

        assertTrue(queue.remove(8));
        assertEquals(queue.size(), 2);
        assertEquals(queue.toString(), "[3, 7]");

        assertTrue(queue.remove(7));
        assertEquals(queue.size(), 1);
        assertEquals(queue.toString(), "[3]");
    }