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