@@ -28,9 +28,9 @@ public class TestRunner {
2828 private static final Logger logger = LoggerFactory .getLogger (TestRunner .class );
2929
3030 private final TestRunnerOptions options = new TestRunnerOptions ();
31+ private final List <String > reporterNames = new ArrayList <>();
3132 private CompatibilityProxy compatibilityProxy ;
3233 private ReporterFactory reporterFactory ;
33- private final List <String > reporterNames = new ArrayList <>();
3434
3535 public TestRunner addPath (String path ) {
3636 options .pathList .add (path );
@@ -47,11 +47,12 @@ public TestRunner addReporter(Reporter reporter) {
4747 return this ;
4848 }
4949
50- public TestRunner addReporter ( String reporterName ) {
51- if ( reporterFactory != null )
50+ public TestRunner addReporter (String reporterName ) {
51+ if (reporterFactory != null ) {
5252 options .reporterList .add (reporterFactory .createReporter (reporterName ));
53- else
53+ } else {
5454 reporterNames .add (reporterName );
55+ }
5556 return this ;
5657 }
5758
@@ -105,22 +106,22 @@ public TestRunner failOnErrors(boolean failOnErrors) {
105106 return this ;
106107 }
107108
108- public TestRunner skipCompatibilityCheck ( boolean skipCompatibilityCheck )
109- {
109+ public TestRunner skipCompatibilityCheck (boolean skipCompatibilityCheck ) {
110110 options .skipCompatibilityCheck = skipCompatibilityCheck ;
111111 return this ;
112112 }
113113
114- public TestRunner setReporterFactory ( ReporterFactory reporterFactory ) {
114+ public TestRunner setReporterFactory (ReporterFactory reporterFactory ) {
115115 this .reporterFactory = reporterFactory ;
116116 return this ;
117117 }
118118
119119 private void delayedAddReporters () {
120- if ( reporterFactory != null )
121- reporterNames .forEach ( this ::addReporter );
122- else
120+ if (reporterFactory != null ) {
121+ reporterNames .forEach (this ::addReporter );
122+ } else {
123123 throw new IllegalStateException ("ReporterFactory must be set to add delayed Reporters!" );
124+ }
124125 }
125126
126127 public void run (Connection conn ) throws SQLException {
@@ -132,17 +133,19 @@ public void run(Connection conn) throws SQLException {
132133 compatibilityProxy = new CompatibilityProxy (conn , options .skipCompatibilityCheck , databaseInformation );
133134 logger .info ("Running on utPLSQL {}" , compatibilityProxy .getDatabaseVersion ());
134135
135- if ( reporterFactory == null )
136+ if (reporterFactory == null ) {
136137 reporterFactory = ReporterFactory .createDefault (compatibilityProxy );
138+ }
137139
138140 delayedAddReporters ();
139141
140142 // First of all check version compatibility
141143 compatibilityProxy .failOnNotCompatible ();
142144
143145 logger .info ("Initializing reporters" );
144- for (Reporter r : options .reporterList )
146+ for (Reporter r : options .reporterList ) {
145147 validateReporter (conn , r );
148+ }
146149
147150 if (options .pathList .isEmpty ()) {
148151 options .pathList .add (databaseInformation .getCurrentSchema (conn ));
@@ -153,43 +156,45 @@ public void run(Connection conn) throws SQLException {
153156 options .reporterList .add (new DocumentationReporter ().init (conn ));
154157 }
155158
156- try (TestRunnerStatement testRunnerStatement = compatibilityProxy .getTestRunnerStatement (options , conn )) {
159+ try (TestRunnerStatement testRunnerStatement = compatibilityProxy .getTestRunnerStatement (options , conn )) {
157160 logger .info ("Running tests" );
158161 testRunnerStatement .execute ();
159162 logger .info ("Running tests finished." );
160163 } catch (SQLException e ) {
161164 if (e .getErrorCode () == SomeTestsFailedException .ERROR_CODE ) {
162165 throw new SomeTestsFailedException (e .getMessage (), e );
163- }
164- else if (e .getErrorCode () == UtPLSQLNotInstalledException .ERROR_CODE ) {
166+ } else if (e .getErrorCode () == UtPLSQLNotInstalledException .ERROR_CODE ) {
165167 throw new UtPLSQLNotInstalledException (e );
166- }
167- else {
168+ } else {
168169 throw e ;
169170 }
170171 }
171172 }
172173
173174 /**
174175 * Check if the reporter was initialized, if not call reporter.init.
175- * @param conn the database connection
176+ *
177+ * @param conn the database connection
176178 * @param reporter the reporter
177179 * @throws SQLException any sql exception
178180 */
179181 private void validateReporter (Connection conn , Reporter reporter ) throws SQLException {
180- if (!reporter .isInit () || reporter .getId () == null || reporter .getId ().isEmpty ())
182+ if (!reporter .isInit () || reporter .getId () == null || reporter .getId ().isEmpty ()) {
181183 reporter .init (conn , compatibilityProxy , reporterFactory );
184+ }
182185 }
183186
184- /** Returns the databaseVersion the TestRunner was run against
187+ /**
188+ * Returns the databaseVersion the TestRunner was run against
185189 *
186190 * @return Version of the database the TestRunner was run against
187191 */
188192 public Version getUsedDatabaseVersion () {
189- if ( compatibilityProxy != null )
193+ if (compatibilityProxy != null ) {
190194 return compatibilityProxy .getDatabaseVersion ();
191- else
195+ } else {
192196 return null ;
197+ }
193198 }
194199
195200}
0 commit comments