@Test public void shouldAppendCredential() throws Exception { String expectedUri = "http: String uri = httpClient.appendCredential("http: assertEquals(expectedUri, uri); }
public String appendCredential(String uri) throws URISyntaxException, UnsupportedEncodingException { URI oldUri = new URI(uri); String newQuery = oldUri.getQuery(); if (newQuery == null) { newQuery = credentialQuery; } else { newQuery += "&" + credentialQuery; } return new URI(oldUri.getScheme(), oldUri.getAuthority(), oldUri.getPath(), newQuery, oldUri.getFragment()).toString(); }
AuthenticatedHttpClient implements HttpClient { public String appendCredential(String uri) throws URISyntaxException, UnsupportedEncodingException { URI oldUri = new URI(uri); String newQuery = oldUri.getQuery(); if (newQuery == null) { newQuery = credentialQuery; } else { newQuery += "&" + credentialQuery; } return new URI(oldUri.getScheme(), oldUri.getAuthority(), oldUri.getPath(), newQuery, oldUri.getFragment()).toString(); } }
AuthenticatedHttpClient implements HttpClient { public String appendCredential(String uri) throws URISyntaxException, UnsupportedEncodingException { URI oldUri = new URI(uri); String newQuery = oldUri.getQuery(); if (newQuery == null) { newQuery = credentialQuery; } else { newQuery += "&" + credentialQuery; } return new URI(oldUri.getScheme(), oldUri.getAuthority(), oldUri.getPath(), newQuery, oldUri.getFragment()).toString(); } AuthenticatedHttpClient(HttpClient httpClient, Credential credential); }
AuthenticatedHttpClient implements HttpClient { public String appendCredential(String uri) throws URISyntaxException, UnsupportedEncodingException { URI oldUri = new URI(uri); String newQuery = oldUri.getQuery(); if (newQuery == null) { newQuery = credentialQuery; } else { newQuery += "&" + credentialQuery; } return new URI(oldUri.getScheme(), oldUri.getAuthority(), oldUri.getPath(), newQuery, oldUri.getFragment()).toString(); } AuthenticatedHttpClient(HttpClient httpClient, Credential credential); @Override HttpResponse execute(HttpMethod method, String targetURL, Map<String, String> headers,
                                HttpRequestBody body); @Override HttpResponse executeXML(HttpMethod method, String targetURL, Map<String, String> headers,
                                HttpXMLRequestBody body); HttpResponse executeJson(HttpMethod method, String targetURL, Map<String, String> headers,
                                    HttpJsonRequestBody body); String appendCorrelationId(String uri); String appendCredential(String uri); }
AuthenticatedHttpClient implements HttpClient { public String appendCredential(String uri) throws URISyntaxException, UnsupportedEncodingException { URI oldUri = new URI(uri); String newQuery = oldUri.getQuery(); if (newQuery == null) { newQuery = credentialQuery; } else { newQuery += "&" + credentialQuery; } return new URI(oldUri.getScheme(), oldUri.getAuthority(), oldUri.getPath(), newQuery, oldUri.getFragment()).toString(); } AuthenticatedHttpClient(HttpClient httpClient, Credential credential); @Override HttpResponse execute(HttpMethod method, String targetURL, Map<String, String> headers,
                                HttpRequestBody body); @Override HttpResponse executeXML(HttpMethod method, String targetURL, Map<String, String> headers,
                                HttpXMLRequestBody body); HttpResponse executeJson(HttpMethod method, String targetURL, Map<String, String> headers,
                                    HttpJsonRequestBody body); String appendCorrelationId(String uri); String appendCredential(String uri);  }