Search in sources :

Example 1 with ArtifactStorePreUpdateEvent

use of org.commonjava.indy.change.event.ArtifactStorePreUpdateEvent 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)

Example 2 with ArtifactStorePreUpdateEvent

use of org.commonjava.indy.change.event.ArtifactStorePreUpdateEvent in project indy by Commonjava.

the class ImpliedRepoMaintainerTest method addImpliedRepoWhenRepoAddedToGroup.

@Test
public void addImpliedRepoWhenRepoAddedToGroup() 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));
    g.addConstituent(repo1);
    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)

Example 3 with ArtifactStorePreUpdateEvent

use of org.commonjava.indy.change.event.ArtifactStorePreUpdateEvent in project indy by Commonjava.

the class DefaultStoreEventDispatcher method updating.

@Override
public void updating(final ArtifactStoreUpdateType type, final EventMetadata eventMetadata, final Map<ArtifactStore, ArtifactStore> changeMap) {
    //        logger.debug( "Trying to fire pre-update event for: {}", new JoinString( ", ", stores ) );
    if (updatePreEvent != null) {
        //            executor.execute( () -> {
        final ArtifactStorePreUpdateEvent event = new ArtifactStorePreUpdateEvent(type, eventMetadata, changeMap);
        //            logger.debug( "Firing pre-update event: {} (for: {}) via:\n  {}", event, new JoinString( ", ", stores ),
        //                          new JoinString( "\n  ", Thread.currentThread()
        //                                                        .getStackTrace() ) );
        updatePreEvent.fire(event);
    //            } );
    }
}
Also used : ArtifactStorePreUpdateEvent(org.commonjava.indy.change.event.ArtifactStorePreUpdateEvent)

Aggregations

ArtifactStorePreUpdateEvent (org.commonjava.indy.change.event.ArtifactStorePreUpdateEvent)3 Group (org.commonjava.indy.model.core.Group)2 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)2 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)2 Test (org.junit.Test)2