ApiAware { public String getWebSocketUrl(String endpoint) { try { URL url = new URL(baseUrl); return url.getPort() != -1 ? String.format("ws: String.format("ws: } catch (MalformedURLException e) { throw new RuntimeException(e); } } private  ApiAware(String baseUrl); static ApiAware withUrl(String url); S get(Class<S> serviceClass); String getWebSocketUrl(String endpoint);  }
@Test public void testGetWebSocketUrl() { assertThat( ApiAware.withUrl("http: equalTo("ws: ); assertThat( ApiAware.withUrl("http: equalTo("ws: ); assertThat( ApiAware.withUrl("http: equalTo("ws: ); }