Search in sources :

Example 16 with ExampleProject

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

the class ProjectPageTest method initExampleProjects.

private void initExampleProjects() {
    when(examplesService.getProjects(any(ExampleRepository.class))).thenReturn(new HashSet<ExampleProject>() {

        {
            add(project1);
            add(project2);
        }
    });
    final ExampleRepository repository = new ExampleRepository(EXAMPLE_REPOSITORY);
    model.setSelectedRepository(repository);
    page.prepareView();
    Mockito.reset(projectsView, pageSelectedEvent);
}
Also used : ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject)

Example 17 with ExampleProject

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

the class ProjectPageTest method testRemoveProject.

@Test
public void testRemoveProject() {
    final ExampleProject project = mock(ExampleProject.class);
    model.addProject(project);
    page.removeProject(project);
    assertEquals(0, model.getProjects().size());
    verify(pageStatusChangedEvent, times(1)).fire(any(WizardPageStatusChangeEvent.class));
}
Also used : WizardPageStatusChangeEvent(org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject) Test(org.junit.Test)

Example 18 with ExampleProject

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

the class ProjectPageTest method testPrepareView_NewRepositorySelected.

@Test
public void testPrepareView_NewRepositorySelected() {
    when(examplesService.getProjects(any(ExampleRepository.class))).thenReturn(new HashSet<ExampleProject>() {

        {
            add(project1);
            add(project2);
        }
    });
    final ExampleRepository repository = new ExampleRepository(EXAMPLE_REPOSITORY);
    model.setSelectedRepository(repository);
    page.prepareView();
    assertEquals(projectsViewWidget, page.asWidget());
    assertEquals(repository, model.getSourceRepository());
    assertTrue(model.getProjects().isEmpty());
    verify(projectsView, times(1)).setProjectsInRepository(projectsArgumentCaptor.capture());
    final List<ExampleProject> sortedProjects = projectsArgumentCaptor.getValue();
    assertNotNull(sortedProjects);
    assertEquals(2, sortedProjects.size());
    assertEquals("project1", sortedProjects.get(0).getName());
    assertEquals("project2", sortedProjects.get(1).getName());
    verify(pageSelectedEvent, times(1)).fire(any(WizardPageSelectedEvent.class));
}
Also used : ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) WizardPageSelectedEvent(org.uberfire.ext.widgets.core.client.wizards.WizardPageSelectedEvent) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject) Test(org.junit.Test)

Example 19 with ExampleProject

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

the class LibraryServiceImplTest method importProjectFromExampleTest.

@Test
public void importProjectFromExampleTest() {
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    final ExampleProject exampleProject = mock(ExampleProject.class);
    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());
}
Also used : 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 20 with ExampleProject

use of org.kie.workbench.common.screens.examples.model.ExampleProject 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<ExampleProject> exampleProjects = new HashSet<>();
    exampleProjects.add(mock(ExampleProject.class));
    doReturn(exampleProjects).when(examplesService).getProjects(playgroundRepository);
    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