@Test public void taskAddReviewsToReviewDAOAfterSuccefullFetchAndReturnSuccess() { List<Review> reviews = new ArrayList<Review>(); when(server.downloadReviews(course)).thenReturn(reviews); assertEquals(BackgroundTask.RETURN_SUCCESS, task.start(progress)); verify(reviewDAO, times(1)).addAll(reviews); verify(progress, times(2)).incrementProgress(1); }
@Override public int start(TaskStatusMonitor progress) { progress.startProgress(this.getDescription(), 2); this.reviews = server.downloadReviews(course); progress.incrementProgress(1); if (this.reviews == null) { return RETURN_FAILURE; } if (shouldStop(progress)) { return BackgroundTask.RETURN_INTERRUPTED; } this.reviewDAO.addAll(reviews); progress.incrementProgress(1); return RETURN_SUCCESS; }
FetchCodeReviewsTask extends BackgroundTask { @Override public int start(TaskStatusMonitor progress) { progress.startProgress(this.getDescription(), 2); this.reviews = server.downloadReviews(course); progress.incrementProgress(1); if (this.reviews == null) { return RETURN_FAILURE; } if (shouldStop(progress)) { return BackgroundTask.RETURN_INTERRUPTED; } this.reviewDAO.addAll(reviews); progress.incrementProgress(1); return RETURN_SUCCESS; } }
FetchCodeReviewsTask extends BackgroundTask { @Override public int start(TaskStatusMonitor progress) { progress.startProgress(this.getDescription(), 2); this.reviews = server.downloadReviews(course); progress.incrementProgress(1); if (this.reviews == null) { return RETURN_FAILURE; } if (shouldStop(progress)) { return BackgroundTask.RETURN_INTERRUPTED; } this.reviewDAO.addAll(reviews); progress.incrementProgress(1); return RETURN_SUCCESS; } FetchCodeReviewsTask(Course course, ServerManager server, ReviewDAO reviewDAO); }
FetchCodeReviewsTask extends BackgroundTask { @Override public int start(TaskStatusMonitor progress) { progress.startProgress(this.getDescription(), 2); this.reviews = server.downloadReviews(course); progress.incrementProgress(1); if (this.reviews == null) { return RETURN_FAILURE; } if (shouldStop(progress)) { return BackgroundTask.RETURN_INTERRUPTED; } this.reviewDAO.addAll(reviews); progress.incrementProgress(1); return RETURN_SUCCESS; } FetchCodeReviewsTask(Course course, ServerManager server, ReviewDAO reviewDAO); @Override int start(TaskStatusMonitor progress); }
FetchCodeReviewsTask extends BackgroundTask { @Override public int start(TaskStatusMonitor progress) { progress.startProgress(this.getDescription(), 2); this.reviews = server.downloadReviews(course); progress.incrementProgress(1); if (this.reviews == null) { return RETURN_FAILURE; } if (shouldStop(progress)) { return BackgroundTask.RETURN_INTERRUPTED; } this.reviewDAO.addAll(reviews); progress.incrementProgress(1); return RETURN_SUCCESS; } FetchCodeReviewsTask(Course course, ServerManager server, ReviewDAO reviewDAO); @Override int start(TaskStatusMonitor progress);  }