AddVCloudAuthorizationAndCookieToRequest implements HttpRequestFilter { @Override public HttpRequest filter(HttpRequest request) throws HttpException { String token = vcloudTokenProvider.get(); return request .toBuilder() .replaceHeaders( ImmutableMultimap.of("x-vcloud-authorization", token, HttpHeaders.COOKIE, "vcloud-token=" + token)).build(); } @Inject  AddVCloudAuthorizationAndCookieToRequest(@VCloudToken Supplier<String> authTokenProvider); @Override HttpRequest filter(HttpRequest request);  }
@Test public void testApply() { HttpRequest request = HttpRequest.builder().method("GET").endpoint("http: request = filter.filter(request); assertEquals(request.getHeaders().size(), 2); assertEquals(request.getFirstHeaderOrNull(HttpHeaders.COOKIE), "vcloud-token=token"); assertEquals(request.getFirstHeaderOrNull("x-vcloud-authorization"), "token"); }