Skip to content

Commit 67013ea

Browse files
convert Run to Java
1 parent 19efd63 commit 67013ea

1 file changed

Lines changed: 216 additions & 63 deletions

File tree

  • sqldev/src/main/java/org/utplsql/sqldev/model/runner

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

Lines changed: 216 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -13,67 +13,220 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.utplsql.sqldev.model.runner
17-
18-
import java.util.LinkedHashMap
19-
import java.util.List
20-
import org.eclipse.xtend.lib.annotations.Accessors
21-
22-
@Accessors
23-
class Run {
24-
String reporterId
25-
String connectionName
26-
List<String> pathList
27-
Integer currentTestNumber
28-
Test currentTest
29-
Integer totalNumberOfTests
30-
String startTime
31-
String endTime
32-
Double executionTime
33-
Counter counter
34-
Integer infoCount
35-
String errorStack
36-
String serverOutput
37-
LinkedHashMap<String, Test> tests
38-
String status
39-
Long start
40-
41-
new(String reporterId, String connectionName, List<String> pathList) {
42-
this.reporterId = reporterId
43-
this.connectionName = connectionName
44-
this.pathList = pathList
45-
this.counter = new Counter
46-
this.tests = new LinkedHashMap<String, Test>
47-
}
48-
49-
def void setStartTime(String startTime) {
50-
this.startTime = startTime
51-
start = System.currentTimeMillis
52-
}
53-
54-
def getName() {
55-
val time = startTime.substring(11,19)
56-
val conn = connectionName?.substring(15)
57-
return '''«time» («conn»)'''
58-
}
59-
60-
def void put(List<Item> items) {
61-
for (item : items) {
62-
if (item instanceof Test) {
63-
this.tests.put(item.id, item)
64-
}
65-
if (item instanceof Suite) {
66-
item.items.put
67-
}
68-
}
69-
}
70-
71-
def getTest(String id) {
72-
return tests.get(id)
73-
}
74-
75-
def getTotalNumberOfCompletedTests() {
76-
return counter.disabled + counter.success + counter.failure + counter.error
77-
}
78-
16+
package org.utplsql.sqldev.model.runner;
17+
18+
import java.util.LinkedHashMap;
19+
import java.util.List;
20+
21+
import org.springframework.core.style.ToStringCreator;
22+
import org.utplsql.sqldev.model.UtplsqlToStringStyler;
23+
24+
public class Run {
25+
private String reporterId;
26+
private String connectionName;
27+
private List<String> pathList;
28+
private Integer currentTestNumber;
29+
private Test currentTest;
30+
private Integer totalNumberOfTests;
31+
private String startTime;
32+
private String endTime;
33+
private Double executionTime;
34+
private Counter counter;
35+
private Integer infoCount;
36+
private String errorStack;
37+
private String serverOutput;
38+
private LinkedHashMap<String, Test> tests;
39+
private String status;
40+
private Long start;
41+
42+
@Override
43+
public String toString() {
44+
return new ToStringCreator(this, UtplsqlToStringStyler.INSTANCE)
45+
.append("reporterId", reporterId)
46+
.append("connectionName", connectionName)
47+
.append("pathList", pathList)
48+
.append("currentTestNumber", currentTestNumber)
49+
.append("currentTest", currentTest)
50+
.append("totalNumberOfTests", totalNumberOfTests)
51+
.append("startTime", startTime)
52+
.append("endTime", endTime)
53+
.append("executionTime", executionTime)
54+
.append("counter", counter)
55+
.append("infoCount", infoCount)
56+
.append("errorStack", errorStack)
57+
.append("serverOutput", serverOutput)
58+
.append("tests", tests)
59+
.append("status", status)
60+
.append("start", start)
61+
.append("endTime", endTime)
62+
.append("totalNumberOfCompletedTests", getTotalNumberOfCompletedTests())
63+
.toString();
64+
}
65+
66+
public Run(final String reporterId, final String connectionName, final List<String> pathList) {
67+
this.reporterId = reporterId;
68+
this.connectionName = connectionName;
69+
this.pathList = pathList;
70+
counter = new Counter();
71+
tests = new LinkedHashMap<>();
72+
}
73+
74+
public void setStartTime(final String startTime) {
75+
this.startTime = startTime;
76+
start = Long.valueOf(System.currentTimeMillis());
77+
}
78+
79+
public String getName() {
80+
final String time = startTime.substring(11, 19);
81+
final String conn = connectionName != null ? connectionName.substring(15) : null;
82+
final StringBuilder sb = new StringBuilder();
83+
sb.append(time);
84+
sb.append(" (");
85+
sb.append(conn);
86+
sb.append(")");
87+
return sb.toString();
88+
}
89+
90+
public void put(final List<Item> items) {
91+
for (final Item item : items) {
92+
if (item instanceof Test) {
93+
tests.put(((Test) item).getId(), (Test) item);
94+
}
95+
if (item instanceof Suite) {
96+
put(((Suite) item).getItems());
97+
}
98+
}
99+
}
100+
101+
public Test getTest(final String id) {
102+
return tests.get(id);
103+
}
104+
105+
public int getTotalNumberOfCompletedTests() {
106+
return counter.getDisabled() + counter.getSuccess() + counter.getFailure() + counter.getError();
107+
}
108+
109+
public String getReporterId() {
110+
return reporterId;
111+
}
112+
113+
public void setReporterId(final String reporterId) {
114+
this.reporterId = reporterId;
115+
}
116+
117+
public String getConnectionName() {
118+
return connectionName;
119+
}
120+
121+
public void setConnectionName(final String connectionName) {
122+
this.connectionName = connectionName;
123+
}
124+
125+
public List<String> getPathList() {
126+
return pathList;
127+
}
128+
129+
public void setPathList(final List<String> pathList) {
130+
this.pathList = pathList;
131+
}
132+
133+
public Integer getCurrentTestNumber() {
134+
return currentTestNumber;
135+
}
136+
137+
public void setCurrentTestNumber(final Integer currentTestNumber) {
138+
this.currentTestNumber = currentTestNumber;
139+
}
140+
141+
public Test getCurrentTest() {
142+
return currentTest;
143+
}
144+
145+
public void setCurrentTest(final Test currentTest) {
146+
this.currentTest = currentTest;
147+
}
148+
149+
public Integer getTotalNumberOfTests() {
150+
return totalNumberOfTests;
151+
}
152+
153+
public void setTotalNumberOfTests(final Integer totalNumberOfTests) {
154+
this.totalNumberOfTests = totalNumberOfTests;
155+
}
156+
157+
public String getStartTime() {
158+
return startTime;
159+
}
160+
161+
public String getEndTime() {
162+
return endTime;
163+
}
164+
165+
public void setEndTime(final String endTime) {
166+
this.endTime = endTime;
167+
}
168+
169+
public Double getExecutionTime() {
170+
return executionTime;
171+
}
172+
173+
public void setExecutionTime(final Double executionTime) {
174+
this.executionTime = executionTime;
175+
}
176+
177+
public Counter getCounter() {
178+
return counter;
179+
}
180+
181+
public void setCounter(final Counter counter) {
182+
this.counter = counter;
183+
}
184+
185+
public Integer getInfoCount() {
186+
return infoCount;
187+
}
188+
189+
public void setInfoCount(final Integer infoCount) {
190+
this.infoCount = infoCount;
191+
}
192+
193+
public String getErrorStack() {
194+
return errorStack;
195+
}
196+
197+
public void setErrorStack(final String errorStack) {
198+
this.errorStack = errorStack;
199+
}
200+
201+
public String getServerOutput() {
202+
return serverOutput;
203+
}
204+
205+
public void setServerOutput(final String serverOutput) {
206+
this.serverOutput = serverOutput;
207+
}
208+
209+
public LinkedHashMap<String, Test> getTests() {
210+
return tests;
211+
}
212+
213+
public void setTests(final LinkedHashMap<String, Test> tests) {
214+
this.tests = tests;
215+
}
216+
217+
public String getStatus() {
218+
return status;
219+
}
220+
221+
public void setStatus(final String status) {
222+
this.status = status;
223+
}
224+
225+
public Long getStart() {
226+
return start;
227+
}
228+
229+
public void setStart(final Long start) {
230+
this.start = start;
231+
}
79232
}

0 commit comments

Comments
 (0)