GithubImporterPagePresenter extends AbstractWizardPage<ImportProject> implements GithubImporterPageView.ActionDelegate { @Override public void projectUrlChanged(@NotNull String url) { dataObject.getSource().getProject().setLocation(url); isGitUrlCorrect(url); String projectName = view.getProjectName(); if (projectName.isEmpty()) { projectName = extractProjectNameFromUri(url); dataObject.getProject().setName(projectName); view.setProjectName(projectName); validateProjectName(); } updateDelegate.updateControls(); } @Inject  GithubImporterPagePresenter(GithubImporterPageView view,
                                       GitHubAuthenticator gitHubAuthenticator,
                                       NotificationManager notificationManager,
                                       GitHubClientService gitHubClientService,
                                       DtoFactory dtoFactory,
                                       GitHubLocalizationConstant locale); @Override boolean isCompleted(); @Override void projectNameChanged(@NotNull String name); @Override void projectUrlChanged(@NotNull String url); @Override void recursiveSelected(boolean recursiveSelected); @Override void projectDescriptionChanged(@NotNull String projectDescription); @Override void projectVisibilityChanged(boolean visible); @Override void keepDirectorySelected(boolean keepDirectory); @Override void keepDirectoryNameChanged(@NotNull String directoryName); @Override void go(@NotNull AcceptsOneWidget container); @Override void onLoadRepoClicked(); @Override void onRepositorySelected(@NotNull ProjectData repository); @Override void onAccountChanged();  }
@Test public void projectUrlStartWithWhiteSpaceEnteredTest() { String incorrectUrl = " https: when(view.getProjectName()).thenReturn(""); presenter.projectUrlChanged(incorrectUrl); verify(view).showUrlError(eq(locale.importProjectMessageStartWithWhiteSpace())); verify(importSourceDescriptor).setLocation(eq(incorrectUrl)); verify(view).setProjectName(anyString()); verify(updateDelegate).updateControls(); }
@Test public void testUrlMatchScpLikeSyntax() { String correctUrl = "host.xz:path/to/repo.git"; when(view.getProjectName()).thenReturn(""); presenter.projectUrlChanged(correctUrl); verifyInvocationsForCorrectUrl(correctUrl); }
@Test public void testUrlWithoutUsername() { String correctUrl = "git@hostname.com:projectName.git"; when(view.getProjectName()).thenReturn(""); presenter.projectUrlChanged(correctUrl); verifyInvocationsForCorrectUrl(correctUrl); }
@Test public void testSshUriWithHostBetweenDoubleSlashAndSlash() { String correctUrl = "ssh: when(view.getProjectName()).thenReturn(""); presenter.projectUrlChanged(correctUrl); verifyInvocationsForCorrectUrl(correctUrl); }
@Test public void testSshUriWithHostBetweenDoubleSlashAndColon() { String correctUrl = "ssh: when(view.getProjectName()).thenReturn(""); presenter.projectUrlChanged(correctUrl); verifyInvocationsForCorrectUrl(correctUrl); }
@Test public void testGitUriWithHostBetweenDoubleSlashAndSlash() { String correctUrl = "git: when(view.getProjectName()).thenReturn(""); presenter.projectUrlChanged(correctUrl); verifyInvocationsForCorrectUrl(correctUrl); }
@Test public void testSshUriWithHostBetweenAtAndColon() { String correctUrl = "user@host.com:login/repo"; when(view.getProjectName()).thenReturn(""); presenter.projectUrlChanged(correctUrl); verifyInvocationsForCorrectUrl(correctUrl); }
@Test public void testSshUriWithHostBetweenAtAndSlash() { String correctUrl = "ssh: when(view.getProjectName()).thenReturn(""); presenter.projectUrlChanged(correctUrl); verifyInvocationsForCorrectUrl(correctUrl); }
@Test public void projectUrlWithIncorrectProtocolEnteredTest() { String correctUrl = "htps: when(view.getProjectName()).thenReturn(""); presenter.projectUrlChanged(correctUrl); verify(view).showUrlError(eq(locale.importProjectMessageProtocolIncorrect())); verify(importSourceDescriptor).setLocation(eq(correctUrl)); verify(view).setProjectName(anyString()); verify(updateDelegate).updateControls(); }