@Test public void correctMethodsCalledIfSomeTestCasesFail() { SubmissionResult result = mock(SubmissionResult.class); when(result.allTestCasesSucceeded()).thenReturn(false); when(result.allTestCasesFailed()).thenReturn(false); Exercise exercise = mock(Exercise.class); when(exercise.getName()).thenReturn("foo"); Project project = mock(Project.class); when(project.getExercise()).thenReturn(exercise); when(task.getProject()).thenReturn(project); when(task.getResult()).thenReturn(result); listener.onSuccess(); verify(task, times(1)).getResult(); verify(task, times(2)).getProject(); verify(invoker, times(1)).invokeTestResultWindow(Mockito.anyListOf(TestCaseResult.class)); verify(invoker, times(0)).invokeAllTestsPassedWindow(Mockito.any(SubmissionResult.class), Mockito.anyString()); verify(invoker, times(0)).invokeAllTestsFailedWindow(Mockito.any(SubmissionResult.class), Mockito.anyString()); verify(invoker, times(1)).invokeSomeTestsFailedWindow(Mockito.any(SubmissionResult.class), Mockito.anyString()); }
@Override public void onSuccess() { final SubmissionResult result = task.getResult(); if (result == null) { return; } String exerciseName = task.getProject().getExercise().getName(); Exercise exercise = task.getProject().getExercise(); uiInvoker.invokeTestResultWindow(result.getTestCases()); if (result.allTestCasesSucceeded()) { uiInvoker.invokeAllTestsPassedWindow(result, exerciseName); exercise.setCompleted(true); } else if (result.allTestCasesFailed()) { uiInvoker.invokeAllTestsFailedWindow(result, exerciseName); exercise.setAttempted(true); } else { uiInvoker.invokeSomeTestsFailedWindow(result, exerciseName); exercise.setAttempted(true); } projectIconHandler.updateIcon(exercise); }
UploadTaskListener implements BackgroundTaskListener { @Override public void onSuccess() { final SubmissionResult result = task.getResult(); if (result == null) { return; } String exerciseName = task.getProject().getExercise().getName(); Exercise exercise = task.getProject().getExercise(); uiInvoker.invokeTestResultWindow(result.getTestCases()); if (result.allTestCasesSucceeded()) { uiInvoker.invokeAllTestsPassedWindow(result, exerciseName); exercise.setCompleted(true); } else if (result.allTestCasesFailed()) { uiInvoker.invokeAllTestsFailedWindow(result, exerciseName); exercise.setAttempted(true); } else { uiInvoker.invokeSomeTestsFailedWindow(result, exerciseName); exercise.setAttempted(true); } projectIconHandler.updateIcon(exercise); } }
UploadTaskListener implements BackgroundTaskListener { @Override public void onSuccess() { final SubmissionResult result = task.getResult(); if (result == null) { return; } String exerciseName = task.getProject().getExercise().getName(); Exercise exercise = task.getProject().getExercise(); uiInvoker.invokeTestResultWindow(result.getTestCases()); if (result.allTestCasesSucceeded()) { uiInvoker.invokeAllTestsPassedWindow(result, exerciseName); exercise.setCompleted(true); } else if (result.allTestCasesFailed()) { uiInvoker.invokeAllTestsFailedWindow(result, exerciseName); exercise.setAttempted(true); } else { uiInvoker.invokeSomeTestsFailedWindow(result, exerciseName); exercise.setAttempted(true); } projectIconHandler.updateIcon(exercise); } UploadTaskListener(UploaderTask task, IdeUIInvoker uiInvoker, ProjectIconHandler projectIconHandler); }
UploadTaskListener implements BackgroundTaskListener { @Override public void onSuccess() { final SubmissionResult result = task.getResult(); if (result == null) { return; } String exerciseName = task.getProject().getExercise().getName(); Exercise exercise = task.getProject().getExercise(); uiInvoker.invokeTestResultWindow(result.getTestCases()); if (result.allTestCasesSucceeded()) { uiInvoker.invokeAllTestsPassedWindow(result, exerciseName); exercise.setCompleted(true); } else if (result.allTestCasesFailed()) { uiInvoker.invokeAllTestsFailedWindow(result, exerciseName); exercise.setAttempted(true); } else { uiInvoker.invokeSomeTestsFailedWindow(result, exerciseName); exercise.setAttempted(true); } projectIconHandler.updateIcon(exercise); } UploadTaskListener(UploaderTask task, IdeUIInvoker uiInvoker, ProjectIconHandler projectIconHandler); @Override void onBegin(); @Override void onSuccess(); @Override void onFailure(); @Override void onInterruption(); }
UploadTaskListener implements BackgroundTaskListener { @Override public void onSuccess() { final SubmissionResult result = task.getResult(); if (result == null) { return; } String exerciseName = task.getProject().getExercise().getName(); Exercise exercise = task.getProject().getExercise(); uiInvoker.invokeTestResultWindow(result.getTestCases()); if (result.allTestCasesSucceeded()) { uiInvoker.invokeAllTestsPassedWindow(result, exerciseName); exercise.setCompleted(true); } else if (result.allTestCasesFailed()) { uiInvoker.invokeAllTestsFailedWindow(result, exerciseName); exercise.setAttempted(true); } else { uiInvoker.invokeSomeTestsFailedWindow(result, exerciseName); exercise.setAttempted(true); } projectIconHandler.updateIcon(exercise); } UploadTaskListener(UploaderTask task, IdeUIInvoker uiInvoker, ProjectIconHandler projectIconHandler); @Override void onBegin(); @Override void onSuccess(); @Override void onFailure(); @Override void onInterruption();  }