Skip to content

Test runner null params and html reporter default assets path #11

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

Merged
merged 2 commits into from
Jun 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 51 additions & 22 deletions src/main/java/io/github/utplsql/api/TestRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public TestRunner addPath(String path) {
}

public TestRunner addPathList(List<String> paths) {
this.pathList.addAll(paths);
if (pathList != null) this.pathList.addAll(paths);
return this;
}

Expand All @@ -43,7 +43,7 @@ public TestRunner colorConsole(boolean colorConsole) {
}

public TestRunner addReporterList(List<Reporter> reporterList) {
this.reporterList.addAll(reporterList);
if (reporterList != null) this.reporterList.addAll(reporterList);
return this;
}

Expand All @@ -53,12 +53,12 @@ public TestRunner addCoverageScheme(String coverageScheme) {
}

public TestRunner withSourceFiles(List<String> sourceFiles) {
this.sourceFiles.addAll(sourceFiles);
if (sourceFiles != null) this.sourceFiles.addAll(sourceFiles);
return this;
}

public TestRunner withTestFiles(List<String> testFiles) {
this.testFiles.addAll(testFiles);
if (testFiles != null) this.testFiles.addAll(testFiles);
return this;
}

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

OracleConnection oraConn = conn.unwrap(OracleConnection.class);
Array pathArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.pathList.toArray());
Array reporterArray = oraConn.createARRAY(CustomTypes.UT_REPORTERS, this.reporterList.toArray());
Array coverageSchemesArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.coverageSchemes.toArray());
Array sourceFilesArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.sourceFiles.toArray());
Array testFilesArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.testFiles.toArray());
Array includeObjectsArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.includeObjects.toArray());
Array excludeObjectsArray = oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.excludeObjects.toArray());

// Workaround because Oracle JDBC doesn't support passing boolean to stored procedures.
String colorConsoleStr = Boolean.toString(this.colorConsole);

OracleConnection oraConn = conn.unwrap(OracleConnection.class);
CallableStatement callableStatement = null;
try {
callableStatement = conn.prepareCall(
"BEGIN " +
"ut_runner.run(" +
"ut_runner.run(" +
"a_paths => ?, a_reporters => ?, a_color_console => " + colorConsoleStr + ", " +
"a_coverage_schemes => ?, a_source_files => ?, a_test_files => ?, " +
"a_include_objects => ?, a_exclude_objects => ?); " +
"END;");
callableStatement.setArray(1, pathArray);
callableStatement.setArray(2, reporterArray);
callableStatement.setArray(3, coverageSchemesArray);
callableStatement.setArray(4, sourceFilesArray);
callableStatement.setArray(5, testFilesArray);
callableStatement.setArray(6, includeObjectsArray);
callableStatement.setArray(7, excludeObjectsArray);
"END;");

int paramIdx = 0;

callableStatement.setArray(
++paramIdx, oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.pathList.toArray()));

callableStatement.setArray(
++paramIdx, oraConn.createARRAY(CustomTypes.UT_REPORTERS, this.reporterList.toArray()));

if (this.coverageSchemes.isEmpty()) {
callableStatement.setNull(++paramIdx, Types.ARRAY, CustomTypes.UT_VARCHAR2_LIST);
} else {
callableStatement.setArray(
++paramIdx, oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.coverageSchemes.toArray()));
}

if (this.sourceFiles.isEmpty()) {
callableStatement.setNull(++paramIdx, Types.ARRAY, CustomTypes.UT_VARCHAR2_LIST);
} else {
callableStatement.setArray(
++paramIdx, oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.sourceFiles.toArray()));
}

if (this.testFiles.isEmpty()) {
callableStatement.setNull(++paramIdx, Types.ARRAY, CustomTypes.UT_VARCHAR2_LIST);
} else {
callableStatement.setArray(
++paramIdx, oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.testFiles.toArray()));
}

if (this.includeObjects.isEmpty()) {
callableStatement.setNull(++paramIdx, Types.ARRAY, CustomTypes.UT_VARCHAR2_LIST);
} else {
callableStatement.setArray(
++paramIdx, oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.includeObjects.toArray()));
}

if (this.excludeObjects.isEmpty()) {
callableStatement.setNull(++paramIdx, Types.ARRAY, CustomTypes.UT_VARCHAR2_LIST);
} else {
callableStatement.setArray(
++paramIdx, oraConn.createARRAY(CustomTypes.UT_VARCHAR2_LIST, this.excludeObjects.toArray()));
}

callableStatement.execute();
} finally {
if (callableStatement != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@

public class CoverageHTMLReporter extends Reporter {

// Could override Reporter.init and call ut_coverage_report_html_helper.get_default_html_assets_path from database,
// but had permissions issues.
public static final String DEFAULT_ASSETS_PATH = "https://utplsql.github.io/utPLSQL-coverage-html/assets/";

private String projectName;
private String assetsPath;

public CoverageHTMLReporter() {

this(null, DEFAULT_ASSETS_PATH);
}

public CoverageHTMLReporter(String projectName, String assetsPath) {
Expand Down