1- /*
1+ /**
22 * Copyright 2019 Philipp Salvisberg <philipp.salvisberg@trivadis.com>
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
16- package org .utplsql .sqldev .test .runner
16+ package org .utplsql .sqldev .test .runner ;
1717
18- import org .junit .Assert
19- import org .junit .Before
20- import org .junit .Test
21- import org .utplsql .sqldev .model .runner .Expectation
18+ import org .eclipse .xtend2 .lib .StringConcatenation ;
19+ import org .junit .Assert ;
20+ import org .junit .Before ;
21+ import org .junit .Test ;
22+ import org .utplsql .sqldev .model .runner .Expectation ;
2223
23- class ExpectationTest {
24- var Expectation exceptionWithDescription
25- var Expectation exceptionWithoutDescription
26-
27- @ Before
28- def void setup () {
29- exceptionWithDescription = new Expectation
30- exceptionWithDescription .description = '''This assert must fail' ''
31- exceptionWithDescription .message = '''at: 1 (number) was expected to equal: 2 (number)' ''
32- exceptionWithDescription .caller = '''"SCOTT.JUNIT_UTPLSQL_TEST1_PKG.TEST_2_NOK", line 14 ut.expect(1, ' This assert must fail ').to_equal(2);' ''
33- exceptionWithoutDescription = new Expectation
34- exceptionWithoutDescription .message = exceptionWithDescription .message
35- exceptionWithoutDescription .caller = exceptionWithDescription .caller
36- exceptionWithoutDescription .message = '''at: 1 (number) was expected to equal: 2 (number)' ''
37- exceptionWithoutDescription .caller = '''"SCOTT.JUNIT_UTPLSQL_TEST1_PKG.TEST_3_NOK", line 42 ut.expect(1).to_equal(2);' ''
38- }
39-
40- @ Test
41- def void failedExpectationCallerLine () {
42- val actual = exceptionWithDescription .callerLine
43- val expected = new Integer (14 )
44- Assert .assertEquals (expected , actual )
45- }
46-
47- @ Test
48- def void shortFailureTextWithDescription () {
49- val actual = exceptionWithDescription .shortFailureText
50- val expected = 'This assert must fail (line 14)'
51- Assert .assertEquals (expected , actual )
52- }
53-
54- @ Test
55- def void shortFailureTextWithoutDescription () {
56- val actual = exceptionWithoutDescription .shortFailureText
57- val expected = 'Line 42'
58- Assert .assertEquals (expected , actual )
59- }
60-
61- }
24+ @ SuppressWarnings ("all" )
25+ 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+ }
68+
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+ }
75+ }
0 commit comments