### Question:
Security implements Auth<HttpClientFactory.Builder> { @Override public void configure(HttpClientFactory.Builder builder) { credentials.applyTo(builder); if (certInfo != null) { certInfo.applyTo(builder); } } protected  Security(Credentials<HttpClientFactory.Builder> credentials, CertInfo<HttpClientFactory.Builder> certInfo); @Override void configure(HttpClientFactory.Builder builder); @PluginBuilderFactory static Security.Builder newBuilder();  }### Answer:
@Test public void appliesCredentialsIfConfigured() { Credentials<HttpClientFactory.Builder> credentials = Mockito.mock(Credentials.class); HttpClientFactory.Builder settingsBuilder = createDefaultTestObjectBuilder(); Security security = createTestBuilder() .withCredentials(credentials) .build(); security.configure(settingsBuilder); verify(credentials).applyTo(builderArgumentCaptor.capture()); Assert.assertEquals(settingsBuilder, builderArgumentCaptor.getValue()); }
@Test public void appliesCertInfoIfConfigured() { CertInfo<HttpClientFactory.Builder> certInfo = Mockito.mock(CertInfo.class); HttpClientFactory.Builder settingsBuilder = createDefaultTestObjectBuilder(); Security security = createTestBuilder() .withCertInfo(certInfo) .build(); security.configure(settingsBuilder); verify(certInfo).applyTo(builderArgumentCaptor.capture()); Assert.assertEquals(settingsBuilder, builderArgumentCaptor.getValue()); }
@Test public void doesntApplyCertInfoIfNotConfigured() { Security auth = createTestBuilder() .withCertInfo(null) .build(); HttpClientFactory.Builder settingsBuilder = Mockito.spy(createDefaultTestObjectBuilder()); auth.configure(settingsBuilder); verify(settingsBuilder, never()).withSslSocketFactory(any()); verify(settingsBuilder, never()).withHttpsIOSessionStrategy(any()); }