SubversionProjectImporterPresenter extends AbstractWizardPage<ImportProject> implements SubversionProjectImporterView.ActionDelegate { @Override public void onProjectUrlChanged() { if (Strings.isNullOrEmpty(view.getProjectUrl())) { view.setProjectName(""); return; } String projectName = Iterables.getLast(Splitter.on("/").omitEmptyStrings().split(view.getProjectUrl())); String calcUrl = getUrl(view.getProjectUrl(), view.getProjectRelativePath()); view.setProjectName(projectName); dataObject.getSource().getProject().setLocation(calcUrl); updateDelegate.updateControls(); } @Inject  SubversionProjectImporterPresenter(SubversionProjectImporterView view); @Override void go(AcceptsOneWidget container); @Override void onProjectNameChanged(); @Override void onProjectUrlChanged(); @Override void onProjectRelativePathChanged(); @Override void onProjectDescriptionChanged(); @Override void onProjectVisibilityChanged(); @Override void onCredentialsChanged(); static final String PUBLIC_VISIBILITY; static final String PRIVATE_VISIBILITY; }
@Test public void testNonUrlProjectUrl() throws Exception { final String projectUrl = "subversion"; when(view.getProjectUrl()).thenReturn(projectUrl); presenter.onProjectUrlChanged(); verify(view).setProjectName(eq(projectUrl)); verify(view, never()).setNameErrorVisibility(anyBoolean()); verify(dataObject.getSource().getProject()).setLocation(projectUrl + "/"); verify(updateDelegate, times(1)).updateControls(); }
@Test public void testValidProjectUrl() throws Exception { final String projectUrl = "https: when(view.getProjectUrl()).thenReturn(projectUrl); presenter.onProjectUrlChanged(); verify(view).setProjectName(eq("trunk")); verify(dataObject.getSource().getProject()).setLocation(projectUrl); verify(updateDelegate).updateControls(); }