Skip to content

Commit 32ef3e1

Browse files
Merge pull request #123 from utPLSQL/feature/issue-65-hierarchical-view
#65 - Alternative hierarchical view
2 parents 8dfb38f + 4d28aa9 commit 32ef3e1

37 files changed

+1960
-322
lines changed

images/runner_model.png

64.9 KB
Loading

sqldev/src/main/java/org/utplsql/sqldev/model/StringTools.java

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@
1515
*/
1616
package org.utplsql.sqldev.model;
1717

18+
import java.text.ParseException;
19+
import java.text.SimpleDateFormat;
1820
import java.util.Collections;
21+
import java.util.Date;
1922
import java.util.List;
2023

24+
import org.utplsql.sqldev.exception.GenericRuntimeException;
25+
2126
public class StringTools {
2227
// do not instantiate this class
2328
private StringTools() {
@@ -38,11 +43,11 @@ public static String getCSV(List<String> list, String indent) {
3843
sb.append("\n");
3944
return sb.toString();
4045
}
41-
46+
4247
public static String getCSV(List<String> list, int indentSpaces) {
4348
return getCSV(list, repeat(" ", indentSpaces));
4449
}
45-
50+
4651
public static String getSimpleCSV(List<String> list) {
4752
final StringBuilder sb = new StringBuilder();
4853
for (final String item : list) {
@@ -74,4 +79,45 @@ public static String formatDateTime(final String dateTime) {
7479
}
7580
}
7681
}
82+
83+
public static String millisToDateTimeString(long millis) {
84+
final Date dateTime = new Date(millis);
85+
final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'000'");
86+
return df.format(dateTime);
87+
}
88+
89+
public static String getSysdate() {
90+
return millisToDateTimeString(System.currentTimeMillis());
91+
}
92+
93+
public static long dateTimeStringToMillis(final String dateTime) {
94+
// handle milliseconds separately since they get lost (rounded) when converted to date
95+
final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
96+
Date date;
97+
try {
98+
date = df.parse(dateTime.substring(0, 20));
99+
} catch (ParseException e) {
100+
throw new GenericRuntimeException("cannot parse datetime string " + dateTime + ".", e);
101+
}
102+
long millis = Long.parseLong(dateTime.substring(20, 23));
103+
return date.getTime() + millis;
104+
}
105+
106+
public static double elapsedTime(String startDateTime, String endDateTime) {
107+
double start = (double) dateTimeStringToMillis(startDateTime);
108+
double end = (double) dateTimeStringToMillis(endDateTime);
109+
return (end - start) / 1000;
110+
}
111+
112+
public static boolean isNotBlank(String value) {
113+
return value != null && !value.trim().isEmpty();
114+
}
115+
116+
public static String trim(String value) {
117+
if (value == null) {
118+
return null;
119+
}
120+
return value.trim();
121+
}
122+
77123
}

sqldev/src/main/java/org/utplsql/sqldev/model/preference/PreferenceModel.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public static PreferenceModel getInstance(final PropertyStorage prefs) {
5353
private static final String KEY_SHOW_DISABLED_TESTS = "showDisabledTests";
5454
private static final String KEY_SHOW_TEST_DESCRIPTION = "showTestDescription";
5555
private static final String KEY_SYNC_DETAIL_TAB = "syncDetailTab";
56+
private static final String KEY_SHOW_SUITES = "showSuites";
5657
private static final String KEY_TEST_PACKAGE_PREFIX = "testPackagePrefix";
5758
private static final String KEY_TEST_PACKAGE_SUFFIX = "testPackageSuffix";
5859
private static final String KEY_TEST_UNIT_PREFIX = "testUnitPrefix";
@@ -88,6 +89,7 @@ public String toString() {
8889
.append(KEY_SHOW_DISABLED_TESTS, isShowDisabledTests())
8990
.append(KEY_SHOW_TEST_DESCRIPTION, isShowTestDescription())
9091
.append(KEY_SYNC_DETAIL_TAB, isSyncDetailTab())
92+
.append(KEY_SHOW_SUITES, isShowSuites())
9193
.append(KEY_TEST_PACKAGE_PREFIX, getTestPackagePrefix())
9294
.append(KEY_TEST_PACKAGE_SUFFIX, getTestPackageSuffix())
9395
.append(KEY_TEST_UNIT_PREFIX, getTestUnitPrefix())
@@ -241,6 +243,14 @@ public void setSyncDetailTab(final boolean syncDetailTab) {
241243
getHashStructure().putBoolean(KEY_SYNC_DETAIL_TAB, syncDetailTab);
242244
}
243245

246+
public boolean isShowSuites() {
247+
return getHashStructure().getBoolean(KEY_SHOW_SUITES, true);
248+
}
249+
250+
public void setShowSuites(final boolean showSuites) {
251+
getHashStructure().putBoolean(KEY_SHOW_SUITES, showSuites);
252+
}
253+
244254
public String getTestPackagePrefix() {
245255
return getHashStructure().getString(KEY_TEST_PACKAGE_PREFIX, "test_");
246256
}

sqldev/src/main/java/org/utplsql/sqldev/model/runner/Item.java

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@
1515
*/
1616
package org.utplsql.sqldev.model.runner;
1717

18+
import javax.swing.Icon;
19+
1820
import org.springframework.core.style.ToStringCreator;
1921
import org.utplsql.sqldev.model.JsonToStringStyler;
22+
import org.utplsql.sqldev.resources.UtplsqlResources;
2023

2124
public abstract class Item {
2225
private String id;
26+
private String name;
27+
private String description;
2328
private String startTime;
2429
private String endTime;
2530
private Double executionTime;
@@ -36,15 +41,75 @@ public Item() {
3641
public String toString() {
3742
return new ToStringCreator(this, JsonToStringStyler.getInstance())
3843
.append("id", id)
44+
.append("name", name)
45+
.append("description", description)
3946
.append("startTime", startTime)
4047
.append("endTime", endTime)
4148
.append("executionTime", executionTime)
4249
.append("counter", counter)
4350
.append("errorStack", errorStack)
4451
.append("serverOutput", serverOutput)
4552
.append("warnings", warnings)
53+
.append("parentId", getParentId())
54+
.append("statusIcon", getStatusIcon())
55+
.append("warningIcon", getWarningIcon())
56+
.append("infoIcon", getInfoIcon())
4657
.toString();
4758
}
59+
60+
public String getParentId() {
61+
// Works only if id (suitepath) is build based on names delimited with a period
62+
// that's expected for real utPLSQL runs, but may fail for artificial runs.
63+
// Returning null is valid, it means this item has no parent and as a
64+
// consequence it will be shown on the top level in the runner.
65+
// A key is required to identify an item since suites can be delivered
66+
// multiple times, e.g. when running a chosen list of tests. This way
67+
// the tests will shown at the right position in the tree, regardless of the call
68+
// parameters.
69+
if (name != null && id != null && name.length() < id.length() && id.endsWith(name)) {
70+
return id.substring(0, id.length() - name.length() - 1);
71+
}
72+
return null;
73+
}
74+
75+
public Icon getStatusIcon() {
76+
Icon icon = null;
77+
if (getStartTime() != null && getEndTime() == null) {
78+
icon = UtplsqlResources.getIcon("PROGRESS_ICON");
79+
} else {
80+
if (getCounter() != null) {
81+
// Escalation logic as for the color of the progress bar.
82+
// A suite with errors or failed tests cannot be considered successful,
83+
// even if some tests completed successfully.
84+
if (getCounter().getError() > 0) {
85+
icon = UtplsqlResources.getIcon("ERROR_ICON");
86+
} else if (getCounter().getFailure() > 0) {
87+
icon = UtplsqlResources.getIcon("FAILURE_ICON");
88+
} else if (getCounter().getSuccess() > 0) {
89+
icon = UtplsqlResources.getIcon("SUCCESS_ICON");
90+
} else if (getCounter().getDisabled() > 0) {
91+
icon = UtplsqlResources.getIcon("DISABLED_ICON");
92+
}
93+
}
94+
}
95+
return icon;
96+
}
97+
98+
public Icon getWarningIcon() {
99+
Icon icon = null;
100+
if (getCounter() != null && getCounter().getWarning() > 0) {
101+
icon = UtplsqlResources.getIcon("WARNING_ICON");
102+
}
103+
return icon;
104+
}
105+
106+
public Icon getInfoIcon() {
107+
Icon icon = null;
108+
if (getServerOutput() != null && getServerOutput().length() > 0) {
109+
icon = UtplsqlResources.getIcon("INFO_ICON");
110+
}
111+
return icon;
112+
}
48113

49114
public String getId() {
50115
return id;
@@ -54,6 +119,22 @@ public void setId(final String id) {
54119
this.id = id;
55120
}
56121

122+
public String getName() {
123+
return name;
124+
}
125+
126+
public void setName(final String name) {
127+
this.name = name;
128+
}
129+
130+
public String getDescription() {
131+
return description;
132+
}
133+
134+
public void setDescription(final String description) {
135+
this.description = description;
136+
}
137+
57138
public String getStartTime() {
58139
return startTime;
59140
}

0 commit comments

Comments
 (0)