@Test
@SuppressWarnings("unchecked")
public void worker_correctly_gets_and_sends_message() throws Exception {

  try (Sender sender = new Sender(onrampClient, contextManager, 1L, service)) {
    sender.start();
    verify(service).scheduleAtFixedRate(runnableCaptor.capture(), anyLong(), anyLong(), any());
    TestMessageContext context = mock(TestMessageContext.class);
    TestMessage message = mock(TestMessage.class);
    CompletableFuture<StandardResponse> future = mock(CompletableFuture.class);
    when(context.getMessage()).thenReturn(message);
    when(contextManager.nextContext()).thenReturn(context);
    when(onrampClient.sendMessage(eq(message))).thenReturn(future);
    runnableCaptor.getValue().run();
    verify(contextManager).nextContext();
    verify(onrampClient).sendMessage(message);
    verify(context).messageSent(future);
  }
}