1
1
package fi .helsinki .cs .tmc .runners ;
2
2
3
+ import com .google .common .base .Optional ;
3
4
import fi .helsinki .cs .tmc .data .Exercise ;
4
5
import fi .helsinki .cs .tmc .data .ResultCollector ;
5
6
import fi .helsinki .cs .tmc .data .TestRunResult ;
@@ -33,12 +34,12 @@ public InvokedEvent(TmcProjectInfo projectInfo) {
33
34
}
34
35
}
35
36
36
- private ProjectMediator projectMediator ;
37
- private ConvenientDialogDisplayer dialogDisplayer ;
38
- private TmcEventBus eventBus ;
39
- private TestResultDisplayer resultDisplayer ;
40
- private ExerciseSubmitter exerciseSubmitter ;
41
- private CourseDb courseDb ;
37
+ private final ProjectMediator projectMediator ;
38
+ private final ConvenientDialogDisplayer dialogDisplayer ;
39
+ private final TmcEventBus eventBus ;
40
+ private final TestResultDisplayer resultDisplayer ;
41
+ private final ExerciseSubmitter exerciseSubmitter ;
42
+ private final CourseDb courseDb ;
42
43
43
44
public TestRunHandler () {
44
45
this .projectMediator = ProjectMediator .getInstance ();
@@ -55,17 +56,16 @@ public void performAction(final ResultCollector resultCollector, Project... proj
55
56
final TmcProjectInfo projectInfo = projectMediator .wrapProject (project );
56
57
eventBus .post (new InvokedEvent (projectInfo ));
57
58
final ExerciseRunner runner = getRunner (projectInfo );
58
- BgTask .start ("Running tests" , runner .getTestRunningTask (projectInfo ), new BgTaskListener <TestRunResult >() {
59
+ BgTask .start ("Running tests" , runner .getTestRunningTask (projectInfo ), new BgTaskListener <Optional < TestRunResult > >() {
59
60
@ Override
60
- public void bgTaskReady (TestRunResult result ) {
61
- if (result == null ) {
61
+ public void bgTaskReady (Optional < TestRunResult > result ) {
62
+ if (! result . isPresent () ) {
62
63
dialogDisplayer .displayError ("The code did not compile." );
63
64
return ;
64
-
65
65
}
66
66
Exercise ex = projectMediator .tryGetExerciseForProject (projectInfo , courseDb );
67
67
boolean canSubmit = ex .isReturnable ();
68
- resultDisplayer .showLocalRunResult (result .getTestCaseResults (), canSubmit , new Runnable () {
68
+ resultDisplayer .showLocalRunResult (result .get (). getTestCaseResults (), canSubmit , new Runnable () {
69
69
@ Override
70
70
public void run () {
71
71
exerciseSubmitter .performAction (projectInfo .getProject ());
@@ -75,7 +75,7 @@ public void run() {
75
75
76
76
@ Override
77
77
public void bgTaskFailed (Throwable ex ) {
78
- log .log (INFO , "performAction failed message: {0}, trace: {1}" ,
78
+ log .log (INFO , "performAction of TestRunHandler failed with message: {0}, trace: {1}" ,
79
79
new Object []{ex .getMessage (), Arrays .deepToString (ex .getStackTrace ())});
80
80
dialogDisplayer .displayError ("Failed to run the tests: " + ex .getMessage ());
81
81
}
0 commit comments