Search in sources :

Example 41 with EventMetadata

use of org.commonjava.maven.galley.event.EventMetadata in project galley by Commonjava.

the class ArtifactManagerImplTest method resolveSnapshot_FirstMatch_SingletonLocationList_SingletonSnapshotList_LatestVersionStrategy.

@Test
public void resolveSnapshot_FirstMatch_SingletonLocationList_SingletonSnapshotList_LatestVersionStrategy() throws Exception {
    final String base = "single-snapshot/";
    final String testResource = base + "single-snapshot.xml";
    final String testPomResource = base + "single-snapshot-pom.xml";
    final ProjectVersionRef ref = new SimpleProjectVersionRef("org.group", "artifact", "1.0-SNAPSHOT");
    final ConcreteResource metadataResource = new ConcreteResource(LOCATION, fixture.snapshotMetadataPath(ref));
    final ConcreteResource pomResource = new ConcreteResource(LOCATION, fixture.pomPath(ref.selectVersion("1.0-20140604.101244-1").asPomArtifact()));
    fixture.getTransport().registerDownload(metadataResource, new TestDownload(ROOT + testResource));
    fixture.getTransport().registerDownload(pomResource, new TestDownload(ROOT + testPomResource));
    final Transfer retrieved = fixture.getArtifactManager().retrieve(LOCATION, ref.asPomArtifact(), new EventMetadata());
    final Document document = fixture.getXml().parse(retrieved, new EventMetadata());
    final ProjectVersionRef result = fixture.getXml().getProjectVersionRef(document);
    System.out.println(result);
//        assertThat( result, notNullValue() );
//        assertThat( result.getVersionString(), equalTo( "1.0-20140604.101244-1" ) );
}
Also used : TestDownload(org.commonjava.maven.galley.testing.core.transport.job.TestDownload) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) Transfer(org.commonjava.maven.galley.model.Transfer) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) Document(org.w3c.dom.Document) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Test(org.junit.Test)

Example 42 with EventMetadata

use of org.commonjava.maven.galley.event.EventMetadata in project galley by Commonjava.

the class VersionResolverImplTest method resolveSnapshot_FirstMatch_TwoLocationList_TwoSingletonSnapshotList_LatestVersionStrategy.

@Test
public void resolveSnapshot_FirstMatch_TwoLocationList_TwoSingletonSnapshotList_LatestVersionStrategy() throws Exception {
    final String testResource = "2-snapshots-2-locations/maven-metadata-1.xml";
    final String testResource2 = "2-snapshots-2-locations/maven-metadata-2.xml";
    final ProjectVersionRef ref = new SimpleProjectVersionRef("org.group2", "artifact", "1.0-SNAPSHOT");
    final String path = fixture.snapshotMetadataPath(ref);
    fixture.getTransport().registerDownload(new ConcreteResource(LOCATION, path), new TestDownload(ROOT + testResource));
    fixture.getTransport().registerDownload(new ConcreteResource(LOCATION2, path), new TestDownload(ROOT + testResource2));
    final ProjectVersionRef result = fixture.getVersionResolver().resolveFirstMatchVariableVersion(TWO_LOCATIONS, ref, LatestVersionSelectionStrategy.INSTANCE, new EventMetadata());
    assertThat(result, notNullValue());
    // newest snapshot is in the SECOND location, but we're using first-match semantics here.
    assertThat(result.getVersionString(), equalTo("1.0-20140604.101244-1"));
}
Also used : TestDownload(org.commonjava.maven.galley.testing.core.transport.job.TestDownload) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Test(org.junit.Test)

Example 43 with EventMetadata

use of org.commonjava.maven.galley.event.EventMetadata in project galley by Commonjava.

the class VersionResolverImplTest method resolveSnapshot_FirstMatch_SingletonLocationList_TwoSnapshotList_LatestVersionStrategy.

@Test
public void resolveSnapshot_FirstMatch_SingletonLocationList_TwoSnapshotList_LatestVersionStrategy() throws Exception {
    final String testResource = "2-snapshots-1-location/two-snapshots.xml";
    final ProjectVersionRef ref = new SimpleProjectVersionRef("org.group2", "artifact", "1.0-SNAPSHOT");
    final ConcreteResource cr = new ConcreteResource(LOCATION, fixture.snapshotMetadataPath(ref));
    final TestDownload download = new TestDownload(ROOT + testResource);
    fixture.getTransport().registerDownload(cr, download);
    final ProjectVersionRef result = fixture.getVersionResolver().resolveFirstMatchVariableVersion(ONE_LOCATION, ref, LatestVersionSelectionStrategy.INSTANCE, new EventMetadata());
    assertThat(result, notNullValue());
    assertThat(result.getVersionString(), equalTo("1.0-20140604.102909-1"));
}
Also used : TestDownload(org.commonjava.maven.galley.testing.core.transport.job.TestDownload) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Test(org.junit.Test)

Example 44 with EventMetadata

use of org.commonjava.maven.galley.event.EventMetadata in project galley by Commonjava.

the class VersionResolverImplTest method resolveSnapshot_Latest_TwoLocationList_TwoSingletonSnapshotList_LatestVersionStrategy.

@Test
public void resolveSnapshot_Latest_TwoLocationList_TwoSingletonSnapshotList_LatestVersionStrategy() throws Exception {
    final String testResource = "2-snapshots-2-locations/maven-metadata-1.xml";
    final String testResource2 = "2-snapshots-2-locations/maven-metadata-2.xml";
    final ProjectVersionRef ref = new SimpleProjectVersionRef("org.group2", "artifact", "1.0-SNAPSHOT");
    final String path = fixture.snapshotMetadataPath(ref);
    fixture.getTransport().registerDownload(new ConcreteResource(LOCATION, path), new TestDownload(ROOT + testResource));
    fixture.getTransport().registerDownload(new ConcreteResource(LOCATION2, path), new TestDownload(ROOT + testResource2));
    final ProjectVersionRef result = fixture.getVersionResolver().resolveLatestVariableVersion(TWO_LOCATIONS, ref, LatestVersionSelectionStrategy.INSTANCE, new EventMetadata());
    assertThat(result, notNullValue());
    // newest snapshot is in the SECOND location.
    assertThat(result.getVersionString(), equalTo("1.0-20140604.102909-1"));
}
Also used : TestDownload(org.commonjava.maven.galley.testing.core.transport.job.TestDownload) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Test(org.junit.Test)

Example 45 with EventMetadata

use of org.commonjava.maven.galley.event.EventMetadata in project indy by Commonjava.

the class ImpliedRepoMaintainerTest method dontRemoveImpliedRepoWhenRepoRemovedFromGroup.

@Test
public void dontRemoveImpliedRepoWhenRepoRemovedFromGroup() throws Exception {
    final Group g = new Group(MAVEN_PKG_KEY, "test");
    storeDataManager.storeArtifactStore(g, summary, false, true, new EventMetadata());
    final RemoteRepository repo1 = new RemoteRepository(MAVEN_PKG_KEY, "one", "http://www.foo.com/repo");
    storeDataManager.storeArtifactStore(repo1, summary, false, true, new EventMetadata());
    final RemoteRepository repo2 = new RemoteRepository(MAVEN_PKG_KEY, "one", "http://www.foo.com/repo");
    storeDataManager.storeArtifactStore(repo2, summary, false, true, new EventMetadata());
    metadataManager.addImpliedMetadata(repo1, Collections.singletonList(repo2));
    // Simulates removal of repo1...odd, I know, but since they post-process these updates, it's what the 
    // event observers would see.
    g.addConstituent(repo2);
    final ArtifactStorePreUpdateEvent event = new ArtifactStorePreUpdateEvent(ArtifactStoreUpdateType.UPDATE, new EventMetadata(), Collections.singletonMap(g.copyOf(), g));
    maintainer.updateImpliedStores(event);
    assertThat(g.getConstituents().contains(repo2.getKey()), equalTo(true));
}
Also used : Group(org.commonjava.indy.model.core.Group) ArtifactStorePreUpdateEvent(org.commonjava.indy.change.event.ArtifactStorePreUpdateEvent) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Test(org.junit.Test)

Aggregations

EventMetadata (org.commonjava.maven.galley.event.EventMetadata)95 Transfer (org.commonjava.maven.galley.model.Transfer)38 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)37 Test (org.junit.Test)37 IndyDataException (org.commonjava.indy.data.IndyDataException)27 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)27 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)20 StoreKey (org.commonjava.indy.model.core.StoreKey)18 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)17 Group (org.commonjava.indy.model.core.Group)17 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)15 Logger (org.slf4j.Logger)15 IOException (java.io.IOException)13 Inject (javax.inject.Inject)11 ApiOperation (io.swagger.annotations.ApiOperation)10 ApiResponses (io.swagger.annotations.ApiResponses)10 InputStream (java.io.InputStream)10 ArrayList (java.util.ArrayList)10 Path (javax.ws.rs.Path)10 SimpleProjectVersionRef (org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef)9