@Test public void appendVersionTest() { RtmClientBuilder builder = new RtmClientBuilder("foo", "bar"); assertThat( builder.createUri("ws: equalTo("ws: ); assertThat( builder.createUri("ws: equalTo("ws: ); assertThat( builder.createUri("ws: equalTo("ws: ); }
URI createUri(String endpoint, String appKey) { if (Strings.isNullOrEmpty(endpoint)) { throw new IllegalArgumentException(); } Pattern verPattern = Pattern.compile("/(v\\d+)$"); Matcher m = verPattern.matcher(endpoint); String fullEndpoint = endpoint; if (!m.find()) { if (!fullEndpoint.endsWith("/")) { fullEndpoint += "/"; } fullEndpoint += RTM_VER; } else { String ver = m.group(1); LOG.warn("Specifying a version as a part of the endpoint is deprecated. " + "Please remove the {} from {}", ver, endpoint); } String uri = String.format("%s?appkey=%s", fullEndpoint, appKey); try { return new URI(uri); } catch (URISyntaxException e) { LOG.error("Unable to parse URI {}", uri, e); throw new RuntimeException(e); } }
RtmClientBuilder { URI createUri(String endpoint, String appKey) { if (Strings.isNullOrEmpty(endpoint)) { throw new IllegalArgumentException(); } Pattern verPattern = Pattern.compile("/(v\\d+)$"); Matcher m = verPattern.matcher(endpoint); String fullEndpoint = endpoint; if (!m.find()) { if (!fullEndpoint.endsWith("/")) { fullEndpoint += "/"; } fullEndpoint += RTM_VER; } else { String ver = m.group(1); LOG.warn("Specifying a version as a part of the endpoint is deprecated. " + "Please remove the {} from {}", ver, endpoint); } String uri = String.format("%s?appkey=%s", fullEndpoint, appKey); try { return new URI(uri); } catch (URISyntaxException e) { LOG.error("Unable to parse URI {}", uri, e); throw new RuntimeException(e); } } }
RtmClientBuilder { URI createUri(String endpoint, String appKey) { if (Strings.isNullOrEmpty(endpoint)) { throw new IllegalArgumentException(); } Pattern verPattern = Pattern.compile("/(v\\d+)$"); Matcher m = verPattern.matcher(endpoint); String fullEndpoint = endpoint; if (!m.find()) { if (!fullEndpoint.endsWith("/")) { fullEndpoint += "/"; } fullEndpoint += RTM_VER; } else { String ver = m.group(1); LOG.warn("Specifying a version as a part of the endpoint is deprecated. " + "Please remove the {} from {}", ver, endpoint); } String uri = String.format("%s?appkey=%s", fullEndpoint, appKey); try { return new URI(uri); } catch (URISyntaxException e) { LOG.error("Unable to parse URI {}", uri, e); throw new RuntimeException(e); } } RtmClientBuilder(String endpoint, String appKey); }
RtmClientBuilder { URI createUri(String endpoint, String appKey) { if (Strings.isNullOrEmpty(endpoint)) { throw new IllegalArgumentException(); } Pattern verPattern = Pattern.compile("/(v\\d+)$"); Matcher m = verPattern.matcher(endpoint); String fullEndpoint = endpoint; if (!m.find()) { if (!fullEndpoint.endsWith("/")) { fullEndpoint += "/"; } fullEndpoint += RTM_VER; } else { String ver = m.group(1); LOG.warn("Specifying a version as a part of the endpoint is deprecated. " + "Please remove the {} from {}", ver, endpoint); } String uri = String.format("%s?appkey=%s", fullEndpoint, appKey); try { return new URI(uri); } catch (URISyntaxException e) { LOG.error("Unable to parse URI {}", uri, e); throw new RuntimeException(e); } } RtmClientBuilder(String endpoint, String appKey); RtmClient build(); RtmClientBuilder setConnectionTimeout(int connectionTimeout); RtmClientBuilder setProxy(URI proxyUri); RtmClientBuilder setPendingActionQueueLength(int pendingActionQueueLength); RtmClientBuilder setMaxReconnectInterval(long maxReconnectInterval); RtmClientBuilder setMinReconnectInterval(long minReconnectInterval); RtmClientBuilder setListener(RtmClientListener listener); @Deprecated RtmClientBuilder setTransportFactory(final TransportFactory transportFactory); RtmClientBuilder setTransportFactory(AbstractTransportFactory transportFactory); RtmClientBuilder setAuthProvider(AuthProvider authProvider); RtmClientBuilder setAutoReconnect(boolean isAutoReconnect); RtmClientBuilder setScheduler(ScheduledExecutorService service); RtmClientBuilder setDispatcher(ExecutorService dispatcher,
                                        boolean shouldDispatchTransport); RtmClientBuilder setJsonSerializer(Serializer serializer); }
RtmClientBuilder { URI createUri(String endpoint, String appKey) { if (Strings.isNullOrEmpty(endpoint)) { throw new IllegalArgumentException(); } Pattern verPattern = Pattern.compile("/(v\\d+)$"); Matcher m = verPattern.matcher(endpoint); String fullEndpoint = endpoint; if (!m.find()) { if (!fullEndpoint.endsWith("/")) { fullEndpoint += "/"; } fullEndpoint += RTM_VER; } else { String ver = m.group(1); LOG.warn("Specifying a version as a part of the endpoint is deprecated. " + "Please remove the {} from {}", ver, endpoint); } String uri = String.format("%s?appkey=%s", fullEndpoint, appKey); try { return new URI(uri); } catch (URISyntaxException e) { LOG.error("Unable to parse URI {}", uri, e); throw new RuntimeException(e); } } RtmClientBuilder(String endpoint, String appKey); RtmClient build(); RtmClientBuilder setConnectionTimeout(int connectionTimeout); RtmClientBuilder setProxy(URI proxyUri); RtmClientBuilder setPendingActionQueueLength(int pendingActionQueueLength); RtmClientBuilder setMaxReconnectInterval(long maxReconnectInterval); RtmClientBuilder setMinReconnectInterval(long minReconnectInterval); RtmClientBuilder setListener(RtmClientListener listener); @Deprecated RtmClientBuilder setTransportFactory(final TransportFactory transportFactory); RtmClientBuilder setTransportFactory(AbstractTransportFactory transportFactory); RtmClientBuilder setAuthProvider(AuthProvider authProvider); RtmClientBuilder setAutoReconnect(boolean isAutoReconnect); RtmClientBuilder setScheduler(ScheduledExecutorService service); RtmClientBuilder setDispatcher(ExecutorService dispatcher,
                                        boolean shouldDispatchTransport); RtmClientBuilder setJsonSerializer(Serializer serializer);  }