Skip to content

Commit d8cbce2

Browse files
committed
RunAction tested and functional so far
1 parent f9c4cf7 commit d8cbce2

File tree

3 files changed

+41
-10
lines changed

3 files changed

+41
-10
lines changed

src/main/java/org/utplsql/cli/ReporterManager.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.sql.Connection;
1414
import java.sql.SQLException;
1515
import java.util.ArrayList;
16+
import java.util.Arrays;
1617
import java.util.List;
1718
import java.util.concurrent.ExecutorService;
1819

@@ -23,10 +24,16 @@ class ReporterManager {
2324
private ExecutorService executorService;
2425

2526
ReporterManager(List<String> reporterParams ) {
26-
initReporterOptionsList(reporterParams);
27+
parseReporterOptionsList(reporterParams);
28+
initReporterOptionsList();
2729
}
2830

29-
private void initReporterOptionsList( List<String> reporterParams ) {
31+
ReporterManager( ReporterOptions[] reporterOptions ) {
32+
this.reporterOptionsList = Arrays.asList(reporterOptions);
33+
initReporterOptionsList();
34+
}
35+
36+
private void parseReporterOptionsList( List<String> reporterParams ) {
3037
reporterOptionsList = new ArrayList<>();
3138
ReporterOptions reporterOptions = null;
3239

@@ -44,13 +51,21 @@ private void initReporterOptionsList( List<String> reporterParams ) {
4451
reporterOptions.forceOutputToScreen(true);
4552
}
4653
}
54+
}
55+
56+
private void initReporterOptionsList( ) {
4757

4858
// If no reporter parameters were passed, use default reporter.
4959
if (reporterOptionsList.isEmpty()) {
50-
reporterOptionsList.add(new ReporterOptions(CoreReporters.UT_DOCUMENTATION_REPORTER.name()));
60+
reporterOptionsList = new ArrayList<>();
61+
reporterOptionsList.add(getDefaultReporterOption());
5162
}
5263
}
5364

65+
private ReporterOptions getDefaultReporterOption() {
66+
return new ReporterOptions(CoreReporters.UT_DOCUMENTATION_REPORTER.name());
67+
}
68+
5469
private void abortGathering(Throwable e) {
5570
addGatherError(e);
5671
executorService.shutdownNow();

src/main/java/org/utplsql/cli/RunAction.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.utplsql.api.reporter.Reporter;
1717
import org.utplsql.api.reporter.ReporterFactory;
1818
import org.utplsql.cli.config.FileMapperConfig;
19+
import org.utplsql.cli.config.ReporterConfig;
1920
import org.utplsql.cli.config.RunCommandConfig;
2021
import org.utplsql.cli.exception.DatabaseConnectionFailed;
2122
import org.utplsql.cli.exception.ReporterTimeoutException;
@@ -54,6 +55,10 @@ void init() {
5455
LoggerConfiguration.configure(config.getLogConfigLevel());
5556
}
5657

58+
public RunCommandConfig getConfig() {
59+
return config;
60+
}
61+
5762
public int doRun() throws OracleCreateStatmenetStuckException {
5863
init();
5964
outputMainInformation();
@@ -270,9 +275,20 @@ private CompatibilityProxy checkFrameworkCompatibility(Connection conn) throws S
270275
}
271276

272277
private ReporterManager getReporterManager() {
273-
ArrayList<String> reporterParams = new ArrayList<>();
274-
if ( reporterManager == null )
275-
reporterManager = new ReporterManager(reporterParams);
278+
if ( reporterManager == null ) {
279+
280+
ReporterConfig[] reporterConfigs = config.getReporters();
281+
if ( reporterConfigs != null ) {
282+
ReporterOptions[] options = new ReporterOptions[reporterConfigs.length];
283+
for (int i = 0; i<reporterConfigs.length; i++ ) {
284+
options[i] = new ReporterOptions(
285+
reporterConfigs[i].getName(),
286+
reporterConfigs[i].getOutput(),
287+
reporterConfigs[i].isScreen());
288+
}
289+
reporterManager = new ReporterManager(options);
290+
}
291+
}
276292

277293
return reporterManager;
278294
}

src/test/java/org/utplsql/cli/RunActionTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void reporterOptions_TwoReporters() throws Exception {
8181
assertEquals(CoreReporters.UT_DOCUMENTATION_REPORTER.name(), reporterOptions1.getReporterName());
8282
assertNull(reporterOptions1.getOutputFileName());
8383
assertFalse(reporterOptions1.outputToFile());
84-
assertTrue(reporterOptions1.outputToScreen());
84+
assertFalse(reporterOptions1.outputToScreen());
8585

8686
ReporterOptions reporterOptions2 = reporterOptionsList.get(1);
8787
assertEquals(CoreReporters.UT_COVERAGE_HTML_REPORTER.name(), reporterOptions2.getReporterName());
@@ -90,13 +90,13 @@ void reporterOptions_TwoReporters() throws Exception {
9090
assertTrue(reporterOptions2.outputToScreen());
9191
}
9292

93-
/*@Test
93+
@Test
9494
void connectionString_asSysdba() throws Exception {
9595
RunAction runCmd = TestHelper.createRunAction("sys as sysdba/mypass@connectstring/service");
9696

9797
assertEquals("sys as sysdba/mypass@connectstring/service",
98-
runCmd.getConnectionInfo().getConnectionString());
99-
}*/
98+
runCmd.getConfig().getConnectString());
99+
}
100100

101101
@Test
102102
void randomOrder_default() throws Exception {

0 commit comments

Comments
 (0)