@Test public void onSubmitCompleteWhenOverwriteFileSelected() { Selection select = mock(Selection.class); FolderNode item = mock(FolderNode.class); when(selectionAgent.getSelection()).thenReturn(select); when(select.getFirstElement()).thenReturn(item); when(view.isOverwriteFileSelected()).thenReturn(true); when(view.getFileName()).thenReturn("fileName"); presenter.onSubmitComplete(""); verify(view).closeDialog(); verify(notificationManager, never()).showError(anyString()); verify(eventBus, times(2)).fireEvent((Event)anyObject()); }
@Override public void onSubmitComplete(String result) { eventBus.fireEvent(new RefreshProjectTreeEvent(getParent())); if (result != null && !result.isEmpty()) { view.closeDialog(); notificationManager.showError(parseMessage(result)); return; } if (view.isOverwriteFileSelected()) { String path = getParent().getPath() + "/" + view.getFileName(); eventBus.fireEvent(new FileContentUpdateEvent(path)); } view.closeDialog(); }
UploadFilePresenter implements UploadFileView.ActionDelegate { @Override public void onSubmitComplete(String result) { eventBus.fireEvent(new RefreshProjectTreeEvent(getParent())); if (result != null && !result.isEmpty()) { view.closeDialog(); notificationManager.showError(parseMessage(result)); return; } if (view.isOverwriteFileSelected()) { String path = getParent().getPath() + "/" + view.getFileName(); eventBus.fireEvent(new FileContentUpdateEvent(path)); } view.closeDialog(); } }
UploadFilePresenter implements UploadFileView.ActionDelegate { @Override public void onSubmitComplete(String result) { eventBus.fireEvent(new RefreshProjectTreeEvent(getParent())); if (result != null && !result.isEmpty()) { view.closeDialog(); notificationManager.showError(parseMessage(result)); return; } if (view.isOverwriteFileSelected()) { String path = getParent().getPath() + "/" + view.getFileName(); eventBus.fireEvent(new FileContentUpdateEvent(path)); } view.closeDialog(); } @Inject  UploadFilePresenter(UploadFileView view,
                               @Named("restContext") String restContext,
                               @Named("workspaceId") String workspaceId,
                               SelectionAgent selectionAgent,
                               EventBus eventBus,
                               NotificationManager notificationManager); }
UploadFilePresenter implements UploadFileView.ActionDelegate { @Override public void onSubmitComplete(String result) { eventBus.fireEvent(new RefreshProjectTreeEvent(getParent())); if (result != null && !result.isEmpty()) { view.closeDialog(); notificationManager.showError(parseMessage(result)); return; } if (view.isOverwriteFileSelected()) { String path = getParent().getPath() + "/" + view.getFileName(); eventBus.fireEvent(new FileContentUpdateEvent(path)); } view.closeDialog(); } @Inject  UploadFilePresenter(UploadFileView view,
                               @Named("restContext") String restContext,
                               @Named("workspaceId") String workspaceId,
                               SelectionAgent selectionAgent,
                               EventBus eventBus,
                               NotificationManager notificationManager); void showDialog(); @Override void onCancelClicked(); @Override void onSubmitComplete(String result); @Override void onUploadClicked(); @Override void onFileNameChanged(); }
UploadFilePresenter implements UploadFileView.ActionDelegate { @Override public void onSubmitComplete(String result) { eventBus.fireEvent(new RefreshProjectTreeEvent(getParent())); if (result != null && !result.isEmpty()) { view.closeDialog(); notificationManager.showError(parseMessage(result)); return; } if (view.isOverwriteFileSelected()) { String path = getParent().getPath() + "/" + view.getFileName(); eventBus.fireEvent(new FileContentUpdateEvent(path)); } view.closeDialog(); } @Inject  UploadFilePresenter(UploadFileView view,
                               @Named("restContext") String restContext,
                               @Named("workspaceId") String workspaceId,
                               SelectionAgent selectionAgent,
                               EventBus eventBus,
                               NotificationManager notificationManager); void showDialog(); @Override void onCancelClicked(); @Override void onSubmitComplete(String result); @Override void onUploadClicked(); @Override void onFileNameChanged();  }