Search in sources :

Example 11 with ModuleRepositories

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

the class ValidationPresenterTest method testSetup.

@Test
public void testSetup() {
    final ProjectScreenModel model = mock(ProjectScreenModel.class);
    doReturn(new ModuleRepositories()).when(model).getRepositories();
    validationPresenter.setup(model).catch_(i -> {
        Assert.fail("Promise should've been resolved!");
        return promises.resolve();
    });
    verify(view).init(eq(validationPresenter));
    verify(validationItemPresenters).setup(any(), any(), any());
}
Also used : ModuleRepositories(org.guvnor.common.services.project.model.ModuleRepositories) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) Test(org.junit.Test)

Example 12 with ModuleRepositories

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

the class ValidationPresenterTest method testCurrentHashCode.

@Test
public void testCurrentHashCode() {
    final ProjectScreenModel model = mock(ProjectScreenModel.class);
    final ModuleRepositories repositories = new ModuleRepositories();
    doReturn(repositories).when(model).getRepositories();
    validationPresenter.setup(model);
    int currentHashCode = validationPresenter.currentHashCode();
    Assert.assertEquals(repositories.getRepositories().hashCode(), currentHashCode);
    repositories.getRepositories().add(mock(ModuleRepositories.ModuleRepository.class));
    int updatedHashCode = validationPresenter.currentHashCode();
    Assert.assertEquals(repositories.getRepositories().hashCode(), updatedHashCode);
}
Also used : ModuleRepositories(org.guvnor.common.services.project.model.ModuleRepositories) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) Test(org.junit.Test)

Example 13 with ModuleRepositories

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

the class PomEditorServiceImplTest method testSaveNonClashingGAVChangeToGAV.

@Test
public void testSaveNonClashingGAVChangeToGAV() {
    final Set<ModuleRepositories.ModuleRepository> moduleRepositoriesMetadata = new HashSet<ModuleRepositories.ModuleRepository>();
    final ModuleRepositories moduleRepositories = new ModuleRepositories(moduleRepositoriesMetadata);
    when(moduleRepositoriesService.load(moduleRepositoriesPath)).thenReturn(moduleRepositories);
    final ArgumentCaptor<MavenRepositoryMetadata> resolvedRepositoriesCaptor = ArgumentCaptor.forClass(MavenRepositoryMetadata.class);
    when(repositoryResolver.getRepositoriesResolvingArtifact(eq(pomXml), resolvedRepositoriesCaptor.capture())).thenReturn(Collections.EMPTY_SET);
    when(pom.getGav()).thenReturn(new GAV("groupId", "artifactId", "0.0.2"));
    service.save(pomPath, pomXml, metaData, comment, DeploymentMode.VALIDATED);
    verify(moduleService, times(1)).resolveModule(pomPath);
    verify(moduleRepositoriesService, times(1)).load(moduleRepositoriesPath);
    verify(repositoryResolver, times(1)).getRepositoriesResolvingArtifact(eq(pomXml));
    final List<MavenRepositoryMetadata> resolvedRepositories = resolvedRepositoriesCaptor.getAllValues();
    assertNotNull(resolvedRepositories);
    assertEquals(0, resolvedRepositories.size());
    verify(ioService, times(1)).startBatch(any(FileSystem.class));
    verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), eq(pomXml), eq(attributes), any(CommentedOption.class));
    verify(ioService, times(1)).endBatch();
}
Also used : Path(org.uberfire.backend.vfs.Path) ModuleRepositories(org.guvnor.common.services.project.model.ModuleRepositories) MavenRepositoryMetadata(org.guvnor.common.services.project.model.MavenRepositoryMetadata) CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) FileSystem(org.uberfire.java.nio.file.FileSystem) GAV(org.guvnor.common.services.project.model.GAV) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 14 with ModuleRepositories

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

the class PomEditorServiceImplTest method testSaveClashingGAVForced.

@Test
public void testSaveClashingGAVForced() {
    final Set<ModuleRepositories.ModuleRepository> moduleRepositoriesMetadata = new HashSet<ModuleRepositories.ModuleRepository>() {

        {
            add(new ModuleRepositories.ModuleRepository(true, new MavenRepositoryMetadata("local-id", "local-url", MavenRepositorySource.LOCAL)));
        }
    };
    final ModuleRepositories moduleRepositories = new ModuleRepositories(moduleRepositoriesMetadata);
    when(moduleRepositoriesService.load(moduleRepositoriesPath)).thenReturn(moduleRepositories);
    final Set<MavenRepositoryMetadata> clashingRepositories = new HashSet<MavenRepositoryMetadata>() {

        {
            add(new MavenRepositoryMetadata("local-id", "local-url", MavenRepositorySource.LOCAL));
        }
    };
    when(repositoryResolver.getRepositoriesResolvingArtifact(eq(pomXml), any(MavenRepositoryMetadata.class))).thenReturn(clashingRepositories);
    when(pom.getGav()).thenReturn(new GAV("groupId", "artifactId", "0.0.1"));
    try {
        service.save(pomPath, pomXml, metaData, comment, DeploymentMode.FORCED);
    } catch (GAVAlreadyExistsException e) {
        fail(e.getMessage());
    }
    verify(moduleService, never()).resolveModule(pomPath);
    verify(moduleRepositoriesService, never()).load(pomPath);
    verify(repositoryResolver, never()).getRepositoriesResolvingArtifact(eq(pomXml), any(MavenRepositoryMetadata.class));
    verify(ioService, times(1)).startBatch(any(FileSystem.class));
    verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), eq(pomXml), eq(attributes), any(CommentedOption.class));
    verify(ioService, times(1)).endBatch();
}
Also used : Path(org.uberfire.backend.vfs.Path) ModuleRepositories(org.guvnor.common.services.project.model.ModuleRepositories) GAVAlreadyExistsException(org.guvnor.common.services.project.service.GAVAlreadyExistsException) MavenRepositoryMetadata(org.guvnor.common.services.project.model.MavenRepositoryMetadata) CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) FileSystem(org.uberfire.java.nio.file.FileSystem) GAV(org.guvnor.common.services.project.model.GAV) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 15 with ModuleRepositories

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

the class ProjectScreenModelLoaderTest method testRepositories.

@Test
public void testRepositories() throws Exception {
    final ModuleRepositories moduleRepositories = new ModuleRepositories();
    when(moduleRepositoriesService.load(repositoriesPath)).thenReturn(moduleRepositories);
    ProjectScreenModel model = loader.load(pathToPom);
    assertEquals(repositoriesPath, model.getPathToRepositories());
    assertEquals(moduleRepositories, model.getRepositories());
}
Also used : ModuleRepositories(org.guvnor.common.services.project.model.ModuleRepositories) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) 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