@Test public void testAdapt_proxyRepositoryAuth() throws Exception { Repository repository = createRepository(new ProxyType()); SimpleApiProxyRepository proxyRepository = (SimpleApiProxyRepository) underTest.adapt(repository); assertThat(proxyRepository.getHttpClient().getAuthentication(), nullValue()); NestedAttributesMap httpclient = repository.getConfiguration().attributes("httpclient").child("authentication"); httpclient.set("type", "username"); httpclient.set("username", "jsmith"); httpclient.set("password", "p4ssw0rd"); proxyRepository = (SimpleApiProxyRepository) underTest.adapt(repository); assertThat(proxyRepository.getHttpClient().getAuthentication().getType(), is("username")); assertThat(proxyRepository.getHttpClient().getAuthentication().getUsername(), is("jsmith")); assertThat(proxyRepository.getHttpClient().getAuthentication().getPassword(), nullValue()); assertThat(proxyRepository.getHttpClient().getAuthentication().getNtlmDomain(), nullValue()); assertThat(proxyRepository.getHttpClient().getAuthentication().getNtlmHost(), nullValue()); httpclient.set("type", "ntlm"); httpclient.set("username", "jsmith"); httpclient.set("password", "p4ssw0rd"); httpclient.set("ntlmDomain", "sona"); httpclient.set("ntlmHost", "sonatype.com"); proxyRepository = (SimpleApiProxyRepository) underTest.adapt(repository); assertThat(proxyRepository.getHttpClient().getAuthentication().getType(), is("ntlm")); assertThat(proxyRepository.getHttpClient().getAuthentication().getUsername(), is("jsmith")); assertThat(proxyRepository.getHttpClient().getAuthentication().getPassword(), nullValue()); assertThat(proxyRepository.getHttpClient().getAuthentication().getNtlmDomain(), is("sona")); assertThat(proxyRepository.getHttpClient().getAuthentication().getNtlmHost(), is("sonatype.com")); }
@Override public AbstractApiRepository adapt(final Repository repository) { boolean online = repository.getConfiguration().isOnline(); String name = repository.getName(); String format = repository.getFormat().toString(); String url = repository.getUrl(); switch (repository.getType().toString()) { case GroupType.NAME: return new SimpleApiGroupRepository(name, format, url, online, getStorageAttributes(repository), getGroupAttributes(repository)); case HostedType.NAME: return new SimpleApiHostedRepository(name, format, url, online, getHostedStorageAttributes(repository), getCleanupPolicyAttributes(repository)); case ProxyType.NAME: return new SimpleApiProxyRepository(name, format, url, online, getStorageAttributes(repository), getCleanupPolicyAttributes(repository), getProxyAttributes(repository), getNegativeCacheAttributes(repository), getHttpClientAttributes(repository), getRoutingRuleName(repository)); default: return null; } }
SimpleApiRepositoryAdapter implements ApiRepositoryAdapter { @Override public AbstractApiRepository adapt(final Repository repository) { boolean online = repository.getConfiguration().isOnline(); String name = repository.getName(); String format = repository.getFormat().toString(); String url = repository.getUrl(); switch (repository.getType().toString()) { case GroupType.NAME: return new SimpleApiGroupRepository(name, format, url, online, getStorageAttributes(repository), getGroupAttributes(repository)); case HostedType.NAME: return new SimpleApiHostedRepository(name, format, url, online, getHostedStorageAttributes(repository), getCleanupPolicyAttributes(repository)); case ProxyType.NAME: return new SimpleApiProxyRepository(name, format, url, online, getStorageAttributes(repository), getCleanupPolicyAttributes(repository), getProxyAttributes(repository), getNegativeCacheAttributes(repository), getHttpClientAttributes(repository), getRoutingRuleName(repository)); default: return null; } } }
SimpleApiRepositoryAdapter implements ApiRepositoryAdapter { @Override public AbstractApiRepository adapt(final Repository repository) { boolean online = repository.getConfiguration().isOnline(); String name = repository.getName(); String format = repository.getFormat().toString(); String url = repository.getUrl(); switch (repository.getType().toString()) { case GroupType.NAME: return new SimpleApiGroupRepository(name, format, url, online, getStorageAttributes(repository), getGroupAttributes(repository)); case HostedType.NAME: return new SimpleApiHostedRepository(name, format, url, online, getHostedStorageAttributes(repository), getCleanupPolicyAttributes(repository)); case ProxyType.NAME: return new SimpleApiProxyRepository(name, format, url, online, getStorageAttributes(repository), getCleanupPolicyAttributes(repository), getProxyAttributes(repository), getNegativeCacheAttributes(repository), getHttpClientAttributes(repository), getRoutingRuleName(repository)); default: return null; } } @Inject  SimpleApiRepositoryAdapter(final RoutingRuleStore routingRuleStore); }
SimpleApiRepositoryAdapter implements ApiRepositoryAdapter { @Override public AbstractApiRepository adapt(final Repository repository) { boolean online = repository.getConfiguration().isOnline(); String name = repository.getName(); String format = repository.getFormat().toString(); String url = repository.getUrl(); switch (repository.getType().toString()) { case GroupType.NAME: return new SimpleApiGroupRepository(name, format, url, online, getStorageAttributes(repository), getGroupAttributes(repository)); case HostedType.NAME: return new SimpleApiHostedRepository(name, format, url, online, getHostedStorageAttributes(repository), getCleanupPolicyAttributes(repository)); case ProxyType.NAME: return new SimpleApiProxyRepository(name, format, url, online, getStorageAttributes(repository), getCleanupPolicyAttributes(repository), getProxyAttributes(repository), getNegativeCacheAttributes(repository), getHttpClientAttributes(repository), getRoutingRuleName(repository)); default: return null; } } @Inject  SimpleApiRepositoryAdapter(final RoutingRuleStore routingRuleStore); @Override AbstractApiRepository adapt(final Repository repository); }
SimpleApiRepositoryAdapter implements ApiRepositoryAdapter { @Override public AbstractApiRepository adapt(final Repository repository) { boolean online = repository.getConfiguration().isOnline(); String name = repository.getName(); String format = repository.getFormat().toString(); String url = repository.getUrl(); switch (repository.getType().toString()) { case GroupType.NAME: return new SimpleApiGroupRepository(name, format, url, online, getStorageAttributes(repository), getGroupAttributes(repository)); case HostedType.NAME: return new SimpleApiHostedRepository(name, format, url, online, getHostedStorageAttributes(repository), getCleanupPolicyAttributes(repository)); case ProxyType.NAME: return new SimpleApiProxyRepository(name, format, url, online, getStorageAttributes(repository), getCleanupPolicyAttributes(repository), getProxyAttributes(repository), getNegativeCacheAttributes(repository), getHttpClientAttributes(repository), getRoutingRuleName(repository)); default: return null; } } @Inject  SimpleApiRepositoryAdapter(final RoutingRuleStore routingRuleStore); @Override AbstractApiRepository adapt(final Repository repository);  }