@Test public void consume() throws URISyntaxException { URI uri = new URIBuilder(URI).build(); HttpHost httpHost = new HttpHost("16.17.158", 8081); List<URI> redirectLocations = new ArrayList<>(); URI redirectUri = new URIBuilder(REDIRECT_URI).build(); redirectLocations.add(redirectUri); Map<String, String> returnResult = new HashMap<>(); finalLocationConsumer.setUri(uri) .setTargetHost(httpHost) .setRedirectLocations(redirectLocations) .consume(returnResult); assertEquals(REDIRECT_URI, returnResult.get(FINAL_LOCATION)); }
public void consume(Map<String, String> returnResult) { URI location; try { location = URIUtils.resolve(uri, targetHost, redirectLocations); } catch (URISyntaxException e) { throw new IllegalArgumentException("could not determine '" + HttpClientService.FINAL_LOCATION + "': " + e.getMessage(), e); } returnResult.put(HttpClientService.FINAL_LOCATION, location.toASCIIString()); }
FinalLocationConsumer { public void consume(Map<String, String> returnResult) { URI location; try { location = URIUtils.resolve(uri, targetHost, redirectLocations); } catch (URISyntaxException e) { throw new IllegalArgumentException("could not determine '" + HttpClientService.FINAL_LOCATION + "': " + e.getMessage(), e); } returnResult.put(HttpClientService.FINAL_LOCATION, location.toASCIIString()); } }
FinalLocationConsumer { public void consume(Map<String, String> returnResult) { URI location; try { location = URIUtils.resolve(uri, targetHost, redirectLocations); } catch (URISyntaxException e) { throw new IllegalArgumentException("could not determine '" + HttpClientService.FINAL_LOCATION + "': " + e.getMessage(), e); } returnResult.put(HttpClientService.FINAL_LOCATION, location.toASCIIString()); }  }
FinalLocationConsumer { public void consume(Map<String, String> returnResult) { URI location; try { location = URIUtils.resolve(uri, targetHost, redirectLocations); } catch (URISyntaxException e) { throw new IllegalArgumentException("could not determine '" + HttpClientService.FINAL_LOCATION + "': " + e.getMessage(), e); } returnResult.put(HttpClientService.FINAL_LOCATION, location.toASCIIString()); }  FinalLocationConsumer setUri(URI uri); FinalLocationConsumer setTargetHost(HttpHost targetHost); FinalLocationConsumer setRedirectLocations(List<URI> redirectLocations); void consume(Map<String, String> returnResult); }
FinalLocationConsumer { public void consume(Map<String, String> returnResult) { URI location; try { location = URIUtils.resolve(uri, targetHost, redirectLocations); } catch (URISyntaxException e) { throw new IllegalArgumentException("could not determine '" + HttpClientService.FINAL_LOCATION + "': " + e.getMessage(), e); } returnResult.put(HttpClientService.FINAL_LOCATION, location.toASCIIString()); }  FinalLocationConsumer setUri(URI uri); FinalLocationConsumer setTargetHost(HttpHost targetHost); FinalLocationConsumer setRedirectLocations(List<URI> redirectLocations); void consume(Map<String, String> returnResult);  }