@Test public void importRepositoryTest() { String repoUrl = "repoUrl"; doReturn(repoUrl).when(view).getRepositoryURL(); when(importService.getProjects(any(), any())).thenReturn(singleton(mock(ImportProject.class))); presenter.importRepository(); verify(view).hideBusyIndicator(); verify(view).hide(); verify(libraryPlaces).goToExternalImportPresenter(any()); }
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()))); }
ImportRepositoryPopUpPresenter { 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()))); } }
ImportRepositoryPopUpPresenter { 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()))); } @Inject  ImportRepositoryPopUpPresenter(final View view,
                                          final LibraryPlaces libraryPlaces,
                                          final Caller<ProjectImportService> importService,
                                          final Caller<LibraryService> libraryService,
                                          final WorkspaceProjectContext projectContext,
                                          final Event<NotificationEvent> notificationEvent,
                                          final TranslationService ts); }
ImportRepositoryPopUpPresenter { 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()))); } @Inject  ImportRepositoryPopUpPresenter(final View view,
                                          final LibraryPlaces libraryPlaces,
                                          final Caller<ProjectImportService> importService,
                                          final Caller<LibraryService> libraryService,
                                          final WorkspaceProjectContext projectContext,
                                          final Event<NotificationEvent> notificationEvent,
                                          final TranslationService ts); @PostConstruct void setup(); void show(); void importRepository(); void cancel(); View getView(); }
ImportRepositoryPopUpPresenter { 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()))); } @Inject  ImportRepositoryPopUpPresenter(final View view,
                                          final LibraryPlaces libraryPlaces,
                                          final Caller<ProjectImportService> importService,
                                          final Caller<LibraryService> libraryService,
                                          final WorkspaceProjectContext projectContext,
                                          final Event<NotificationEvent> notificationEvent,
                                          final TranslationService ts); @PostConstruct void setup(); void show(); void importRepository(); void cancel(); View getView();  }