MavenApiRepositoryAdapter extends SimpleApiRepositoryAdapter { @Override public AbstractApiRepository adapt(final Repository repository) { boolean online = repository.getConfiguration().isOnline(); String name = repository.getName(); String url = repository.getUrl(); switch (repository.getType().toString()) { case HostedType.NAME: return new MavenHostedApiRepository(name, url, online, getHostedStorageAttributes(repository), getCleanupPolicyAttributes(repository), createMavenAttributes(repository)); case ProxyType.NAME: return new MavenProxyApiRepository(name, url, online, getHostedStorageAttributes(repository), getCleanupPolicyAttributes(repository), getProxyAttributes(repository), getNegativeCacheAttributes(repository), getHttpClientAttributes(repository), getRoutingRuleName(repository), createMavenAttributes(repository)); default: return super.adapt(repository); } } @Inject  MavenApiRepositoryAdapter(final RoutingRuleStore routingRuleStore); @Override AbstractApiRepository adapt(final Repository repository);  }
@Test public void testAdapt_groupRepository() throws Exception { Repository repository = createRepository(new GroupType()); repository.getConfiguration().attributes("group").set("memberNames", Arrays.asList("a", "b")); SimpleApiGroupRepository groupRepository = (SimpleApiGroupRepository) underTest.adapt(repository); assertRepository(groupRepository, "group", true); }
@Test public void testAdapt_hostedRepository() throws Exception { Repository repository = createRepository(new HostedType(), LayoutPolicy.STRICT, VersionPolicy.MIXED); MavenHostedApiRepository hostedRepository = (MavenHostedApiRepository) underTest.adapt(repository); assertRepository(hostedRepository, "hosted", true); assertThat(hostedRepository.getMaven().getLayoutPolicy(), is("STRICT")); assertThat(hostedRepository.getMaven().getVersionPolicy(), is("MIXED")); assertThat(hostedRepository.getCleanup(), nullValue()); assertThat(hostedRepository.getStorage(), notNullValue()); }
@Test public void testAdapt_proxyRepository() throws Exception { Repository repository = createRepository(new ProxyType(), LayoutPolicy.STRICT, VersionPolicy.MIXED); MavenProxyApiRepository proxyRepository = (MavenProxyApiRepository) underTest.adapt(repository); assertRepository(proxyRepository, "proxy", true); assertThat(proxyRepository.getMaven().getLayoutPolicy(), is("STRICT")); assertThat(proxyRepository.getMaven().getVersionPolicy(), is("MIXED")); assertThat(proxyRepository.getCleanup(), nullValue()); assertThat(proxyRepository.getHttpClient(), notNullValue()); assertThat(proxyRepository.getNegativeCache(), notNullValue()); assertThat(proxyRepository.getProxy(), notNullValue()); assertThat(proxyRepository.getStorage(), notNullValue()); }