Search in sources :

Example 11 with ExampleProject

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

the class ProjectPageTest method testIsProjectSelected_NotSelected.

@Test
public void testIsProjectSelected_NotSelected() {
    final ExampleProject project = mock(ExampleProject.class);
    assertFalse(page.isProjectSelected(project));
}
Also used : ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject) Test(org.junit.Test)

Example 12 with ExampleProject

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

the class LibraryServiceImpl method importProject.

@Override
public WorkspaceProject importProject(final OrganizationalUnit organizationalUnit, final ExampleProject exampleProject) {
    final ExampleOrganizationalUnit exampleOrganizationalUnit = new ExampleOrganizationalUnit(organizationalUnit.getName());
    final List<ExampleProject> exampleProjects = Collections.singletonList(exampleProject);
    final WorkspaceProjectContextChangeEvent projectContextChangeEvent = examplesService.setupExamples(exampleOrganizationalUnit, exampleProjects);
    return projectContextChangeEvent.getWorkspaceProject();
}
Also used : ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject)

Example 13 with ExampleProject

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

the class LibraryServiceImpl method getExampleProjects.

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

Example 14 with ExampleProject

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

the class LibraryServiceImplTest method importDefaultProjectTest.

@Test
public void importDefaultProjectTest() {
    final Repository repository = mock(Repository.class);
    when(repository.getAlias()).thenReturn("example");
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    when(organizationalUnit.getName()).thenReturn("ou");
    when(organizationalUnit.getIdentifier()).thenReturn("ou");
    when(organizationalUnit.getRepositories()).thenReturn(singletonList(repository));
    when(ouService.getOrganizationalUnits()).thenReturn(singletonList(organizationalUnit));
    final ExampleProject exampleProject = mock(ExampleProject.class);
    doReturn("example").when(exampleProject).getName();
    final WorkspaceProject project = mock(WorkspaceProject.class);
    final Module module = mock(Module.class);
    doReturn(module).when(project).getMainModule();
    final WorkspaceProjectContextChangeEvent projectContextChangeEvent = mock(WorkspaceProjectContextChangeEvent.class);
    doReturn(project).when(projectContextChangeEvent).getWorkspaceProject();
    doReturn(projectContextChangeEvent).when(examplesService).setupExamples(any(ExampleOrganizationalUnit.class), anyList());
    final WorkspaceProject importedProject = libraryService.importProject(organizationalUnit, exampleProject);
    assertEquals(module, importedProject.getMainModule());
    verify(examplesService).setupExamples(new ExampleOrganizationalUnit(organizationalUnit.getName()), singletonList(exampleProject));
}
Also used : ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) Repository(org.guvnor.structure.repositories.Repository) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) Module(org.guvnor.common.services.project.model.Module) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject) Test(org.junit.Test)

Example 15 with ExampleProject

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

the class LibraryServiceImplTest method getCustomExampleProjectsTest.

@Test
public void getCustomExampleProjectsTest() {
    System.setProperty("org.kie.project.examples.repository.url", "importProjectsUrl");
    final Set<ExampleProject> exampleProjects = new HashSet<>();
    exampleProjects.add(mock(ExampleProject.class));
    doReturn(exampleProjects).when(examplesService).getProjects(new ExampleRepository("importProjectsUrl"));
    final Set<ExampleProject> loadedExampleProjects = libraryService.getExampleProjects();
    assertEquals(exampleProjects, loadedExampleProjects);
}
Also used : ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject) HashSet(java.util.HashSet) 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