### Question:
NetworkService { public SocketClient getConnectionWithRetries(String ip, int port, int retries, long retrySleep) throws Exception { SocketClient client = new SocketClient(); RetryOnException retryHandler = new RetryOnException(retries, retrySleep); while (true) { try { client.startConnection(ip, port); } catch (Exception ex) { log.error("error", ex); retryHandler.exceptionOccurred(); } } }  SocketClient startConnection(String ip, int port); SocketClient getConnectionWithRetry(String ip, int port); SocketClient getConnectionWithRetries(String ip, int port, int retries, long retrySleep);  }### Answer:
@Test public void getConnectionWithRetries() throws Exception { NetworkService networkService = new NetworkService(); assertThatThrownBy(() -> networkService.getConnectionWithRetries("localhost", 123, 3, 3000)) .hasMessageContaining("Retry limit exceeded"); }