RemoveFromIndexPresenter implements RemoveFromIndexView.ActionDelegate { public void showDialog() { project = appContext.getCurrentProject(); String workDir = project.getRootProject().getPath(); view.setMessage(formMessage(workDir)); view.setRemoved(false); view.showDialog(); } @Inject  RemoveFromIndexPresenter(RemoveFromIndexView view,
                                    EventBus eventBus,
                                    GitServiceClient service,
                                    GitOutputPartPresenter console,
                                    GitLocalizationConstant constant,
                                    AppContext appContext,
                                    SelectionAgent selectionAgent,
                                    NotificationManager notificationManager,
                                    EditorAgent editorAgent,
                                    ProjectExplorerPresenter projectExplorer); void showDialog(); @Override void onRemoveClicked(); @Override void onCancelClicked();  }
@Test public void testShowDialogWhenSomeFileIsSelected() throws Exception { String filePath = PROJECT_PATH + PROJECT_NAME; Selection selection = mock(Selection.class); FileReferenceNode file = mock(FileReferenceNode.class); when(file.getStorablePath()).thenReturn(filePath); when(selection.getHeadElement()).thenReturn(file); when(selectionAgent.getSelection()).thenReturn(selection); when(constant.removeFromIndexFile(anyString())).thenReturn(SAFE_HTML); when(SAFE_HTML.asString()).thenReturn(MESSAGE); presenter.showDialog(); verify(view).setMessage(eq(MESSAGE)); verify(view).setRemoved(eq(!REMOVED)); verify(view).showDialog(); verify(constant).removeFromIndexFile(eq(PROJECT_NAME)); }
@Test public void testShowDialogWhenSomeFolderIsSelected() throws Exception { String folderPath = PROJECT_PATH + PROJECT_NAME; Selection selection = mock(Selection.class); FolderReferenceNode folder = mock(FolderReferenceNode.class); when(folder.getStorablePath()).thenReturn(folderPath); when(selection.getHeadElement()).thenReturn(folder); when(selectionAgent.getSelection()).thenReturn(selection); when(constant.removeFromIndexFolder(anyString())).thenReturn(SAFE_HTML); when(SAFE_HTML.asString()).thenReturn(MESSAGE); presenter.showDialog(); verify(view).setMessage(eq(MESSAGE)); verify(view).setRemoved(eq(!REMOVED)); verify(view).showDialog(); verify(constant).removeFromIndexFolder(eq(PROJECT_NAME)); }
@Test public void testShowDialogWhenRootFolderIsSelected() throws Exception { Selection selection = mock(Selection.class); ProjectDescriptorNode project = mock(ProjectDescriptorNode.class); when(project.getStorablePath()).thenReturn(PROJECT_PATH); when(selection.getHeadElement()).thenReturn(project); when(selectionAgent.getSelection()).thenReturn(selection); when(constant.removeFromIndexAll()).thenReturn(MESSAGE); presenter.showDialog(); verify(view).setMessage(eq(MESSAGE)); verify(view).setRemoved(eq(!REMOVED)); verify(view).showDialog(); verify(constant).removeFromIndexAll(); }