BufferedSender implements Sender { @Override public List<SenderListener> getListeners() { return sender.getListeners(); } BufferedSender(Builder builder);   BufferedSender(Builder builder, ScheduledExecutorService executorService); Queue<Payload> queue(); Sender sender(); @Override void send(Payload payload); @Override void addListener(SenderListener listener); @Override List<SenderListener> getListeners(); @Override void close(); @Override void close(boolean wait);  }
@Test public void shouldDelegateGetListeners() { sut.getListeners(); verify(sender).getListeners(); }
@Test public void sendTaskShouldNotThrowErrorIfQueueFails() { Exception errorQueue = new RuntimeException("Error in queue"); when(queue.poll()).thenThrow(errorQueue); when(sender.getListeners()).thenReturn(asList(listener)); SendTask sut = new SendTask(1, queue, sender); sut.run(); ArgumentCaptor<SenderException> argument = ArgumentCaptor.forClass(SenderException.class); verify(listener).onError(any(), argument.capture()); assertThat(argument.getValue(), is(instanceOf(SenderException.class))); assertThat(argument.getValue().getCause(), is(errorQueue)); }