@Test(expectedExceptions = IllegalArgumentException.class) public void testFailIfNoGeneratedHttpRequest() { ApiVersionFilter filter = new ApiVersionFilter(config, filterStringsBoundToInjectorByName(new Properties())); filter.filter(HttpRequest.builder().method("GET").endpoint("http: }
@Override public HttpRequest filter(HttpRequest request) throws HttpException { checkArgument(request instanceof GeneratedHttpRequest, "This filter can only be applied to GeneratedHttpRequest objects"); GeneratedHttpRequest generatedRequest = (GeneratedHttpRequest) request; String commandName = config.getCommandName(generatedRequest.getInvocation()); String customApiVersion = versions.get(commandName); if (customApiVersion == null) { Invokable<?, ?> invoked = generatedRequest.getInvocation().getInvokable(); String className = invoked.getOwnerType().getRawType().getSimpleName(); customApiVersion = versions.get(className); } if (customApiVersion != null) { return request.toBuilder().replaceQueryParam("api-version", customApiVersion).build(); } return request; }
ApiVersionFilter implements HttpRequestFilter { @Override public HttpRequest filter(HttpRequest request) throws HttpException { checkArgument(request instanceof GeneratedHttpRequest, "This filter can only be applied to GeneratedHttpRequest objects"); GeneratedHttpRequest generatedRequest = (GeneratedHttpRequest) request; String commandName = config.getCommandName(generatedRequest.getInvocation()); String customApiVersion = versions.get(commandName); if (customApiVersion == null) { Invokable<?, ?> invoked = generatedRequest.getInvocation().getInvokable(); String className = invoked.getOwnerType().getRawType().getSimpleName(); customApiVersion = versions.get(className); } if (customApiVersion != null) { return request.toBuilder().replaceQueryParam("api-version", customApiVersion).build(); } return request; } }
ApiVersionFilter implements HttpRequestFilter { @Override public HttpRequest filter(HttpRequest request) throws HttpException { checkArgument(request instanceof GeneratedHttpRequest, "This filter can only be applied to GeneratedHttpRequest objects"); GeneratedHttpRequest generatedRequest = (GeneratedHttpRequest) request; String commandName = config.getCommandName(generatedRequest.getInvocation()); String customApiVersion = versions.get(commandName); if (customApiVersion == null) { Invokable<?, ?> invoked = generatedRequest.getInvocation().getInvokable(); String className = invoked.getOwnerType().getRawType().getSimpleName(); customApiVersion = versions.get(className); } if (customApiVersion != null) { return request.toBuilder().replaceQueryParam("api-version", customApiVersion).build(); } return request; } @Inject  ApiVersionFilter(InvocationConfig config, Function<Predicate<String>, Map<String, String>> filterStringsBoundByName); }
ApiVersionFilter implements HttpRequestFilter { @Override public HttpRequest filter(HttpRequest request) throws HttpException { checkArgument(request instanceof GeneratedHttpRequest, "This filter can only be applied to GeneratedHttpRequest objects"); GeneratedHttpRequest generatedRequest = (GeneratedHttpRequest) request; String commandName = config.getCommandName(generatedRequest.getInvocation()); String customApiVersion = versions.get(commandName); if (customApiVersion == null) { Invokable<?, ?> invoked = generatedRequest.getInvocation().getInvokable(); String className = invoked.getOwnerType().getRawType().getSimpleName(); customApiVersion = versions.get(className); } if (customApiVersion != null) { return request.toBuilder().replaceQueryParam("api-version", customApiVersion).build(); } return request; } @Inject  ApiVersionFilter(InvocationConfig config, Function<Predicate<String>, Map<String, String>> filterStringsBoundByName); @Override HttpRequest filter(HttpRequest request); }
ApiVersionFilter implements HttpRequestFilter { @Override public HttpRequest filter(HttpRequest request) throws HttpException { checkArgument(request instanceof GeneratedHttpRequest, "This filter can only be applied to GeneratedHttpRequest objects"); GeneratedHttpRequest generatedRequest = (GeneratedHttpRequest) request; String commandName = config.getCommandName(generatedRequest.getInvocation()); String customApiVersion = versions.get(commandName); if (customApiVersion == null) { Invokable<?, ?> invoked = generatedRequest.getInvocation().getInvokable(); String className = invoked.getOwnerType().getRawType().getSimpleName(); customApiVersion = versions.get(className); } if (customApiVersion != null) { return request.toBuilder().replaceQueryParam("api-version", customApiVersion).build(); } return request; } @Inject  ApiVersionFilter(InvocationConfig config, Function<Predicate<String>, Map<String, String>> filterStringsBoundByName); @Override HttpRequest filter(HttpRequest request);  }