@Test(expected = RequestTimeoutException.class) public void testFetchException() { when(fetcher.get(any(), any())).thenThrow(new RequestTimeoutException("timed out")); proxy.get(applicationMock, hostname, CLUSTERCONTROLLER_CONTAINER.serviceName, "clustercontroller-status/v1/clusterName"); }
public HttpResponse get(Application application, String hostName, String serviceType, String relativePath) { HostInfo host = application.getModel().getHosts().stream() .filter(hostInfo -> hostInfo.getHostname().equals(hostName)) .findFirst() .orElseThrow(() -> new NotFoundException("Failed to find host " + hostName)); ServiceInfo service = host.getServices().stream() .filter(serviceInfo -> serviceType.equals(serviceInfo.getServiceType())) .findFirst() .orElseThrow(() -> new NotFoundException("Failed to find any service of type " + serviceType + " on host " + hostName)); PortInfo port = service.getPorts().stream() .filter(portInfo -> portInfo.getTags().stream().collect(Collectors.toSet()).containsAll( Stream.of("http", "state").collect(Collectors.toSet()))) .findFirst() .orElseThrow(() -> new NotFoundException("Failed to find HTTP state port")); return internalGet(host.getHostname(), port.getPort(), relativePath); }
HttpProxy { public HttpResponse get(Application application, String hostName, String serviceType, String relativePath) { HostInfo host = application.getModel().getHosts().stream() .filter(hostInfo -> hostInfo.getHostname().equals(hostName)) .findFirst() .orElseThrow(() -> new NotFoundException("Failed to find host " + hostName)); ServiceInfo service = host.getServices().stream() .filter(serviceInfo -> serviceType.equals(serviceInfo.getServiceType())) .findFirst() .orElseThrow(() -> new NotFoundException("Failed to find any service of type " + serviceType + " on host " + hostName)); PortInfo port = service.getPorts().stream() .filter(portInfo -> portInfo.getTags().stream().collect(Collectors.toSet()).containsAll( Stream.of("http", "state").collect(Collectors.toSet()))) .findFirst() .orElseThrow(() -> new NotFoundException("Failed to find HTTP state port")); return internalGet(host.getHostname(), port.getPort(), relativePath); } }
HttpProxy { public HttpResponse get(Application application, String hostName, String serviceType, String relativePath) { HostInfo host = application.getModel().getHosts().stream() .filter(hostInfo -> hostInfo.getHostname().equals(hostName)) .findFirst() .orElseThrow(() -> new NotFoundException("Failed to find host " + hostName)); ServiceInfo service = host.getServices().stream() .filter(serviceInfo -> serviceType.equals(serviceInfo.getServiceType())) .findFirst() .orElseThrow(() -> new NotFoundException("Failed to find any service of type " + serviceType + " on host " + hostName)); PortInfo port = service.getPorts().stream() .filter(portInfo -> portInfo.getTags().stream().collect(Collectors.toSet()).containsAll( Stream.of("http", "state").collect(Collectors.toSet()))) .findFirst() .orElseThrow(() -> new NotFoundException("Failed to find HTTP state port")); return internalGet(host.getHostname(), port.getPort(), relativePath); } @Inject  HttpProxy();  HttpProxy(HttpFetcher fetcher); }
HttpProxy { public HttpResponse get(Application application, String hostName, String serviceType, String relativePath) { HostInfo host = application.getModel().getHosts().stream() .filter(hostInfo -> hostInfo.getHostname().equals(hostName)) .findFirst() .orElseThrow(() -> new NotFoundException("Failed to find host " + hostName)); ServiceInfo service = host.getServices().stream() .filter(serviceInfo -> serviceType.equals(serviceInfo.getServiceType())) .findFirst() .orElseThrow(() -> new NotFoundException("Failed to find any service of type " + serviceType + " on host " + hostName)); PortInfo port = service.getPorts().stream() .filter(portInfo -> portInfo.getTags().stream().collect(Collectors.toSet()).containsAll( Stream.of("http", "state").collect(Collectors.toSet()))) .findFirst() .orElseThrow(() -> new NotFoundException("Failed to find HTTP state port")); return internalGet(host.getHostname(), port.getPort(), relativePath); } @Inject  HttpProxy();  HttpProxy(HttpFetcher fetcher); HttpResponse get(Application application, String hostName, String serviceType, String relativePath); }
HttpProxy { public HttpResponse get(Application application, String hostName, String serviceType, String relativePath) { HostInfo host = application.getModel().getHosts().stream() .filter(hostInfo -> hostInfo.getHostname().equals(hostName)) .findFirst() .orElseThrow(() -> new NotFoundException("Failed to find host " + hostName)); ServiceInfo service = host.getServices().stream() .filter(serviceInfo -> serviceType.equals(serviceInfo.getServiceType())) .findFirst() .orElseThrow(() -> new NotFoundException("Failed to find any service of type " + serviceType + " on host " + hostName)); PortInfo port = service.getPorts().stream() .filter(portInfo -> portInfo.getTags().stream().collect(Collectors.toSet()).containsAll( Stream.of("http", "state").collect(Collectors.toSet()))) .findFirst() .orElseThrow(() -> new NotFoundException("Failed to find HTTP state port")); return internalGet(host.getHostname(), port.getPort(), relativePath); } @Inject  HttpProxy();  HttpProxy(HttpFetcher fetcher); HttpResponse get(Application application, String hostName, String serviceType, String relativePath);  }