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();
}
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());
}
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();
}
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();
}
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());
}
Aggregations