Search in sources :

Example 21 with ModuleRepositories

use of org.guvnor.common.services.project.model.ModuleRepositories in project kie-wb-common by kiegroup.

the class ModuleRepositoriesSynchronizerTest method testRemoveModuleRepository.

@Test
public void testRemoveModuleRepository() {
    final ResourceUpdatedEvent event = new ResourceUpdatedEvent(pomPath, "", sessionInfo);
    final Set<ModuleRepositories.ModuleRepository> repositories = new HashSet<ModuleRepositories.ModuleRepository>() {

        {
            add(new ModuleRepositories.ModuleRepository(true, new MavenRepositoryMetadata("local-id", "local-url", MavenRepositorySource.LOCAL)));
        }
    };
    final ModuleRepositories moduleRepositories = new ModuleRepositories(repositories);
    when(moduleRepositoriesService.load(moduleRepositoriesPath)).thenReturn(moduleRepositories);
    synchronizer.onResourceUpdated(event);
    final ArgumentCaptor<ModuleRepositories> moduleRepositoriesArgumentCaptor = ArgumentCaptor.forClass(ModuleRepositories.class);
    verify(moduleRepositoriesService, times(1)).save(eq(moduleRepositoriesPath), moduleRepositoriesArgumentCaptor.capture(), any(String.class));
    final ModuleRepositories saved = moduleRepositoriesArgumentCaptor.getValue();
    assertNotNull(saved);
    assertEquals(0, saved.getRepositories().size());
}
Also used : ModuleRepositories(org.guvnor.common.services.project.model.ModuleRepositories) MavenRepositoryMetadata(org.guvnor.common.services.project.model.MavenRepositoryMetadata) ResourceUpdatedEvent(org.uberfire.workbench.events.ResourceUpdatedEvent) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

ModuleRepositories (org.guvnor.common.services.project.model.ModuleRepositories)21 MavenRepositoryMetadata (org.guvnor.common.services.project.model.MavenRepositoryMetadata)16 Test (org.junit.Test)16 GAVAlreadyExistsException (org.guvnor.common.services.project.service.GAVAlreadyExistsException)10 ProjectScreenModel (org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel)9 GAV (org.guvnor.common.services.project.model.GAV)8 HashSet (java.util.HashSet)7 Path (org.uberfire.backend.vfs.Path)6 CommentedOption (org.uberfire.java.nio.base.options.CommentedOption)6 FileSystem (org.uberfire.java.nio.file.FileSystem)6 POM (org.guvnor.common.services.project.model.POM)3 KieModule (org.kie.workbench.common.services.shared.project.KieModule)3 ResourceUpdatedEvent (org.uberfire.workbench.events.ResourceUpdatedEvent)3 IOException (java.io.IOException)1 XmlPullParserException (org.codehaus.plexus.util.xml.pull.XmlPullParserException)1 ProjectImports (org.guvnor.common.services.project.model.ProjectImports)1 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)1 Before (org.junit.Before)1 Path (org.uberfire.java.nio.file.Path)1