}).given(channel).basicAck(anyLong(), anyBoolean()); final CountDownLatch latch4 = new CountDownLatch(1); willAnswer(i -> { verify(channel).basicAck(10L, true); verify(channel).basicAck(16L, true); assertTrue(latch3.await(10, TimeUnit.SECONDS)); verify(channel).basicAck(17L, true); consumer.get().handleDelivery("consumerTag", envelope(18), props, body); consumer.get().handleDelivery("consumerTag", envelope(19), props, body); assertTrue(latch4.await(10, TimeUnit.SECONDS)); verify(channel).basicAck(18L, true); verify(channel).basicNack(19L, true, true); consumer.get().handleDelivery("consumerTag", envelope(20), props, body); assertTrue(latch5.await(10, TimeUnit.SECONDS)); verify(channel).basicAck(20L, true);