    @Test
    public void testGetHttpClientWithProxyConfig() throws Exception
    {

        ArgumentCaptor<CredentialsProvider> credentialsProviderCaptor = ArgumentCaptor.forClass(CredentialsProvider.class);
        ArgumentCaptor<HttpHost> httpHostArgumentCaptor = ArgumentCaptor.forClass(HttpHost.class);
        PowerMockito.when(httpClientBuilder.setProxy(httpHostArgumentCaptor.capture())).thenReturn(httpClientBuilder);
        PowerMockito.when(httpClientBuilder.setDefaultCredentialsProvider(credentialsProviderCaptor.capture())).thenReturn(httpClientBuilder);

        assertNotNull(httpClientFactory.getHttpClient(fillProxyConfiguration(), null));
        HttpHost httpHost = httpHostArgumentCaptor.getValue();
        Credentials credentials = credentialsProviderCaptor.getValue().getCredentials(new AuthScope(HOST, PORT));

        assertEquals(HOST, httpHost.getHostName());
        assertEquals(PORT, httpHost.getPort());
        assertEquals(USERNAME, credentials.getUserPrincipal().getName());
        assertEquals(PASSWORD, credentials.getPassword());

        verify(httpClientBuilder).build();
    }