4
4
import org .utplsql .api .reporter .CoreReporters ;
5
5
import org .utplsql .api .reporter .Reporter ;
6
6
import org .utplsql .api .reporter .ReporterFactory ;
7
+ import org .utplsql .cli .config .ReporterConfig ;
7
8
import org .utplsql .cli .reporters .ReporterOptionsAware ;
8
9
9
10
import javax .sql .DataSource ;
13
14
import java .sql .Connection ;
14
15
import java .sql .SQLException ;
15
16
import java .util .ArrayList ;
16
- import java .util .Arrays ;
17
17
import java .util .List ;
18
18
import java .util .concurrent .ExecutorService ;
19
19
@@ -23,17 +23,30 @@ class ReporterManager {
23
23
private List <Throwable > reporterGatherErrors ;
24
24
private ExecutorService executorService ;
25
25
26
- ReporterManager ( ReporterOptions [] reporterOptions ) {
27
- this .reporterOptionsList = Arrays .asList (reporterOptions );
28
- initReporterOptionsList ();
26
+ ReporterManager (ReporterConfig [] reporterConfigs ) {
27
+ reporterOptionsList = new ArrayList <>();
28
+ if ( reporterConfigs != null && reporterConfigs .length > 0 ) {
29
+ loadOptionsFromConfigs ( reporterConfigs );
30
+ }
31
+ else {
32
+ reporterOptionsList .add (getDefaultReporterOption ());
33
+ }
29
34
}
30
35
31
- private void initReporterOptionsList ( ) {
36
+ private void loadOptionsFromConfigs ( ReporterConfig [] reporterConfigs ) {
37
+ boolean printToScreen = false ;
38
+ for (ReporterConfig reporterConfig : reporterConfigs ) {
39
+ ReporterOptions option = new ReporterOptions (
40
+ reporterConfig .getName (),
41
+ reporterConfig .getOutput ());
32
42
33
- // If no reporter parameters were passed, use default reporter.
34
- if (reporterOptionsList .isEmpty ()) {
35
- reporterOptionsList = new ArrayList <>();
36
- reporterOptionsList .add (getDefaultReporterOption ());
43
+ option .forceOutputToScreen (reporterConfig .isForceToScreen ());
44
+ reporterOptionsList .add (option );
45
+
46
+ // Check printToScreen validity
47
+ if (option .outputToScreen () && printToScreen )
48
+ throw new IllegalArgumentException ("You cannot configure more than one reporter to output to screen" );
49
+ printToScreen = option .outputToScreen ();
37
50
}
38
51
}
39
52
0 commit comments