|
15 | 15 | */ |
16 | 16 | package org.utplsql.sqldev.test.runner; |
17 | 17 |
|
18 | | -import org.eclipse.xtend2.lib.StringConcatenation; |
19 | 18 | import org.junit.Assert; |
20 | | -import org.junit.Before; |
21 | 19 | import org.junit.Test; |
22 | 20 | import org.utplsql.sqldev.model.runner.Expectation; |
23 | 21 |
|
24 | | -@SuppressWarnings("all") |
25 | 22 | public class ExpectationTest { |
26 | | - private Expectation exceptionWithDescription; |
27 | | - |
28 | | - private Expectation exceptionWithoutDescription; |
29 | | - |
30 | | - @Before |
31 | | - public void setup() { |
32 | | - Expectation _expectation = new Expectation(); |
33 | | - this.exceptionWithDescription = _expectation; |
34 | | - StringConcatenation _builder = new StringConcatenation(); |
35 | | - _builder.append("This assert must fail"); |
36 | | - this.exceptionWithDescription.setDescription(_builder.toString()); |
37 | | - StringConcatenation _builder_1 = new StringConcatenation(); |
38 | | - _builder_1.append("at: 1 (number) was expected to equal: 2 (number)"); |
39 | | - this.exceptionWithDescription.setMessage(_builder_1.toString()); |
40 | | - StringConcatenation _builder_2 = new StringConcatenation(); |
41 | | - _builder_2.append("\"SCOTT.JUNIT_UTPLSQL_TEST1_PKG.TEST_2_NOK\", line 14 ut.expect(1, \'This assert must fail\').to_equal(2);"); |
42 | | - this.exceptionWithDescription.setCaller(_builder_2.toString()); |
43 | | - Expectation _expectation_1 = new Expectation(); |
44 | | - this.exceptionWithoutDescription = _expectation_1; |
45 | | - this.exceptionWithoutDescription.setMessage(this.exceptionWithDescription.getMessage()); |
46 | | - this.exceptionWithoutDescription.setCaller(this.exceptionWithDescription.getCaller()); |
47 | | - StringConcatenation _builder_3 = new StringConcatenation(); |
48 | | - _builder_3.append("at: 1 (number) was expected to equal: 2 (number)"); |
49 | | - this.exceptionWithoutDescription.setMessage(_builder_3.toString()); |
50 | | - StringConcatenation _builder_4 = new StringConcatenation(); |
51 | | - _builder_4.append("\"SCOTT.JUNIT_UTPLSQL_TEST1_PKG.TEST_3_NOK\", line 42 ut.expect(1).to_equal(2);"); |
52 | | - this.exceptionWithoutDescription.setCaller(_builder_4.toString()); |
53 | | - } |
54 | | - |
55 | | - @Test |
56 | | - public void failedExpectationCallerLine() { |
57 | | - final Integer actual = this.exceptionWithDescription.getCallerLine(); |
58 | | - final Integer expected = new Integer(14); |
59 | | - Assert.assertEquals(expected, actual); |
60 | | - } |
61 | | - |
62 | | - @Test |
63 | | - public void shortFailureTextWithDescription() { |
64 | | - final String actual = this.exceptionWithDescription.getShortFailureText(); |
65 | | - final String expected = "This assert must fail (line 14)"; |
66 | | - Assert.assertEquals(expected, actual); |
67 | | - } |
| 23 | + |
| 24 | + private Expectation getExpectationWithDescription() { |
| 25 | + Expectation ex = new Expectation(); |
| 26 | + ex.setDescription("This assert must fail"); |
| 27 | + ex.setMessage("at: 1 (number) was expected to equal: 2 (number)"); |
| 28 | + ex.setCaller("\"SCOTT.JUNIT_UTPLSQL_TEST1_PKG.TEST_2_NOK\", line 14 ut.expect(1, 'This assert must fail').to_equal(2);"); |
| 29 | + return ex; |
| 30 | + } |
| 31 | + |
| 32 | + private Expectation getExpectationWithoutDescription() { |
| 33 | + Expectation ex = new Expectation(); |
| 34 | + ex.setMessage("at: 1 (number) was expected to equal: 2 (number)"); |
| 35 | + ex.setCaller("\"SCOTT.JUNIT_UTPLSQL_TEST1_PKG.TEST_3_NOK\", line 42 ut.expect(1).to_equal(2);"); |
| 36 | + return ex; |
| 37 | + } |
68 | 38 |
|
69 | | - @Test |
70 | | - public void shortFailureTextWithoutDescription() { |
71 | | - final String actual = this.exceptionWithoutDescription.getShortFailureText(); |
72 | | - final String expected = "Line 42"; |
73 | | - Assert.assertEquals(expected, actual); |
74 | | - } |
| 39 | + @Test |
| 40 | + public void failedExpectationCallerLine() { |
| 41 | + final Integer actual = getExpectationWithDescription().getCallerLine(); |
| 42 | + final Integer expected = Integer.valueOf(14); |
| 43 | + Assert.assertEquals(expected, actual); |
| 44 | + } |
| 45 | + |
| 46 | + @Test |
| 47 | + public void shortFailureTextWithDescription() { |
| 48 | + final String actual = getExpectationWithDescription().getShortFailureText(); |
| 49 | + final String expected = "This assert must fail (line 14)"; |
| 50 | + Assert.assertEquals(expected, actual); |
| 51 | + } |
| 52 | + |
| 53 | + @Test |
| 54 | + public void shortFailureTextWithoutDescription() { |
| 55 | + final String actual = getExpectationWithoutDescription().getShortFailureText(); |
| 56 | + final String expected = "Line 42"; |
| 57 | + Assert.assertEquals(expected, actual); |
| 58 | + } |
75 | 59 | } |
0 commit comments