|
1 | | -/** |
| 1 | +/* |
2 | 2 | * Copyright 2018 Philipp Salvisberg <philipp.salvisberg@trivadis.com> |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
18 | 18 | import java.awt.Component; |
19 | 19 | import java.awt.Dimension; |
20 | 20 | import java.awt.Toolkit; |
21 | | -import java.util.Collections; |
| 21 | +import java.util.Arrays; |
22 | 22 | import java.util.UUID; |
| 23 | + |
23 | 24 | import javax.swing.JFrame; |
24 | 25 | import javax.swing.SwingUtilities; |
25 | | -import org.eclipse.xtext.xbase.lib.CollectionLiterals; |
26 | | -import org.eclipse.xtext.xbase.lib.Exceptions; |
| 26 | + |
| 27 | +import org.junit.Assert; |
27 | 28 | import org.junit.Before; |
28 | 29 | import org.junit.Test; |
29 | | -import org.utplsql.sqldev.model.runner.Counter; |
| 30 | +import org.utplsql.sqldev.model.SystemTools; |
30 | 31 | import org.utplsql.sqldev.model.runner.Run; |
31 | 32 | import org.utplsql.sqldev.resources.UtplsqlResources; |
32 | 33 | import org.utplsql.sqldev.ui.runner.RunnerPanel; |
33 | 34 |
|
34 | | -@SuppressWarnings("all") |
35 | 35 | public class UtplsqlRunnerPanelTest { |
36 | | - private Run run; |
37 | | - |
38 | | - @Before |
39 | | - public void setup() { |
40 | | - final String reporterId = UUID.randomUUID().toString().replace("-", ""); |
41 | | - Run _run = new Run(null, reporterId, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList())); |
42 | | - this.run = _run; |
43 | | - this.run.setStartTime("2019-06-09T13:42:42.123456"); |
44 | | - Counter _counter = this.run.getCounter(); |
45 | | - _counter.setDisabled(Integer.valueOf(0)); |
46 | | - Counter _counter_1 = this.run.getCounter(); |
47 | | - _counter_1.setSuccess(Integer.valueOf(0)); |
48 | | - Counter _counter_2 = this.run.getCounter(); |
49 | | - _counter_2.setFailure(Integer.valueOf(0)); |
50 | | - Counter _counter_3 = this.run.getCounter(); |
51 | | - _counter_3.setError(Integer.valueOf(0)); |
52 | | - Counter _counter_4 = this.run.getCounter(); |
53 | | - _counter_4.setWarning(Integer.valueOf(0)); |
54 | | - this.run.setTotalNumberOfTests(Integer.valueOf(5)); |
55 | | - this.run.setCurrentTestNumber(Integer.valueOf(0)); |
56 | | - } |
57 | | - |
58 | | - @Test |
59 | | - public void showGUI() { |
60 | | - try { |
61 | | - final long start = System.currentTimeMillis(); |
62 | | - final JFrame frame = new JFrame("utPLSQL Runner Panel"); |
63 | | - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
64 | | - final RunnerPanel panel = new RunnerPanel(); |
65 | | - final Component gui = panel.getGUI(); |
66 | | - panel.setModel(this.run); |
67 | | - SwingUtilities.invokeLater(new Runnable() { |
68 | | - @Override |
69 | | - public void run() { |
70 | | - frame.add(gui); |
71 | | - frame.pack(); |
72 | | - final Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); |
73 | | - frame.setLocation(((dim.width / 2) - (frame.getSize().width / 2)), ((dim.height / 2) - (frame.getSize().height / 2))); |
74 | | - frame.setVisible(true); |
75 | | - } |
76 | | - }); |
77 | | - this.run.setStatus("starting"); |
78 | | - panel.update(this.run.getReporterId()); |
79 | | - Thread.sleep(3000); |
80 | | - Counter _counter = this.run.getCounter(); |
81 | | - Integer _success = this.run.getCounter().getSuccess(); |
82 | | - int _plus = ((_success).intValue() + 1); |
83 | | - _counter.setSuccess(Integer.valueOf(_plus)); |
84 | | - this.run.setStatus("utplsql.test.a"); |
85 | | - panel.update(this.run.getReporterId()); |
86 | | - Thread.sleep(500); |
87 | | - Counter _counter_1 = this.run.getCounter(); |
88 | | - Integer _success_1 = this.run.getCounter().getSuccess(); |
89 | | - int _plus_1 = ((_success_1).intValue() + 1); |
90 | | - _counter_1.setSuccess(Integer.valueOf(_plus_1)); |
91 | | - this.run.setStatus("utplsql.test.b"); |
92 | | - panel.update(this.run.getReporterId()); |
93 | | - Thread.sleep(500); |
94 | | - Counter _counter_2 = this.run.getCounter(); |
95 | | - Integer _success_2 = this.run.getCounter().getSuccess(); |
96 | | - int _plus_2 = ((_success_2).intValue() + 1); |
97 | | - _counter_2.setSuccess(Integer.valueOf(_plus_2)); |
98 | | - this.run.setStatus("utplsql.test.c"); |
99 | | - panel.update(this.run.getReporterId()); |
100 | | - Thread.sleep(500); |
101 | | - Counter _counter_3 = this.run.getCounter(); |
102 | | - Integer _failure = this.run.getCounter().getFailure(); |
103 | | - int _plus_3 = ((_failure).intValue() + 1); |
104 | | - _counter_3.setFailure(Integer.valueOf(_plus_3)); |
105 | | - this.run.setStatus("utplsql.test.d"); |
106 | | - panel.update(this.run.getReporterId()); |
107 | | - Thread.sleep(500); |
108 | | - Counter _counter_4 = this.run.getCounter(); |
109 | | - Integer _success_3 = this.run.getCounter().getSuccess(); |
110 | | - int _plus_4 = ((_success_3).intValue() + 1); |
111 | | - _counter_4.setSuccess(Integer.valueOf(_plus_4)); |
112 | | - this.run.setStatus("utplsql.test.e"); |
113 | | - final long end = System.currentTimeMillis(); |
114 | | - Double _double = new Double((end - start)); |
115 | | - double _divide = ((_double).doubleValue() / 1000); |
116 | | - this.run.setExecutionTime(Double.valueOf(_divide)); |
117 | | - this.run.setStatus(UtplsqlResources.getString("RUNNER_FINNISHED_TEXT")); |
118 | | - panel.update(this.run.getReporterId()); |
119 | | - Thread.sleep(2000); |
120 | | - frame.dispose(); |
121 | | - } catch (Throwable _e) { |
122 | | - throw Exceptions.sneakyThrow(_e); |
| 36 | + private Run run; |
| 37 | + |
| 38 | + @Before |
| 39 | + public void setup() { |
| 40 | + final String reporterId = UUID.randomUUID().toString().replace("-", ""); |
| 41 | + run = new Run(null, reporterId, Arrays.asList()); |
| 42 | + run.setStartTime("2019-06-09T13:42:42.123456"); |
| 43 | + run.getCounter().setDisabled(0); |
| 44 | + run.getCounter().setSuccess(0); |
| 45 | + run.getCounter().setFailure(0); |
| 46 | + run.getCounter().setError(0); |
| 47 | + run.getCounter().setWarning(0); |
| 48 | + run.setTotalNumberOfTests(5); |
| 49 | + run.setCurrentTestNumber(0); |
| 50 | + } |
| 51 | + |
| 52 | + @Test |
| 53 | + public void showGUI() { |
| 54 | + final long start = System.currentTimeMillis(); |
| 55 | + final JFrame frame = new JFrame("utPLSQL Runner Panel"); |
| 56 | + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
| 57 | + final RunnerPanel panel = new RunnerPanel(); |
| 58 | + final Component gui = panel.getGUI(); |
| 59 | + panel.setModel(run); |
| 60 | + |
| 61 | + SwingUtilities.invokeLater(() -> { |
| 62 | + frame.add(gui); |
| 63 | + frame.pack(); |
| 64 | + final Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); |
| 65 | + frame.setSize(600, 600); |
| 66 | + frame.setLocation(dim.width / 2 - frame.getSize().width / 2, dim.height / 2 - frame.getSize().height / 2); |
| 67 | + frame.setVisible(true); |
| 68 | + }); |
| 69 | + |
| 70 | + run.setStatus("starting"); |
| 71 | + panel.update(run.getReporterId()); |
| 72 | + SystemTools.sleep(3000); |
| 73 | + |
| 74 | + run.getCounter().setSuccess(run.getCounter().getSuccess() + 1); |
| 75 | + run.setStatus("utplsql.test.a"); |
| 76 | + panel.update(run.getReporterId()); |
| 77 | + SystemTools.sleep(500); |
| 78 | + |
| 79 | + run.getCounter().setSuccess(run.getCounter().getSuccess() + 1); |
| 80 | + run.setStatus("utplsql.test.b"); |
| 81 | + panel.update(run.getReporterId()); |
| 82 | + SystemTools.sleep(500); |
| 83 | + |
| 84 | + run.getCounter().setSuccess(run.getCounter().getSuccess() + 1); |
| 85 | + run.setStatus("utplsql.test.c"); |
| 86 | + panel.update(run.getReporterId()); |
| 87 | + SystemTools.sleep(500); |
| 88 | + |
| 89 | + run.getCounter().setFailure(run.getCounter().getFailure() + 1); |
| 90 | + run.setStatus("utplsql.test.d"); |
| 91 | + panel.update(run.getReporterId()); |
| 92 | + SystemTools.sleep(500); |
| 93 | + |
| 94 | + run.getCounter().setSuccess(run.getCounter().getSuccess() + 1); |
| 95 | + run.setStatus("utplsql.test.e"); |
| 96 | + final long end = System.currentTimeMillis(); |
| 97 | + run.setExecutionTime(Double.valueOf(end - start) / 1000); |
| 98 | + run.setStatus(UtplsqlResources.getString("RUNNER_FINNISHED_TEXT")); |
| 99 | + panel.update(run.getReporterId()); |
| 100 | + SystemTools.sleep(2000); |
| 101 | + Assert.assertNotNull(frame); |
| 102 | + frame.dispose(); |
123 | 103 | } |
124 | | - } |
125 | 104 | } |
0 commit comments