MovePresenter extends SubversionActionPresenter implements MoveView.ActionDelegate { public void showMove() { Selection<?> selection = projectExplorerPart.getSelection(); sources = selection.getAllElements(); projectPath = getCurrentProjectPath(); treeStructureProvider.get().getRootNodes(new AsyncCallback<List<TreeNode<?>>>() { @Override public void onFailure(Throwable caught) { notificationManager.showError(locale.moveFailToGetProject()); } @Override public void onSuccess(List<TreeNode<?>> result) { view.setProjectNodes(result); } }); view.onShow(sources.size() == 1); } @Inject  MovePresenter(AppContext appContext,
                         EventBus eventBus,
                         RawOutputPresenter console,
                         WorkspaceAgent workspaceAgent,
                         ProjectExplorerPresenter projectExplorerPart,
                         MoveView view,
                         FilteredTreeStructureProvider treeStructureProvider,
                         NotificationManager notificationManager,
                         SubversionClientService service,
                         DtoUnmarshallerFactory dtoUnmarshallerFactory,
                         SubversionExtensionLocalizationConstants locale); void showMove(); @Override void onMoveClicked(); @Override void onCancelClicked(); @Override void minimize(); @Override void activatePart(); @Override void onNodeSelected(TreeNode<?> destinationNode); @Override void onUrlsChanged(); @Override void onNodeExpanded(final TreeNode<?> node);  }
@Test public void testMoveViewShouldBeShowed() throws Exception { final Selection selection = mock(Selection.class); final List<StorableNode> allItems = new ArrayList<>(); final FileNode fileNode = mock(FileNode.class); final FolderNode folderNode = mock(FolderNode.class); when(treeStructureProvider.get()).thenReturn(filteredTreeStructure); when(projectExplorerPart.getSelection()).thenReturn(selection); when(selection.isEmpty()).thenReturn(false); when(selection.getAllElements()).thenReturn(allItems); allItems.add(fileNode); allItems.add(folderNode); presenter.showMove(); verify(view).onShow(false); }
@Test public void testMoveViewShouldSetProjectNode() throws Exception { final Selection selection = mock(Selection.class); final List<StorableNode> allItems = new ArrayList<>(); final FileNode fileNode = mock(FileNode.class); final FolderNode folderNode = mock(FolderNode.class); when(treeStructureProvider.get()).thenReturn(filteredTreeStructure); when(projectExplorerPart.getSelection()).thenReturn(selection); when(selection.isEmpty()).thenReturn(false); when(selection.getAllElements()).thenReturn(allItems); allItems.add(fileNode); allItems.add(folderNode); presenter.showMove(); List<TreeNode<?>> children = new ArrayList<>(); children.add(mock(ProjectNode.class)); verify(filteredTreeStructure).getRootNodes(asyncRequestCallbackStatusCaptor.capture()); AsyncCallback<List<TreeNode<?>>> requestCallback = asyncRequestCallbackStatusCaptor.getValue(); GwtReflectionUtils.callPrivateMethod(requestCallback, "onSuccess", children); verify(view).setProjectNodes(eq(children)); }