-
Notifications
You must be signed in to change notification settings - Fork 16
Feature/new cli library #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
6717057
038981f
b21f651
ce849fc
5520562
f9c4cf7
d8cbce2
3b5e168
60997d7
d13ae5b
5e86b01
00f3f5f
2ce4e91
b88d5c5
c80dc8c
8eec2cb
ded39d3
6922e52
5aa4c1d
60fcfaf
a3608b5
09bf357
1b65b51
77fd752
e443e3c
0bdca7d
ae0e9c4
f47c0de
bb18ea1
1a984ff
81e0953
a8acbb9
10bef7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| import org.utplsql.api.reporter.CoreReporters; | ||
| import org.utplsql.api.reporter.Reporter; | ||
| import org.utplsql.api.reporter.ReporterFactory; | ||
| import org.utplsql.cli.config.ReporterConfig; | ||
| import org.utplsql.cli.reporters.ReporterOptionsAware; | ||
|
|
||
| import javax.sql.DataSource; | ||
|
|
@@ -13,7 +14,6 @@ | |
| import java.sql.Connection; | ||
| import java.sql.SQLException; | ||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.concurrent.ExecutorService; | ||
|
|
||
|
|
@@ -23,17 +23,30 @@ class ReporterManager { | |
| private List<Throwable> reporterGatherErrors; | ||
| private ExecutorService executorService; | ||
|
|
||
| ReporterManager( ReporterOptions[] reporterOptions ) { | ||
| this.reporterOptionsList = Arrays.asList(reporterOptions); | ||
| initReporterOptionsList(); | ||
| ReporterManager(ReporterConfig[] reporterConfigs ) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me share with you my point. I prefere to use simple constructors and use factory methods for all necessary operation neede to call the constructor. I don't like calling functions from a constructor as it doesn't allow making fields final and I personnaly like final fields. Do you mind making a small refactoring of this place?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean like public static ReporterManager create( ReporterConfig[] reporterConfigs ) { ...?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes with all necessary stuff populating arrays done there and then call a simple private constructor. |
||
| reporterOptionsList = new ArrayList<>(); | ||
| if ( reporterConfigs != null && reporterConfigs.length > 0 ) { | ||
| loadOptionsFromConfigs( reporterConfigs ); | ||
| } | ||
| else { | ||
| reporterOptionsList.add(getDefaultReporterOption()); | ||
| } | ||
| } | ||
|
|
||
| private void initReporterOptionsList( ) { | ||
| private void loadOptionsFromConfigs( ReporterConfig[] reporterConfigs ) { | ||
| boolean printToScreen = false; | ||
| for (ReporterConfig reporterConfig : reporterConfigs) { | ||
| ReporterOptions option = new ReporterOptions( | ||
| reporterConfig.getName(), | ||
| reporterConfig.getOutput()); | ||
|
|
||
| // If no reporter parameters were passed, use default reporter. | ||
| if (reporterOptionsList.isEmpty()) { | ||
| reporterOptionsList = new ArrayList<>(); | ||
| reporterOptionsList.add(getDefaultReporterOption()); | ||
| option.forceOutputToScreen(reporterConfig.isForceToScreen()); | ||
| reporterOptionsList.add(option); | ||
|
|
||
| // Check printToScreen validity | ||
| if (option.outputToScreen() && printToScreen) | ||
| throw new IllegalArgumentException("You cannot configure more than one reporter to output to screen"); | ||
| printToScreen = option.outputToScreen(); | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we gather Errors? if not, lets make it
List<Exception>