Skip to content

Commit c0757c4

Browse files
authored
Merge pull request #11 from viniciusam/bugfix/test_runner_null_param
Test runner null params and html reporter default assets path
2 parents f2ba5ed + ffc110c commit c0757c4

File tree

2 files changed

+56
-23
lines changed

2 files changed

+56
-23
lines changed

src/main/java/io/github/utplsql/api/TestRunner.java

Lines changed: 51 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public TestRunner addPath(String path) {
2828
}
2929

3030
public TestRunner addPathList(List<String> paths) {
31-
this.pathList.addAll(paths);
31+
if (pathList != null) this.pathList.addAll(paths);
3232
return this;
3333
}
3434

@@ -43,7 +43,7 @@ public TestRunner colorConsole(boolean colorConsole) {
4343
}
4444

4545
public TestRunner addReporterList(List<Reporter> reporterList) {
46-
this.reporterList.addAll(reporterList);
46+
if (reporterList != null) this.reporterList.addAll(reporterList);
4747
return this;
4848
}
4949

@@ -53,12 +53,12 @@ public TestRunner addCoverageScheme(String coverageScheme) {
5353
}
5454

5555
public TestRunner withSourceFiles(List<String> sourceFiles) {
56-
this.sourceFiles.addAll(sourceFiles);
56+
if (sourceFiles != null) this.sourceFiles.addAll(sourceFiles);
5757
return this;
5858
}
5959

6060
public TestRunner withTestFiles(List<String> testFiles) {
61-
this.testFiles.addAll(testFiles);
61+
if (testFiles != null) this.testFiles.addAll(testFiles);
6262
return this;
6363
}
6464

@@ -84,34 +84,63 @@ public void run(Connection conn) throws SQLException {
8484
this.reporterList.add(new DocumentationReporter().init(conn));
8585
}
8686

87-
OracleConnection oraConn = conn.unwrap(OracleConnection.class);
88-
Array pathArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.pathList.toArray());
89-
Array reporterArray = oraConn.createARRAY(CustomTypes.UT_REPORTERS, this.reporterList.toArray());
90-
Array coverageSchemesArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.coverageSchemes.toArray());
91-
Array sourceFilesArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.sourceFiles.toArray());
92-
Array testFilesArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.testFiles.toArray());
93-
Array includeObjectsArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.includeObjects.toArray());
94-
Array excludeObjectsArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.excludeObjects.toArray());
95-
9687
// Workaround because Oracle JDBC doesn't support passing boolean to stored procedures.
9788
String colorConsoleStr = Boolean.toString(this.colorConsole);
9889

90+
OracleConnection oraConn = conn.unwrap(OracleConnection.class);
9991
CallableStatement callableStatement = null;
10092
try {
10193
callableStatement = conn.prepareCall(
10294
"BEGIN " +
103-
"ut_runner.run(" +
95+
"ut_runner.run(" +
10496
"a_paths => ?, a_reporters => ?, a_color_console => " + colorConsoleStr + ", " +
10597
"a_coverage_schemes => ?, a_source_files => ?, a_test_files => ?, " +
10698
"a_include_objects => ?, a_exclude_objects => ?); " +
107-
"END;");
108-
callableStatement.setArray(1, pathArray);
109-
callableStatement.setArray(2, reporterArray);
110-
callableStatement.setArray(3, coverageSchemesArray);
111-
callableStatement.setArray(4, sourceFilesArray);
112-
callableStatement.setArray(5, testFilesArray);
113-
callableStatement.setArray(6, includeObjectsArray);
114-
callableStatement.setArray(7, excludeObjectsArray);
99+
"END;");
100+
101+
int paramIdx = 0;
102+
103+
callableStatement.setArray(
104+
++paramIdx, oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.pathList.toArray()));
105+
106+
callableStatement.setArray(
107+
++paramIdx, oraConn.createARRAY(CustomTypes.UT_REPORTERS, this.reporterList.toArray()));
108+
109+
if (this.coverageSchemes.isEmpty()) {
110+
callableStatement.setNull(++paramIdx, Types.ARRAY, CustomTypes.UT_VARCHAR2_LIST);
111+
} else {
112+
callableStatement.setArray(
113+
++paramIdx, oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.coverageSchemes.toArray()));
114+
}
115+
116+
if (this.sourceFiles.isEmpty()) {
117+
callableStatement.setNull(++paramIdx, Types.ARRAY, CustomTypes.UT_VARCHAR2_LIST);
118+
} else {
119+
callableStatement.setArray(
120+
++paramIdx, oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.sourceFiles.toArray()));
121+
}
122+
123+
if (this.testFiles.isEmpty()) {
124+
callableStatement.setNull(++paramIdx, Types.ARRAY, CustomTypes.UT_VARCHAR2_LIST);
125+
} else {
126+
callableStatement.setArray(
127+
++paramIdx, oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.testFiles.toArray()));
128+
}
129+
130+
if (this.includeObjects.isEmpty()) {
131+
callableStatement.setNull(++paramIdx, Types.ARRAY, CustomTypes.UT_VARCHAR2_LIST);
132+
} else {
133+
callableStatement.setArray(
134+
++paramIdx, oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.includeObjects.toArray()));
135+
}
136+
137+
if (this.excludeObjects.isEmpty()) {
138+
callableStatement.setNull(++paramIdx, Types.ARRAY, CustomTypes.UT_VARCHAR2_LIST);
139+
} else {
140+
callableStatement.setArray(
141+
++paramIdx, oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.excludeObjects.toArray()));
142+
}
143+
115144
callableStatement.execute();
116145
} finally {
117146
if (callableStatement != null)

src/main/java/io/github/utplsql/api/reporter/CoverageHTMLReporter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@
88

99
public class CoverageHTMLReporter extends Reporter {
1010

11+
// Could override Reporter.init and call ut_coverage_report_html_helper.get_default_html_assets_path from database,
12+
// but had permissions issues.
13+
public static final String DEFAULT_ASSETS_PATH = "https://utplsql.github.io/utPLSQL-coverage-html/assets/";
14+
1115
private String projectName;
1216
private String assetsPath;
1317

1418
public CoverageHTMLReporter() {
15-
19+
this(null, DEFAULT_ASSETS_PATH);
1620
}
1721

1822
public CoverageHTMLReporter(String projectName, String assetsPath) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy