Search in sources :

Example 1 with ExampleProjectWidget

use of org.kie.workbench.common.screens.library.client.widgets.example.ExampleProjectWidget 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 2 with ExampleProjectWidget

use of org.kie.workbench.common.screens.library.client.widgets.example.ExampleProjectWidget in project kie-wb-common by kiegroup.

the class ExampleImportPresenterTest method filterProjectsTest.

@Test
public void filterProjectsTest() {
    doReturn(false).when(libraryService).isClustered();
    doAnswer(invocationOnMock -> {
        invocationOnMock.getArgument(0, ParameterizedCommand.class).execute(importProjectsPreferences);
        return null;
    }).when(importProjectsPreferences).load(any(ParameterizedCommand.class), any(ParameterizedCommand.class));
    Set<ImportProject> projects = getImportProjects();
    doReturn(projects).when(examplesService).getExampleProjects(any());
    Map<String, String> params = new HashMap<>();
    params.put("repositoryUrl", "repoUrl");
    importPresenter.onStartup(new DefaultPlaceRequest(LibraryPlaces.PROJECT_SCREEN, params));
    final List<ExampleProjectWidget> filteredProjects = importPresenter.filterProjects("a");
    assertEquals(2, filteredProjects.size());
}
Also used : ImportProject(org.kie.workbench.common.screens.examples.model.ImportProject) HashMap(java.util.HashMap) DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) ExampleProjectWidget(org.kie.workbench.common.screens.library.client.widgets.example.ExampleProjectWidget) Test(org.junit.Test)

Example 3 with ExampleProjectWidget

use of org.kie.workbench.common.screens.library.client.widgets.example.ExampleProjectWidget in project kie-wb-common by kiegroup.

the class ExampleImportPresenterTest method selectProjectWithMultipleProjectSelectionDisabledTest.

@Test
public void selectProjectWithMultipleProjectSelectionDisabledTest() {
    final Set<ImportProject> importProjects = getImportProjects();
    importPresenter.setupProjects(importProjects);
    importPresenter.setMultipleProjectSelectionEnabled(false);
    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).unselect();
    verify(project3Widget, never()).select();
    verify(project3Widget).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 ExampleProjectWidget

use of org.kie.workbench.common.screens.library.client.widgets.example.ExampleProjectWidget in project kie-wb-common by kiegroup.

the class ExampleImportPresenterTest method setup.

@Before
public void setup() {
    libraryServiceCaller = new CallerMock<>(libraryService);
    examplesServiceCaller = new CallerMock<>(examplesService);
    tileWidget = spy(new ExampleProjectWidget(mock(ExampleProjectWidget.View.class), exampleProjectOkPresenter, exampleProjectErrorPresenter, branchSelectorPopUpPresenter));
    doReturn("space1").when(organizationalUnit).getName();
    doReturn(tileWidget).when(tileWidgets).get();
    doAnswer(invocationOnMock -> spy(new ExampleProjectWidget(mock(ExampleProjectWidget.View.class), exampleProjectOkPresenter, exampleProjectErrorPresenter, branchSelectorPopUpPresenter))).when(tileWidgets).get();
    importPresenter = spy(new ExamplesImportPresenter(view, libraryPlaces, tileWidgets, examplesServiceCaller, mock(WorkspaceProjectContext.class), notificationEvent, projectContextChangeEvent, new Elemental2DomUtil(), mock(TranslationService.class), importProjectsPreferences, libraryServiceCaller));
    doReturn(organizationalUnit).when(importPresenter).activeOrganizationalUnit();
}
Also used : TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) Elemental2DomUtil(org.jboss.errai.common.client.dom.elemental2.Elemental2DomUtil) WorkspaceProjectContext(org.guvnor.common.services.project.client.context.WorkspaceProjectContext) ExampleProjectWidget(org.kie.workbench.common.screens.library.client.widgets.example.ExampleProjectWidget) Before(org.junit.Before)

Example 5 with ExampleProjectWidget

use of org.kie.workbench.common.screens.library.client.widgets.example.ExampleProjectWidget in project kie-wb-common by kiegroup.

the class ImportPresenter method setupProjects.

public void setupProjects(final Set<ImportProject> projects) {
    if (projects == null || projects.isEmpty()) {
        showNoProjects();
        return;
    }
    projectWidgetsByProject = new HashMap<>();
    projects.forEach(project -> {
        ExampleProjectWidget projectWidget = createProjectWidget(project);
        projectWidgetsByProject.put(project, projectWidget);
    });
    updateView(projectWidgetsByProject.values());
}
Also used : ExampleProjectWidget(org.kie.workbench.common.screens.library.client.widgets.example.ExampleProjectWidget)

Aggregations

ExampleProjectWidget (org.kie.workbench.common.screens.library.client.widgets.example.ExampleProjectWidget)6 Test (org.junit.Test)3 ImportProject (org.kie.workbench.common.screens.examples.model.ImportProject)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)1 WorkspaceProjectContext (org.guvnor.common.services.project.client.context.WorkspaceProjectContext)1 Elemental2DomUtil (org.jboss.errai.common.client.dom.elemental2.Elemental2DomUtil)1 TranslationService (org.jboss.errai.ui.client.local.spi.TranslationService)1 Before (org.junit.Before)1 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)1 DefaultPlaceRequest (org.uberfire.mvp.impl.DefaultPlaceRequest)1