Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8be0c92
add methods produceReportWithCoverage and getHtmlCoverage
PhilippSalvisberg May 30, 2020
9605a71
add test for produceReportWithCoverage
PhilippSalvisberg May 30, 2020
c18c484
execute setup and teardown per test
PhilippSalvisberg May 30, 2020
758872c
add null checks for parameters
PhilippSalvisberg May 30, 2020
55b8727
add public openInBrowser method
PhilippSalvisberg May 30, 2020
fd0d3df
reuse code coverage test setup with actual coverage result
PhilippSalvisberg May 30, 2020
5284796
add support to run tests with code coverage in one run
PhilippSalvisberg May 30, 2020
b1985e6
add test with code coverage
PhilippSalvisberg May 30, 2020
e280483
run code coverage via realtime reporter if possible
PhilippSalvisberg May 30, 2020
22610ee
no dedicated connection required anymore
PhilippSalvisberg May 30, 2020
e677de7
configure default fetch size of 100 (except for consumeReport)
PhilippSalvisberg May 30, 2020
667b5fc
add resources for code coverage (icon and tooltip text)
PhilippSalvisberg May 30, 2020
c2e7b12
calculate default schemas and provide getter; handle test env.
PhilippSalvisberg May 30, 2020
acfb60e
populate default value for schemas under test
PhilippSalvisberg May 30, 2020
6f5e7cb
test calcuation of default schemas under test
PhilippSalvisberg May 30, 2020
89565a4
add code coverage to toolbar of realtime reporter (all tests)
PhilippSalvisberg May 30, 2020
d589045
use list of schemas instead of top schema as default
PhilippSalvisberg May 30, 2020
84ffaeb
amend test based on new default logic
PhilippSalvisberg May 30, 2020
64cbad0
add code coverage context menu on overview table
PhilippSalvisberg May 30, 2020
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
Prev Previous commit
Next Next commit
calculate default schemas and provide getter; handle test env.
  • Loading branch information
PhilippSalvisberg committed May 30, 2020
commit c2e7b12dc8041710b5b5faf817876d6beaa3fe0d
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.logging.Logger;

import org.utplsql.sqldev.dal.RealtimeReporterDao;
Expand Down Expand Up @@ -53,6 +57,7 @@ public CodeCoverageReporter(final List<String> pathList, final List<String> incl
final String connectionName) {
this.pathList = pathList;
this.includeObjectList = includeObjectList;
setDefaultSchema();
setConnection(connectionName);
}

Expand All @@ -62,6 +67,7 @@ public CodeCoverageReporter(final List<String> pathList, final List<String> incl
this.pathList = pathList;
this.includeObjectList = includeObjectList;
this.conn = conn;
setDefaultSchema();
}

private void setConnection(final String connectionName) {
Expand All @@ -75,6 +81,31 @@ private void setConnection(final String connectionName) {
this.conn = DatabaseTools.getConnection(connectionName);
}
}

private void setDefaultSchema() {
if (includeObjectList != null && !includeObjectList.isEmpty()) {
// use the owner with the most hits in includeObjectList
HashMap<String, Integer> owners = new HashMap<>();
for (String entry : includeObjectList) {
String[] obj = entry.toUpperCase().split("\\.");
if (obj.length == 2) {
// only if objectOwner and objectName are available
Integer count = owners.get(obj[0]);
if (count == null) {
count = 1;
} else {
count++;
}
owners.put(obj[0], count);
}
}
Optional<Entry<String, Integer>> top = owners.entrySet().stream()
.sorted(Map.Entry.<String, Integer>comparingByValue().reversed()).findFirst();
if (top.isPresent()) {
schemas = top.get().getKey();
}
}
}

private ArrayList<String> toStringList(final String s) {
final ArrayList<String> list = new ArrayList<>();
Expand All @@ -92,8 +123,14 @@ private void run() {
logger.fine(() -> "Running code coverage reporter for " + pathList + "...");
try {
final RealtimeReporterDao dao = new RealtimeReporterDao(conn);
final PreferenceModel preferences = PreferenceModel.getInstance(Preferences.getPreferences());
if (preferences.isUseRealtimeReporter() && dao.isSupported()) {
PreferenceModel preferences;
try {
preferences = PreferenceModel.getInstance(Preferences.getPreferences());
} catch (NoClassDefFoundError error) {
// not running in SQL Developer (in tests)
preferences = PreferenceModel.getInstance(null);
}
if (preferences.isUseRealtimeReporter() && dao.isSupported() && connectionName != null) {
runCodeCoverageWithRealtimeReporter();
} else {
runCodeCoverageStandalone();
Expand Down Expand Up @@ -181,6 +218,10 @@ public void setSchemas(final String schemas) {
this.schemas = schemas;
}

public String getSchemas() {
return schemas;
}

public void setIncludeObjects(final String includeObjects) {
this.includeObjects = includeObjects;
}
Expand Down