@Test void requestSpecification_mustNotContainAbsoluteUri() { Target<?> target = new UriTarget<>(String.class, "Sample", "https: RequestSpecification requestSpecification = new RequestSpecification(); requestSpecification.uri(URI.create("https: assertThrows(IllegalStateException.class, () -> target.apply(requestSpecification)); }
@Override public void apply(RequestSpecification requestSpecification) { URI targetUri = requestSpecification.uri() .map(current -> { if (current.isAbsolute()) { throw new IllegalStateException("URIs must be relative when using a UriTarget."); } return URI.create(uri.toString() + current.toString()); }).orElse(this.uri); requestSpecification.uri(targetUri); }
UriTarget extends AbstractTarget<T> { @Override public void apply(RequestSpecification requestSpecification) { URI targetUri = requestSpecification.uri() .map(current -> { if (current.isAbsolute()) { throw new IllegalStateException("URIs must be relative when using a UriTarget."); } return URI.create(uri.toString() + current.toString()); }).orElse(this.uri); requestSpecification.uri(targetUri); } }
UriTarget extends AbstractTarget<T> { @Override public void apply(RequestSpecification requestSpecification) { URI targetUri = requestSpecification.uri() .map(current -> { if (current.isAbsolute()) { throw new IllegalStateException("URIs must be relative when using a UriTarget."); } return URI.create(uri.toString() + current.toString()); }).orElse(this.uri); requestSpecification.uri(targetUri); } UriTarget(Class<T> type, String uri);  UriTarget(Class<T> type, String name, String uri); }
UriTarget extends AbstractTarget<T> { @Override public void apply(RequestSpecification requestSpecification) { URI targetUri = requestSpecification.uri() .map(current -> { if (current.isAbsolute()) { throw new IllegalStateException("URIs must be relative when using a UriTarget."); } return URI.create(uri.toString() + current.toString()); }).orElse(this.uri); requestSpecification.uri(targetUri); } UriTarget(Class<T> type, String uri);  UriTarget(Class<T> type, String name, String uri); @Override void apply(RequestSpecification requestSpecification); }
UriTarget extends AbstractTarget<T> { @Override public void apply(RequestSpecification requestSpecification) { URI targetUri = requestSpecification.uri() .map(current -> { if (current.isAbsolute()) { throw new IllegalStateException("URIs must be relative when using a UriTarget."); } return URI.create(uri.toString() + current.toString()); }).orElse(this.uri); requestSpecification.uri(targetUri); } UriTarget(Class<T> type, String uri);  UriTarget(Class<T> type, String name, String uri); @Override void apply(RequestSpecification requestSpecification);  }