### Question:
Consumer { public void consume() throws InterruptedException { var item = queue.take(); LOGGER.info("Consumer [{}] consume item [{}] produced by [{}]", name, item.getId(), item.getProducer()); } Consumer(String name, ItemQueue queue); void consume();  }### Answer:
@Test public void testConsume() throws Exception { final var queue = spy(new ItemQueue()); for (var id = 0; id < ITEM_COUNT; id++) { queue.put(new Item("producer", id)); } reset(queue); final var consumer = new Consumer("consumer", queue); for (var id = 0; id < ITEM_COUNT; id++) { consumer.consume(); } verify(queue, times(ITEM_COUNT)).take(); }