@Test public void testAdapt_proxyRepository() throws Exception { Repository repository = createRepository(new ProxyType()); NestedAttributesMap proxy = repository.getConfiguration().attributes("proxy"); proxy.set("remoteUrl", "https: SimpleApiProxyRepository proxyRepository = (SimpleApiProxyRepository) underTest.adapt(repository); assertRepository(proxyRepository, "proxy", true); assertThat(proxyRepository.getProxy().getContentMaxAge(), is(1440)); assertThat(proxyRepository.getProxy().getMetadataMaxAge(), is(1440)); assertThat(proxyRepository.getProxy().getRemoteUrl(), is("https: assertThat(proxyRepository.getHttpClient().getAutoBlock(), is(false)); assertThat(proxyRepository.getHttpClient().getBlocked(), is(false)); proxy.set("contentMaxAge", 1000.0); proxy.set("metadataMaxAge", 1000.0); NestedAttributesMap httpclient = repository.getConfiguration().attributes("httpclient"); httpclient.set("autoBlock", true); httpclient.set("blocked", true); proxyRepository = (SimpleApiProxyRepository) underTest.adapt(repository); assertThat(proxyRepository.getProxy().getContentMaxAge(), is(1000)); assertThat(proxyRepository.getProxy().getMetadataMaxAge(), is(1000)); assertThat(proxyRepository.getHttpClient().getAutoBlock(), is(true)); assertThat(proxyRepository.getHttpClient().getBlocked(), is(true)); }
@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);  }