@Test public void testProduce() throws Exception { assertTimeout(ofMillis(6000), () -> { final ItemQueue queue = mock(ItemQueue.class); final Producer producer = new Producer("producer", queue); producer.produce(); verify(queue).put(any(Item.class)); verifyNoMoreInteractions(queue); }); }
public void produce() throws InterruptedException { Item item = new Item(name, itemId++); queue.put(item); Random random = new Random(); Thread.sleep(random.nextInt(2000)); }
Producer { public void produce() throws InterruptedException { Item item = new Item(name, itemId++); queue.put(item); Random random = new Random(); Thread.sleep(random.nextInt(2000)); } }
Producer { public void produce() throws InterruptedException { Item item = new Item(name, itemId++); queue.put(item); Random random = new Random(); Thread.sleep(random.nextInt(2000)); } Producer(String name, ItemQueue queue); }
Producer { public void produce() throws InterruptedException { Item item = new Item(name, itemId++); queue.put(item); Random random = new Random(); Thread.sleep(random.nextInt(2000)); } Producer(String name, ItemQueue queue); void produce(); }
Producer { public void produce() throws InterruptedException { Item item = new Item(name, itemId++); queue.put(item); Random random = new Random(); Thread.sleep(random.nextInt(2000)); } Producer(String name, ItemQueue queue); void produce();  }