Search in sources :

Example 26 with ExampleProject

use of org.kie.workbench.common.screens.examples.model.ExampleProject 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)

Example 27 with ExampleProject

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

the class ExamplesServiceImplTest method testGetProjects_NullRepositoryUrl.

@Test
public void testGetProjects_NullRepositoryUrl() {
    final Set<ExampleProject> modules = service.getProjects(new ExampleRepository(null));
    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)

Aggregations

ExampleProject (org.kie.workbench.common.screens.examples.model.ExampleProject)27 Test (org.junit.Test)18 ExampleRepository (org.kie.workbench.common.screens.examples.model.ExampleRepository)14 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)8 ExampleOrganizationalUnit (org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit)7 WorkspaceProjectContextChangeEvent (org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)6 Module (org.guvnor.common.services.project.model.Module)6 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)6 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)6 Branch (org.guvnor.structure.repositories.Branch)6 Path (org.uberfire.backend.vfs.Path)6 HashSet (java.util.HashSet)5 ConfigGroup (org.guvnor.structure.server.config.ConfigGroup)4 ArrayList (java.util.ArrayList)3 NewProjectEvent (org.guvnor.common.services.project.events.NewProjectEvent)3 KieModule (org.kie.workbench.common.services.shared.project.KieModule)3 WizardPageSelectedEvent (org.uberfire.ext.widgets.core.client.wizards.WizardPageSelectedEvent)3 HashMap (java.util.HashMap)2 Set (java.util.Set)2 POM (org.guvnor.common.services.project.model.POM)2