OutgoingCallsGatheringClient implements IncomingRequestAwareClient { @Override public CompletionStage<Response<ByteString>> send(Request request, Optional<Request> incoming) { final URI uri = URI.create(request.uri()); final String service = uri.getAuthority(); callsGatherer.gatherOutgoingCall(service, request); return delegate.send(request, incoming); } OutgoingCallsGatheringClient(OutgoingCallsGatherer callsGatherer, IncomingRequestAwareClient delegate); @Override CompletionStage<Response<ByteString>> send(Request request, Optional<Request> incoming);  }
@Test public void shouldGatherCallsWithServiceFromAuthority() throws Exception { Request request = Request.forUri("http: client.send(request, empty()); verify(delegate).send(eq(request), eq(empty())); verify(callsGatherer).gatherOutgoingCall(eq("bowman"), eq(request)); }