@Override
    public Map<String, String> getAddresses() {
        AwsCredentials credentials = awsCredentialsProvider.credentials();
        Map<String, String> instances = Collections.emptyMap();
        if (!awsConfig.anyOfEcsPropertiesConfigured()) {
            instances = awsEc2Api.describeInstances(credentials);
        }
        if (awsConfig.anyOfEc2PropertiesConfigured()) {
            return instances;
        }
        if (instances.isEmpty() && DiscoveryMode.Client == awsConfig.getDiscoveryMode()) {
            return getEcsAddresses(credentials);
        }
        return instances;
    }
@Test
    public void getEcsAddressesClient() {
        AwsCredentials credentials = AwsCredentials.builder()
                .setAccessKey("access-key")
                .setSecretKey("secret-key")
                .setToken("token")
                .build();
        Map<String, String> expectedResult = singletonMap("123.12.1.0", "1.4.6.2");
        ArrayList<String> privateIps = new ArrayList<>(expectedResult.keySet());

        AwsConfig awsConfig = AwsConfig.builder()
                .setCluster("CLUSTER")
                .setDiscoveryMode(DiscoveryMode.Client)
                .build();
        awsEc2Client = new AwsEc2Client(awsEc2Api, awsEcsApi, awsMetadataApi, awsCredentialsProvider, awsConfig);
        given(awsCredentialsProvider.credentials()).willReturn(credentials);
        given(awsEc2Api.describeInstances(credentials)).willReturn(emptyMap());
        given(awsEcsApi.listTaskPrivateAddresses("CLUSTER", credentials)).willReturn(privateIps);
        given(awsEc2Api.describeNetworkInterfaces(privateIps, credentials)).willReturn(expectedResult);

        // when
        Map<String, String> result = awsEc2Client.getAddresses();

        // then
        assertEquals(expectedResult, result);
    }