HttpDiscoveryLookupClient implements DiscoveryLookupClient { @Override public ListenableFuture<ServiceDescriptors> refreshServices(ServiceDescriptors serviceDescriptors) { requireNonNull(serviceDescriptors, "serviceDescriptors is null"); return lookup(serviceDescriptors.getType(), serviceDescriptors.getPool(), serviceDescriptors); } @Inject  HttpDiscoveryLookupClient(NodeInfo nodeInfo,
            JsonCodec<ServiceDescriptorsRepresentation> serviceDescriptorsCodec,
            @ForDiscoveryClient HttpClient httpClient,
            ServiceInventory serviceInventory); @Flatten RequestStats getStats(); @Override ListenableFuture<ServiceDescriptors> getServices(String type); @Override ListenableFuture<ServiceDescriptors> getServices(String type, String pool); @Override ListenableFuture<ServiceDescriptors> refreshServices(ServiceDescriptors serviceDescriptors);  }
@Test public void testRefreshServices() throws Exception { ServiceDescriptors descriptors = createClient(createProcessor(null, null, "testingenvironment")) .refreshServices(new ServiceDescriptors("testService", "testPool", ImmutableList.of(), new Duration(1, HOURS), null)) .get(); assertDescriptorsExpected(descriptors, null, DEFAULT_DELAY); }
@Test public void testRefreshServicesEtag() throws Exception { ServiceDescriptors descriptors = createClient(createProcessor(null, "oldEtag", "testingenvironment")) .refreshServices(new ServiceDescriptors("testService", "testPool", ImmutableList.of(), new Duration(1, HOURS), "oldEtag")) .get(); assertDescriptorsExpected(descriptors, null, DEFAULT_DELAY); }
@Test public void testRefreshServicesNotModified() throws Exception { ServiceDescriptors descriptors = createClient( request -> mockResponse() .status(NOT_MODIFIED) .header("ETag", "newEtag") .header("Cache-Control", "max-age=123") .build()) .refreshServices(new ServiceDescriptors("testService", "testPool", EXPECTED_SERVICE_DESCRIPTOR_LIST, new Duration(1, HOURS), "oldEtag")) .get(); assertDescriptorsExpected(descriptors, "newEtag", new Duration(123, SECONDS)); }