@Test public void importEmptyRepositoryOnSuccessTest() { final String repositoryUrl = "repoUrl"; final String repositoryAlias = "myRepository"; final OrganizationalUnit orgUnit = mock(OrganizationalUnit.class); doThrow(new EmptyRemoteRepositoryException(repositoryAlias)).when(importService).getProjects(any(), any()); doReturn(repositoryUrl).when(view).getRepositoryURL(); doReturn(Optional.of(orgUnit)).when(projectContext).getActiveOrganizationalUnit(); presenter.importRepository(); verify(libraryService).createProject(orgUnit, repositoryUrl, repositoryAlias); verify(view, never()).showError(anyString()); verify(view).hideBusyIndicator(); verify(view).hide(); verify(notificationEvent).fire(any(NotificationEvent.class)); verify(libraryPlaces).goToProject(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();  }