@Test public void taskReturnsInterruptedIfCancelIsRequestedAtFirstCheckpoint() throws IOException { when(progress.isCancelRequested()).thenReturn(true); assertEquals(BackgroundTask.RETURN_INTERRUPTED, task.start(progress)); verify(progress, times(0)).incrementProgress(1); }
@Override public int start(TaskStatusMonitor progress) { progress.startProgress(this.getDescription(), 2); try { uploader.setProject(projectDAO.getProjectByFile(path)); uploader.setAsPaste(pasteMessage); uploader.zipProjects(); if (shouldStop(progress)) { return BackgroundTask.RETURN_INTERRUPTED; } progress.incrementProgress(1); uploader.handleSubmissionResponse(); if (shouldStop(progress)) { return BackgroundTask.RETURN_INTERRUPTED; } progress.incrementProgress(1); } catch (Exception ex) { invoker.raiseVisibleException("An error occurred while uploading exercise to pastebin:\n" + ex.getMessage()); return BackgroundTask.RETURN_FAILURE; } return BackgroundTask.RETURN_SUCCESS; }
PastebinTask extends BackgroundTask { @Override public int start(TaskStatusMonitor progress) { progress.startProgress(this.getDescription(), 2); try { uploader.setProject(projectDAO.getProjectByFile(path)); uploader.setAsPaste(pasteMessage); uploader.zipProjects(); if (shouldStop(progress)) { return BackgroundTask.RETURN_INTERRUPTED; } progress.incrementProgress(1); uploader.handleSubmissionResponse(); if (shouldStop(progress)) { return BackgroundTask.RETURN_INTERRUPTED; } progress.incrementProgress(1); } catch (Exception ex) { invoker.raiseVisibleException("An error occurred while uploading exercise to pastebin:\n" + ex.getMessage()); return BackgroundTask.RETURN_FAILURE; } return BackgroundTask.RETURN_SUCCESS; } }
PastebinTask extends BackgroundTask { @Override public int start(TaskStatusMonitor progress) { progress.startProgress(this.getDescription(), 2); try { uploader.setProject(projectDAO.getProjectByFile(path)); uploader.setAsPaste(pasteMessage); uploader.zipProjects(); if (shouldStop(progress)) { return BackgroundTask.RETURN_INTERRUPTED; } progress.incrementProgress(1); uploader.handleSubmissionResponse(); if (shouldStop(progress)) { return BackgroundTask.RETURN_INTERRUPTED; } progress.incrementProgress(1); } catch (Exception ex) { invoker.raiseVisibleException("An error occurred while uploading exercise to pastebin:\n" + ex.getMessage()); return BackgroundTask.RETURN_FAILURE; } return BackgroundTask.RETURN_SUCCESS; } PastebinTask(ProjectUploader uploader, String path, String pasteMessage, ProjectDAO projectDAO,
            IdeUIInvoker invoker); }
PastebinTask extends BackgroundTask { @Override public int start(TaskStatusMonitor progress) { progress.startProgress(this.getDescription(), 2); try { uploader.setProject(projectDAO.getProjectByFile(path)); uploader.setAsPaste(pasteMessage); uploader.zipProjects(); if (shouldStop(progress)) { return BackgroundTask.RETURN_INTERRUPTED; } progress.incrementProgress(1); uploader.handleSubmissionResponse(); if (shouldStop(progress)) { return BackgroundTask.RETURN_INTERRUPTED; } progress.incrementProgress(1); } catch (Exception ex) { invoker.raiseVisibleException("An error occurred while uploading exercise to pastebin:\n" + ex.getMessage()); return BackgroundTask.RETURN_FAILURE; } return BackgroundTask.RETURN_SUCCESS; } PastebinTask(ProjectUploader uploader, String path, String pasteMessage, ProjectDAO projectDAO,
            IdeUIInvoker invoker); @Override int start(TaskStatusMonitor progress); String getPasteUrl(); }
PastebinTask extends BackgroundTask { @Override public int start(TaskStatusMonitor progress) { progress.startProgress(this.getDescription(), 2); try { uploader.setProject(projectDAO.getProjectByFile(path)); uploader.setAsPaste(pasteMessage); uploader.zipProjects(); if (shouldStop(progress)) { return BackgroundTask.RETURN_INTERRUPTED; } progress.incrementProgress(1); uploader.handleSubmissionResponse(); if (shouldStop(progress)) { return BackgroundTask.RETURN_INTERRUPTED; } progress.incrementProgress(1); } catch (Exception ex) { invoker.raiseVisibleException("An error occurred while uploading exercise to pastebin:\n" + ex.getMessage()); return BackgroundTask.RETURN_FAILURE; } return BackgroundTask.RETURN_SUCCESS; } PastebinTask(ProjectUploader uploader, String path, String pasteMessage, ProjectDAO projectDAO,
            IdeUIInvoker invoker); @Override int start(TaskStatusMonitor progress); String getPasteUrl();  }