LocalZipImporterPagePresenter implements LocalZipImporterPageView.ActionDelegate { @Override public void projectNameChanged() { view.setEnabledImportButton(isCompleted()); } @Inject  LocalZipImporterPagePresenter(LocalZipImporterPageView view,
                                         DtoFactory dtoFactory,
                                         CoreLocalizationConstant locale,
                                         @RestContext String restContext,
                                         @Named("workspaceId") String workspaceId,
                                         EventBus eventBus,
                                         VfsServiceClient vfsServiceClient,
                                         ProjectServiceClient projectServiceClient,
                                         DialogFactory dialogFactory,
                                         ImportProjectNotificationSubscriber importProjectNotificationSubscriber); void show(); @Override void projectNameChanged(); @Override void fileNameChanged(); @Override void onSubmitComplete(String result); @Override void onCancelClicked(); @Override void onImportClicked();  }
@Test public void correctProjectNameEnteredWhenZipForUploadChoosedTest() { when(view.getProjectName()).thenReturn(PROJECT_NAME); when(view.getFileName()).thenReturn(FILE_NAME); presenter.projectNameChanged(); verify(view).setEnabledImportButton(eq(true)); verify(view).hideNameError(); verify(view, never()).showNameError(); }
@Test public void incorrectFileForUploadChoosedTest() { String incorrectFileName = "test.txt"; when(view.getProjectName()).thenReturn(PROJECT_NAME); when(view.getFileName()).thenReturn(incorrectFileName); presenter.projectNameChanged(); verify(view).setEnabledImportButton(eq(false)); verify(view, never()).showNameError(); }
@Test public void emptyProjectNameEnteredTest() { String emptyName = ""; when(view.getFileName()).thenReturn(FILE_NAME); when(view.getProjectName()).thenReturn(emptyName); presenter.projectNameChanged(); verify(view).setEnabledImportButton(eq(false)); verify(view).showNameError(); }
@Test public void incorrectProjectNameEnteredTest() { String incorrectName = "angularjs+"; when(view.getFileName()).thenReturn(FILE_NAME); when(view.getProjectName()).thenReturn(incorrectName); presenter.projectNameChanged(); verify(view).setEnabledImportButton(eq(false)); verify(view).showNameError(); }