@Override
    public List<AwsEndpoint> getClusterEndpoints() {
        List<AwsEndpoint> result = new ArrayList<>();

        EurekaHttpClient client = null;
        try {
            client = clientFactory.newClient();
            EurekaHttpResponse<Applications> response = client.getVip(vipAddress);
            if (validResponse(response)) {
                Applications applications = response.getEntity();
                if (applications != null) {
                    applications.shuffleInstances(true);  // filter out non-UP instances
                    List<InstanceInfo> validInstanceInfos = applications.getInstancesByVirtualHostName(vipAddress);
                    for (InstanceInfo instanceInfo : validInstanceInfos) {
                        AwsEndpoint endpoint = ResolverUtils.instanceInfoToEndpoint(clientConfig, transportConfig, instanceInfo);
                        if (endpoint != null) {
                            result.add(endpoint);
                        }
                    }
                    logger.debug("Retrieved endpoint list {}", result);
                    return result;
                }
            }
        } catch (Exception e) {
            logger.error("Error contacting server for endpoints with vipAddress:{}", vipAddress, e);
        } finally {
            if (client != null) {
                client.shutdown();
            }
        }

        logger.info("Returning empty endpoint list");
        return Collections.emptyList();
    }
@Test
    public void testNoValidDataFromRemoteServer() {
        Applications newApplications = new Applications();
        for (Application application : applications.getRegisteredApplications()) {
            if (!application.getInstances().get(0).getVIPAddress().equals(vipAddress)) {
                newApplications.addApplication(application);
            }
        }
        when(httpClient.getVip(vipAddress)).thenReturn(EurekaHttpResponse.anEurekaHttpResponse(200, newApplications).build());

        List<AwsEndpoint> endpoints = resolver.getClusterEndpoints();
        assertThat(endpoints.isEmpty(), is(true));

        verify(httpClient, times(1)).shutdown();
    }