### Question:
WebSocketMessageSender { public void send(String message) { int attempts = 0; for (; attempts < maxSendAttempts; attempts++) { boolean sentSuccessfully = webSocketClientAdapter.sendMessage(message); if (sentSuccessfully) { return; } else { try { long millis = sendRetryIntervalMs * attempts; log.error("Failed sending message, will retry in {} ms", millis); Thread.sleep(millis); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } } log.error("Unable to send message (attempts={}): {}", attempts, message); } WebSocketMessageSender(OkHttpWebSocketClient webSocketClientAdapter, long sendRetryIntervalMs, int maxSendAttempts); void send(String message);  }### Answer:
@Test void shouldRetrySendingMessages() { given(webSocketClientAdapterMock.sendMessage(any())) .willReturn(false) .willReturn(false) .willReturn(true); mesageSender.send("hello"); verify(webSocketClientAdapterMock, times(3)).sendMessage(contains("hello")); }