Search in sources :

Example 61 with HostedRepository

use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.

the class ListStoresByTypeTest method listByType.

@Test
public void listByType() throws Exception {
    final Set<ArtifactStore> hosteds = new HashSet<>();
    for (int i = 0; i < 3; i++) {
        final HostedRepository repo = new HostedRepository(newName());
        assertThat(client.stores().create(repo, name.getMethodName(), HostedRepository.class), notNullValue());
        hosteds.add(repo);
    }
    final Set<ArtifactStore> remotes = new HashSet<>();
    for (int i = 0; i < 3; i++) {
        final RemoteRepository repo = new RemoteRepository(newName(), newUrl());
        assertThat(client.stores().create(repo, name.getMethodName(), RemoteRepository.class), notNullValue());
        remotes.add(repo);
    }
    final Set<ArtifactStore> groups = new HashSet<>();
    for (int i = 0; i < 3; i++) {
        final Group repo = new Group(newName());
        assertThat(client.stores().create(repo, name.getMethodName(), Group.class), notNullValue());
        groups.add(repo);
    }
    // Now, start listing by type and verify that ONLY those of the given type are present
    checkListing(client.stores().listHostedRepositories(), hosteds, Arrays.asList(remotes, groups));
    checkListing(client.stores().listRemoteRepositories(), remotes, Arrays.asList(groups, hosteds));
    checkListing(client.stores().listGroups(), groups, Arrays.asList(hosteds, remotes));
}
Also used : Group(org.commonjava.indy.model.core.Group) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) HashSet(java.util.HashSet) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Test(org.junit.Test)

Example 62 with HostedRepository

use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.

the class ArtifactRefs_DependencyInAnotherRepoInGroup_RuleTest method start.

@Override
public void start() throws Throwable {
    super.start();
    otherSource = new HostedRepository("otherSource");
    otherSource = client.stores().create(otherSource, "Creating secondary content source", HostedRepository.class);
    other = new Group("other", source.getKey(), otherSource.getKey());
    other = client.stores().create(other, "Creating secondary content group", Group.class);
    Logger logger = LoggerFactory.getLogger(getClass());
    logger.info("{} contains members: {}", other, other.getConstituents());
}
Also used : Group(org.commonjava.indy.model.core.Group) Logger(org.slf4j.Logger) HostedRepository(org.commonjava.indy.model.core.HostedRepository)

Example 63 with HostedRepository

use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.

the class PomUploadListenerTest method run.

@Test
public void run() throws Exception {
    final String repo1 = "repo1";
    HostedRepository hosted1 = new HostedRepository(repo1);
    client.stores().create(hosted1, "adding hosted", HostedRepository.class);
    StoreKey key = new StoreKey(hosted, repo1);
    InputStream stream = new ByteArrayInputStream(content.getBytes());
    client.content().store(key, path, stream);
    waitForEventPropagation();
    boolean exists = client.content().exists(hosted, repo1, pathRel, true);
    assertThat(exists, equalTo(true));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) StoreKey(org.commonjava.indy.model.core.StoreKey) HostedRepository(org.commonjava.indy.model.core.HostedRepository) AbstractIndyFunctionalTest(org.commonjava.indy.ftest.core.AbstractIndyFunctionalTest) Test(org.junit.Test)

Example 64 with HostedRepository

use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.

the class AbstractValidationRuleTest method start.

@Override
public void start() throws Throwable {
    super.start();
    module = client.module(IndyPromoteClientModule.class);
    HostedRepository shr = new HostedRepository("source");
    shr.setAllowSnapshots(true);
    System.out.println("Validation rule test client:" + client);
    System.out.println("Validation rule test client store:" + client.stores());
    source = client.stores().create(shr, "creating test source", HostedRepository.class);
    if (Group.class.equals(targetCls)) {
        target = (T) client.stores().create(new Group(TARGET_NAME), "creating test target", Group.class);
    } else if (HostedRepository.class.equals(targetCls)) {
        HostedRepository hr = new HostedRepository(TARGET_NAME);
        hr.setAllowSnapshots(true);
        target = (T) client.stores().create(hr, "creating test target", HostedRepository.class);
    } else {
        throw new IllegalStateException(targetCls.getName() + " is not currently supported as promotion targets.");
    }
}
Also used : Group(org.commonjava.indy.model.core.Group) IndyPromoteClientModule(org.commonjava.indy.promote.client.IndyPromoteClientModule) HostedRepository(org.commonjava.indy.model.core.HostedRepository)

Example 65 with HostedRepository

use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.

the class AutoProxCalculationTest method jsonRoundTrip_HostedRepoCreation.

@Test
public void jsonRoundTrip_HostedRepoCreation() throws IOException {
    HostedRepository repo = new HostedRepository("test");
    AutoProxCalculation in = new AutoProxCalculation(repo, "test-rule.groovy");
    IndyObjectMapper mapper = new IndyObjectMapper(true);
    String json = mapper.writeValueAsString(in);
    AutoProxCalculation out = mapper.readValue(json, AutoProxCalculation.class);
    assertThat(out, notNullValue());
    assertThat(out.getRuleName(), equalTo(in.getRuleName()));
    assertThat(out.getStore(), equalTo(in.getStore()));
    assertThat(out, equalTo(in));
}
Also used : IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Test(org.junit.Test)

Aggregations

HostedRepository (org.commonjava.indy.model.core.HostedRepository)77 Test (org.junit.Test)47 Group (org.commonjava.indy.model.core.Group)44 ByteArrayInputStream (java.io.ByteArrayInputStream)37 Transfer (org.commonjava.maven.galley.model.Transfer)21 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)18 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)15 Before (org.junit.Before)15 InputStream (java.io.InputStream)13 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)11 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)11 IndyObjectMapper (org.commonjava.indy.model.core.io.IndyObjectMapper)10 AbstractContentManagementTest (org.commonjava.indy.ftest.core.AbstractContentManagementTest)9 PackageMetadata (org.commonjava.indy.pkg.npm.model.PackageMetadata)7 PathsPromoteRequest (org.commonjava.indy.promote.model.PathsPromoteRequest)7 PathsPromoteResult (org.commonjava.indy.promote.model.PathsPromoteResult)7 Metadata (org.apache.maven.artifact.repository.metadata.Metadata)6 Versioning (org.apache.maven.artifact.repository.metadata.Versioning)6 MetadataXpp3Reader (org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader)6 IndyDataException (org.commonjava.indy.data.IndyDataException)6