Search in sources :

Example 16 with ImportProject

use of org.kie.workbench.common.screens.examples.model.ImportProject in project kie-wb-common by kiegroup.

the class LibraryServiceImpl method getExampleProjects.

@Override
public Set<ImportProject> getExampleProjects(OrganizationalUnit organizationalUnit) {
    final String importProjectsUrl = getCustomImportProjectsUrl();
    final ExampleRepository repository = importProjectsUrl == null || importProjectsUrl.isEmpty() ? examplesService.getPlaygroundRepository() : new ExampleRepository(importProjectsUrl);
    final Set<ImportProject> projects = examplesService.getProjects(organizationalUnit, repository);
    return projects;
}
Also used : ImportProject(org.kie.workbench.common.screens.examples.model.ImportProject) ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository)

Example 17 with ImportProject

use of org.kie.workbench.common.screens.examples.model.ImportProject in project kie-wb-common by kiegroup.

the class LibraryServiceImplTest method getDefaultExampleProjectsTest.

@Test
public void getDefaultExampleProjectsTest() {
    System.setProperty("org.kie.project.examples.repository.url", "");
    final ExampleRepository playgroundRepository = new ExampleRepository("playgroundRepositoryUrl");
    doReturn(playgroundRepository).when(examplesService).getPlaygroundRepository();
    final Set<ImportProject> importProjects = new HashSet<>();
    importProjects.add(mock(ImportProject.class));
    doReturn(importProjects).when(examplesService).getProjects(any(), eq(playgroundRepository));
    final Set<ImportProject> loadedImportProjects = libraryService.getExampleProjects(ou1);
    assertEquals(importProjects, loadedImportProjects);
}
Also used : ImportProject(org.kie.workbench.common.screens.examples.model.ImportProject) ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 18 with ImportProject

use of org.kie.workbench.common.screens.examples.model.ImportProject in project kie-wb-common by kiegroup.

the class ExamplesServiceImplTest method testGetProjects_EmptyRepositoryUrl.

@Test
public void testGetProjects_EmptyRepositoryUrl() {
    final Set<ImportProject> modules = service.getProjects(ou, new ExampleRepository(""));
    assertNotNull(modules);
    assertEquals(0, modules.size());
}
Also used : ImportProject(org.kie.workbench.common.screens.examples.model.ImportProject) ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) Test(org.junit.Test)

Example 19 with ImportProject

use of org.kie.workbench.common.screens.examples.model.ImportProject in project kie-wb-common by kiegroup.

the class ExamplesServiceImplTest method testGetProjects_WhiteSpaceRepositoryUrl.

@Test
public void testGetProjects_WhiteSpaceRepositoryUrl() {
    final Set<ImportProject> modules = service.getProjects(ou, new ExampleRepository("   "));
    assertNotNull(modules);
    assertEquals(0, modules.size());
}
Also used : ImportProject(org.kie.workbench.common.screens.examples.model.ImportProject) ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) Test(org.junit.Test)

Example 20 with ImportProject

use of org.kie.workbench.common.screens.examples.model.ImportProject in project kie-wb-common by kiegroup.

the class ExamplesServiceImplTest method testGetProjects_NullRepositoryUrl.

@Test
public void testGetProjects_NullRepositoryUrl() {
    final Set<ImportProject> modules = service.getProjects(ou, new ExampleRepository(null));
    assertNotNull(modules);
    assertEquals(0, modules.size());
}
Also used : ImportProject(org.kie.workbench.common.screens.examples.model.ImportProject) ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) Test(org.junit.Test)

Aggregations

ImportProject (org.kie.workbench.common.screens.examples.model.ImportProject)37 Test (org.junit.Test)30 ExampleRepository (org.kie.workbench.common.screens.examples.model.ExampleRepository)22 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)17 Path (org.uberfire.backend.vfs.Path)17 ImportUtils.makeGitRepository (org.kie.workbench.common.screens.examples.backend.server.ImportUtils.makeGitRepository)14 Module (org.guvnor.common.services.project.model.Module)11 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)11 KieModule (org.kie.workbench.common.services.shared.project.KieModule)10 Mockito.anyString (org.mockito.Mockito.anyString)10 Branch (org.guvnor.structure.repositories.Branch)8 Repository (org.guvnor.structure.repositories.Repository)7 RepositoryEnvironmentConfigurations (org.guvnor.structure.repositories.RepositoryEnvironmentConfigurations)7 JGitFileSystem (org.uberfire.java.nio.fs.jgit.JGitFileSystem)7 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)5 FileSystem (org.uberfire.java.nio.file.FileSystem)5 ArrayList (java.util.ArrayList)4 WorkspaceProjectContextChangeEvent (org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)4 POM (org.guvnor.common.services.project.model.POM)4 Credentials (org.kie.workbench.common.screens.examples.model.Credentials)4