Search in sources :

Example 1 with ImportProject

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

the class LibraryPlacesTest method goToExternalImportProjectsTest.

@Test
public void goToExternalImportProjectsTest() {
    doAnswer(inv -> {
        final Command command = inv.getArgument(0, Command.class);
        command.execute();
        return null;
    }).when(libraryPlaces).closeAllPlacesOrNothing(any());
    final PlaceRequest trySamplesScreen = new DefaultPlaceRequest(LibraryPlaces.IMPORT_PROJECTS_SCREEN);
    final PartDefinitionImpl part = new PartDefinitionImpl(trySamplesScreen);
    part.setSelectable(false);
    final Set<ImportProject> projects = singleton(new ImportProject(PathFactory.newPath("example", "default://main@system/repo/example"), "example", "description", "git@git.com", emptyList()));
    libraryPlaces.goToExternalImportPresenter(projects);
    verify(placeManager).goTo(eq(part), Mockito.<PanelDefinition>any());
    verify(libraryPlaces).setupExternalImportBreadCrumbs();
}
Also used : PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest) PlaceRequest(org.uberfire.mvp.PlaceRequest) PartDefinitionImpl(org.uberfire.workbench.model.impl.PartDefinitionImpl) Command(org.uberfire.mvp.Command) ImportProject(org.kie.workbench.common.screens.examples.model.ImportProject) DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest) Test(org.junit.Test)

Example 2 with ImportProject

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

the class ImportRepositoryPopUpPresenter method importRepository.

public void importRepository() {
    final String repositoryUrl = view.getRepositoryURL();
    if (isEmpty(repositoryUrl)) {
        view.showError(view.getEmptyRepositoryURLValidationMessage());
        return;
    }
    final String fixedRepositoryUrl = repositoryUrl.trim();
    view.showBusyIndicator(view.getLoadingMessage());
    importService.call((Set<ImportProject> projects) -> {
        view.hideBusyIndicator();
        if (projects.isEmpty()) {
            view.showError(view.getNoProjectsToImportMessage());
        } else {
            view.hide();
            libraryPlaces.goToExternalImportPresenter(projects);
        }
    }, (Message message, Throwable throwable) -> {
        if (throwable instanceof EmptyRemoteRepositoryException) {
            final String repositoryAlias = ((EmptyRemoteRepositoryException) throwable).getRepositoryAlias();
            createProjectFromEmptyRemoteRepository(fixedRepositoryUrl, repositoryAlias);
        } else {
            view.hideBusyIndicator();
            view.showError(view.getNoProjectsToImportMessage());
        }
        return false;
    }).getProjects(this.libraryPlaces.getActiveSpace(), new ExampleRepository(fixedRepositoryUrl, new Credentials(view.getUserName(), view.getPassword())));
}
Also used : Message(org.jboss.errai.bus.client.api.messaging.Message) ImportProject(org.kie.workbench.common.screens.examples.model.ImportProject) ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) EmptyRemoteRepositoryException(org.kie.workbench.common.screens.examples.exception.EmptyRemoteRepositoryException) Credentials(org.kie.workbench.common.screens.examples.model.Credentials)

Example 3 with ImportProject

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

the class ExampleImportPresenterTest method selectProjectWithMultipleProjectSelectionEnabledTest.

@Test
public void selectProjectWithMultipleProjectSelectionEnabledTest() {
    final Set<ImportProject> importProjects = getImportProjects();
    importPresenter.setupProjects(importProjects);
    importPresenter.setMultipleProjectSelectionEnabled(true);
    final List<ImportProject> importProjectsList = new ArrayList<>(importProjects);
    final ImportProject project1 = importProjectsList.get(0);
    final ExampleProjectWidget project1Widget = importPresenter.getProjectWidgetsByProject().get(project1);
    final ImportProject project2 = importProjectsList.get(1);
    final ExampleProjectWidget project2Widget = importPresenter.getProjectWidgetsByProject().get(project2);
    final ImportProject project3 = importProjectsList.get(2);
    final ExampleProjectWidget project3Widget = importPresenter.getProjectWidgetsByProject().get(project3);
    importPresenter.selectProject(project1Widget);
    verify(project1Widget).select();
    verify(project1Widget, never()).unselect();
    verify(project2Widget, never()).select();
    verify(project2Widget, never()).unselect();
    verify(project3Widget, never()).select();
    verify(project3Widget, never()).unselect();
}
Also used : ImportProject(org.kie.workbench.common.screens.examples.model.ImportProject) ArrayList(java.util.ArrayList) ExampleProjectWidget(org.kie.workbench.common.screens.library.client.widgets.example.ExampleProjectWidget) Test(org.junit.Test)

Example 4 with ImportProject

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

the class ProjectImportServiceImplRepositoryNamesTest method nameIsTaken.

@Test
public void nameIsTaken() {
    String module1 = "module1";
    String module1_1 = "module1 [1]";
    doCallRealMethod().when(service).importProject(any(), any());
    doReturn(mock(org.uberfire.java.nio.file.Path.class)).when(service).getProjectRoot(any(ImportProject.class));
    doReturn(mock(org.uberfire.java.nio.file.Path.class)).when(pathUtil).convert(any(Path.class));
    WorkspaceProject project1 = mock(WorkspaceProject.class, Answers.RETURNS_DEEP_STUBS.get());
    doReturn(module1).when(project1).getName();
    when(project1.getMainModule().getPomXMLPath()).thenReturn(mock(Path.class));
    List<WorkspaceProject> projects = new ArrayList<>();
    projects.add(project1);
    projects.add(project1);
    doReturn(projects).when(projectService).getAllWorkspaceProjectsByName(any(), eq(module1));
    doReturn(module1_1).when(projectService).createFreshProjectName(any(), eq(module1));
    try {
        service.importProjects(organizationalUnit, importProjects);
        fail("An exception should be rise");
    } catch (ProjectAlreadyExistException ex) {
        assertNotNull(ex);
        System.out.println(ex.getMessage());
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) ProjectAlreadyExistException(org.kie.workbench.common.screens.examples.exception.ProjectAlreadyExistException) ImportProject(org.kie.workbench.common.screens.examples.model.ImportProject) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 5 with ImportProject

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

the class ProjectImportServiceImplTest method testGetProjects_NullRepositoryUrl.

@Test
public void testGetProjects_NullRepositoryUrl() {
    final Set<ImportProject> modules = service.getProjects(organizationalUnit, 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