Search in sources :

Example 21 with ExampleRepository

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

the class ExamplesServiceImplTest method testGetProjects_EmptyRepositoryUrl.

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

Example 22 with ExampleRepository

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

the class ExamplesServiceImplTest method testGetProjects_CustomDescription.

@Test
public void testGetProjects_CustomDescription() {
    final Path moduleRoot = mock(Path.class);
    final KieModule module = mock(KieModule.class);
    when(module.getRootPath()).thenReturn(moduleRoot);
    when(module.getModuleName()).thenReturn("module1");
    when(moduleRoot.toURI()).thenReturn("default:///module1");
    when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(true);
    when(ioService.readAllString(any(org.uberfire.java.nio.file.Path.class))).thenReturn("This is custom description.\n\n This is a new line.");
    when(metadataService.getTags(any(Path.class))).thenReturn(Arrays.asList("tag1", "tag2"));
    final GitRepository repository = makeGitRepository();
    when(repositoryFactory.newRepository(any(ConfigGroup.class))).thenReturn(repository);
    when(moduleService.getAllModules(any(Branch.class))).thenReturn(new HashSet<Module>() {

        {
            add(module);
        }
    });
    final Set<ExampleProject> modules = service.getProjects(new ExampleRepository("https://github.com/guvnorngtestuser1/guvnorng-playground.git"));
    assertNotNull(modules);
    assertEquals(1, modules.size());
    assertTrue(modules.contains(new ExampleProject(moduleRoot, "module1", "This is custom description. This is a new line.", Arrays.asList("tag1", "tag2"))));
}
Also used : Path(org.uberfire.backend.vfs.Path) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) Branch(org.guvnor.structure.repositories.Branch) ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) ConfigGroup(org.guvnor.structure.server.config.ConfigGroup) Module(org.guvnor.common.services.project.model.Module) KieModule(org.kie.workbench.common.services.shared.project.KieModule) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Test(org.junit.Test)

Example 23 with ExampleRepository

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

the class ExamplesServiceImplTest method resolveGitRepositoryClonedBefore.

@Test
public void resolveGitRepositoryClonedBefore() {
    ExampleRepository playgroundRepository = new ExampleRepository("file:///home/user/folder/.kie-wb-playground");
    service.setPlaygroundRepository(playgroundRepository);
    GitRepository repository = mock(GitRepository.class);
    Map<String, Object> repositoryEnvironment = new HashMap<>();
    repositoryEnvironment.put("origin", playgroundRepository.getUrl());
    when(repository.getEnvironment()).thenReturn(repositoryEnvironment);
    service.getClonedRepositories().add(repository);
    Repository result = service.resolveGitRepository(playgroundRepository);
    assertEquals(repository, result);
    verify(repositoryFactory, never()).newRepository(any(ConfigGroup.class));
}
Also used : GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) Repository(org.guvnor.structure.repositories.Repository) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) HashMap(java.util.HashMap) ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) ConfigGroup(org.guvnor.structure.server.config.ConfigGroup) Test(org.junit.Test)

Example 24 with ExampleRepository

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

the class ExamplesServiceImplTest method testGetProjects_WhiteSpaceRepositoryUrl.

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

Example 25 with ExampleRepository

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

the class ExamplesServiceImplTest method testGetProjects_DefaultDescription.

@Test
public void testGetProjects_DefaultDescription() {
    final Path moduleRoot = mock(Path.class);
    final KieModule module = mock(KieModule.class);
    when(module.getRootPath()).thenReturn(moduleRoot);
    when(module.getModuleName()).thenReturn("module1");
    when(moduleRoot.toURI()).thenReturn("default:///module1");
    when(metadataService.getTags(any(Path.class))).thenReturn(Arrays.asList("tag1", "tag2"));
    final GitRepository repository = makeGitRepository();
    when(repositoryFactory.newRepository(any(ConfigGroup.class))).thenReturn(repository);
    when(moduleService.getAllModules(any(Branch.class))).thenReturn(new HashSet<Module>() {

        {
            add(module);
        }
    });
    service.setPlaygroundRepository(mock(ExampleRepository.class));
    final Set<ExampleProject> modules = service.getProjects(new ExampleRepository("https://github.com/guvnorngtestuser1/guvnorng-playground.git"));
    assertNotNull(modules);
    assertEquals(1, modules.size());
    assertTrue(modules.contains(new ExampleProject(moduleRoot, "module1", "Example 'module1' module", Arrays.asList("tag1", "tag2"))));
}
Also used : Path(org.uberfire.backend.vfs.Path) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) Branch(org.guvnor.structure.repositories.Branch) ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) ConfigGroup(org.guvnor.structure.server.config.ConfigGroup) Module(org.guvnor.common.services.project.model.Module) KieModule(org.kie.workbench.common.services.shared.project.KieModule) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Test(org.junit.Test)

Aggregations

ExampleRepository (org.kie.workbench.common.screens.examples.model.ExampleRepository)27 Test (org.junit.Test)19 ExampleProject (org.kie.workbench.common.screens.examples.model.ExampleProject)11 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)6 ConfigGroup (org.guvnor.structure.server.config.ConfigGroup)6 Module (org.guvnor.common.services.project.model.Module)4 Branch (org.guvnor.structure.repositories.Branch)3 Repository (org.guvnor.structure.repositories.Repository)3 KieModule (org.kie.workbench.common.services.shared.project.KieModule)3 Path (org.uberfire.backend.vfs.Path)3 HashSet (java.util.HashSet)2 ConfigType (org.guvnor.structure.server.config.ConfigType)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 ZipEntry (java.util.zip.ZipEntry)1 ZipInputStream (java.util.zip.ZipInputStream)1 PostConstruct (javax.annotation.PostConstruct)1 Git (org.eclipse.jgit.api.Git)1