ZipImporterPagePresenter extends AbstractWizardPage<ImportProject> implements ZipImporterPageView.ActionDelegate { @Override public void projectUrlChanged(@NotNull String url) { dataObject.getSource().getProject().setLocation(url); isUrlCorrect(url); String projectName = view.getProjectName(); if (projectName.isEmpty()) { projectName = extractProjectNameFromUri(url); dataObject.getProject().setName(projectName); view.setProjectName(projectName); validateProjectName(); } updateDelegate.updateControls(); } @Inject  ZipImporterPagePresenter(ZipImporterPageView view, CoreLocalizationConstant locale); @Override void init(ImportProject dataObject); @Override boolean isCompleted(); @Override void projectNameChanged(@NotNull String name); @Override void projectUrlChanged(@NotNull String url); @Override void projectDescriptionChanged(@NotNull String projectDescription); @Override void projectVisibilityChanged(boolean visible); @Override void skipFirstLevelChanged(boolean isSkipFirstLevel); @Override void go(AcceptsOneWidget container);  }
@Test public void incorrectProjectUrlEnteredTest() { String incorrectUrl = "https when(view.getProjectName()).thenReturn(""); when(view.getProjectName()).thenReturn("angularjs"); presenter.projectUrlChanged(incorrectUrl); verify(view).showUrlError(anyString()); verify(delegate).updateControls(); }
@Test public void projectUrlWithoutZipEnteredTest() { String incorrectUrl = "https: when(view.getProjectName()).thenReturn(""); presenter.projectUrlChanged(incorrectUrl); verify(view).showUrlError(anyString()); verify(delegate).updateControls(); }
@Test public void projectUrlStartWithWhiteSpaceEnteredTest() { String incorrectUrl = " https: when(view.getProjectName()).thenReturn("name"); presenter.projectUrlChanged(incorrectUrl); verify(view).showUrlError(eq(locale.importProjectMessageStartWithWhiteSpace())); verify(delegate).updateControls(); }
@Test public void correctProjectUrlEnteredTest() { String correctUrl = "https: when(view.getProjectName()).thenReturn("", "angularjs"); presenter.projectUrlChanged(correctUrl); verify(view, never()).showUrlError(anyString()); verify(importSourceDescriptor).setLocation(eq(correctUrl)); verify(view).hideNameError(); verify(view).setProjectName(anyString()); verify(delegate).updateControls(); }