Search in sources :

Example 36 with ImportProject

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

the class BranchSelectorPopUpPresenterTest method setupTest.

@Test
public void setupTest() {
    final ImportProject importProject = mock(ImportProject.class);
    final List<String> branches = Arrays.asList("master", "branch1");
    doReturn(branches).when(importProject).getSelectedBranches();
    final HTMLElement branchSelectorContainer = mock(HTMLElement.class);
    doReturn(branchSelectorContainer).when(view).getBranchSelectorContainer();
    presenter.setup(importProject, b -> {
    });
    verify(view).init(presenter);
    verify(branchSelector).setup(same(branchSelectorContainer), any(), eq(Arrays.asList("branch1", "master")), any());
    verify(view).show();
}
Also used : HTMLElement(elemental2.dom.HTMLElement) ImportProject(org.kie.workbench.common.screens.examples.model.ImportProject) Test(org.junit.Test)

Example 37 with ImportProject

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

the class ImportPresenter method ok.

public void ok() {
    final List<ImportProject> projects = projectWidgetsByProject.entrySet().stream().filter(p -> p.getValue().isSelected()).map(Map.Entry::getKey).collect(Collectors.toList());
    if (projects.isEmpty()) {
        notificationEvent.fire(new NotificationEvent(view.getNoProjectsSelectedMessage(), NotificationEvent.NotificationType.ERROR));
        return;
    }
    view.showBusyIndicator(view.getImportingMessage());
    importProjects(projects, event -> {
        view.hideBusyIndicator();
        notificationEvent.fire(new NotificationEvent(view.getImportProjectsSuccessMessage(), NotificationEvent.NotificationType.SUCCESS));
        projectContextChangeEvent.fire(event);
        // In this case we've imported multiple projects, so just go to the space screen.
        if (event.getWorkspaceProject() == null) {
            libraryPlaces.goToLibrary();
        }
    }, new HasBusyIndicatorDefaultErrorCallback(view));
}
Also used : ImportProject(org.kie.workbench.common.screens.examples.model.ImportProject) HasBusyIndicatorDefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) HashMap(java.util.HashMap) Map(java.util.Map)

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