8000 move common fields and methods from Suite/Test to Item · utPLSQL/utPLSQL-SQLDeveloper@a972c50 · GitHub
[go: up one dir, main page]

Skip to content

Commit a972c50

Browse files
move common fields and methods from Suite/Test to Item
1 parent ad912ba commit a972c50

File tree

3 files changed

+93
-82
lines changed

3 files changed

+93
-82
lines changed

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;
8000 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
}

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

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import org.utplsql.sqldev.model.JsonToStringStyler;
2323

2424
public class Suite extends Item {
25-
private String name;
26-
private String description;
2725
private List<Item> items;
2826

2927
public Suite() {
@@ -35,36 +33,24 @@ public String toString() {
3533
return new ToStringCreator(this, JsonToStringStyler.getInstance())
3634
// ancestor
3735
.append("id", getId())
36+
.append("name", getName())
37+
.append("description", getDescription())
3838
.append("startTime", getStartTime())
3939
.append("endTime", getEndTime())
4040
.append("executionTime", getExecutionTime())
4141
.append("counter", getCounter())
4242
.append("errorStack", getErrorStack())
4343
.append("serverOutput", getServerOutput())
4444
.append("warnings", getWarnings())
45+
.append("parentId", getParentId())
46+
.append("statusIcon", getStatusIcon())
47+
.append("warningIcon", getWarningIcon())
48+
.append("infoIcon", getInfoIcon())
4549
// local
46-
.append("name", name)
47-
.append("description", description)
4850
.append("items", items)
4951
.toString();
5052
}
5153

52-
public String getName() {
53-
return name;
54-
}
55-
56-
public void setName(final String name) {
57-
this.name = name;
58-
}
59-
60-
public String getDescription() {
61-
return description;
62-
}
63-
64-
public void setDescription(final String description) {
65-
this.description = description;
66-
}
67-
6854
public List<Item> getItems() {
6955
return items;
7056
}

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

Lines changed: 6 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,15 @@
1717

1818
import java.util.List;
1919

20-
import javax.swing.Icon;
21-
2220
import org.springframework.core.style.ToStringCreator;
2321
import org.utplsql.sqldev.model.JsonToStringStyler;
24-
import org.utplsql.sqldev.resources.UtplsqlResources;
2522

2623
public class Test extends Item {
2724
private String executableType;
2825
private String ownerName;
2926
private String objectName;
3027
private String procedureName;
3128
private Boolean disabled;
32-
private String name;
33-
private String description;
3429
private Integer testNumber;
3530
private List<Expectation> failedExpectations;
3631

@@ -39,65 +34,30 @@ public String toString() {
3934
return new ToStringCreator(this, JsonToStringStyler.getInstance())
4035
// ancestor
4136
.append("id", getId())
37+
.append("name", getName())
38+
.append("description", getDescription())
4239
.append("startTime", getStartTime())
4340
.append("endTime", getEndTime())
4441
.append("executionTime", getExecutionTime())
4542
.append("counter", getCounter())
4643
.append("errorStack", getErrorStack())
4744
.append("serverOutput", getServerOutput())
4845
.append("warnings", getWarnings())
46+
.append("parentId", getParentId())
47+
.append("statusIcon", getStatusIcon())
48+
.append("warningIcon", getWarningIcon())
49+
.append("infoIcon", getInfoIcon())
4950
// local
5051
.append("executableType", executableType)
5152
.append("ownerName", ownerName)
5253
.append("objectName", objectName)
5354
.append("procedureName", procedureName)
5455
.append("disabled", disabled)
55-
.append("name", name)
56-
.append("description", description)
5756
.append("testNumber", testNumber)
5857
.append("failedExpectations", failedExpectations)
59-
.append("statusIcon", getStatusIcon())
60-
.append("warningIcon", getWarningIcon())
61-
.append("infoIcon", getInfoIcon())
6258
.toString();
6359
}
6460

65-
public Icon getStatusIcon() {
66-
Icon icon = null;
67-
if (getStartTime() != null && getEndTime() == null) {
68-
icon = UtplsqlResources.getIcon("PROGRESS_ICON");
69-
} else {
70-
if (getCounter() != null) {
71-
if (getCounter().getSuccess() > 0) {
72-
icon = UtplsqlResources.getIcon("SUCCESS_ICON");
73-
} else if (getCounter().getError() > 0) {
74-
icon = UtplsqlResources.getIcon("ERROR_ICON");
75-
} else if (getCounter().getFailure() > 0) {
76-
icon = UtplsqlResources.getIcon("FAILURE_ICON");
77-
} else if (getCounter().getDisabled() > 0) {
78-
icon = UtplsqlResources.getIcon("DISABLED_ICON");
79-
}
80-
}
81-
}
82-
return icon;
83-
}
84-
85-
public Icon getWarningIcon() {
86-
Icon icon = null;
87-
if (getCounter() != null && getCounter().getWarning() > 0) {
88-
icon = UtplsqlResources.getIcon("WARNING_ICON");
89-
}
90-
return icon;
91-
}
92-
93-
public Icon getInfoIcon() {
94-
Icon icon = null;
95-
if (getServerOutput() != null && getServerOutput().length() > 0) {
96-
icon = UtplsqlResources.getIcon("INFO_ICON");
97-
}
98-
return icon;
99-
}
100-
10161
public String getExecutableType() {
10262
return executableType;
10363
}
@@ -138,22 +98,6 @@ public void setDisabled(final Boolean disabled) {
13898
this.disabled = disabled;
13999
}
140100

141-
public String getName() {
142-
return name;
143-
}
144-
145-
public void setName(final String name) {
146-
this.name = name;
147-
}
148-
149-
public String getDescription() {
150-
return description;
151-
}
152-
153-
public void setDescription(final String description) {
154-
this.description = description;
155-
}
156-
157101
public Integer getTestNumber() {
158102
return testNumber;
159103
}

0 commit comments

Comments
 (0)
0