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");
13
13
* See the License for the specific language governing permissions and
14
14
* limitations under the License.
15
15
*/
16
- package org .utplsql .sqldev .test .dal
16
+ package org .utplsql .sqldev .test .dal ;
17
17
18
- import org .junit .AfterClass
19
- import org .junit .Assert
20
- import org .junit .BeforeClass
21
- import org .junit .Test
22
- import org .springframework .jdbc .BadSqlGrammarException
23
- import org .utplsql .sqldev .dal .UtplsqlDao
24
- import org .utplsql .sqldev .test .AbstractJdbcTest
18
+ import com .google .common .base .Objects ;
19
+ import java .sql .Connection ;
20
+ import java .util .List ;
21
+ import org .eclipse .xtend2 .lib .StringConcatenation ;
22
+ import org .eclipse .xtext .xbase .lib .Exceptions ;
23
+ import org .eclipse .xtext .xbase .lib .Functions .Function1 ;
24
+ import org .eclipse .xtext .xbase .lib .IterableExtensions ;
25
+ import org .junit .AfterClass ;
26
+ import org .junit .Assert ;
27
+ import org .junit .BeforeClass ;
28
+ import org .junit .Test ;
29
+ import org .oddgen .sqldev .generators .model .Node ;
30
+ import org .springframework .jdbc .BadSqlGrammarException ;
31
+ import org .utplsql .sqldev .dal .UtplsqlDao ;
32
+ import org .utplsql .sqldev .test .AbstractJdbcTest ;
25
33
26
- class DalBugFixTest extends AbstractJdbcTest {
27
-
28
- @ BeforeClass
29
- @ AfterClass
30
- def static void setupAndTeardown () {
31
- try {
32
- jdbcTemplate .execute ("DROP PACKAGE junit_utplsql_test_pkg" )
33
- } catch (BadSqlGrammarException e ) {
34
- // ignore
35
- }
36
- }
37
-
38
- @ Test
39
- // https://github.com/utPLSQL/utPLSQL-SQLDeveloper/issues/54
40
- def void issue54FolderIconForSuitesWithoutTests () {
41
- setupAndTeardown
42
- jdbcTemplate .execute ('''
43
- CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS
44
- -- %suite
45
-
46
- END junit_utplsql_test_pkg ;
47
- ''')
48
- val dao = new UtplsqlDao (dataSource .connection )
49
- val actualNodes = dao .runnables ()
50
- Assert .assertEquals (4 , actualNodes .size )
51
- val pkg = actualNodes .findFirst [it .id == "SCOTT:junit_utplsql_test_pkg" ]
52
- Assert .assertEquals ("FOLDER_ICON" , pkg .iconName )
53
- jdbcTemplate .execute ("DROP PACKAGE junit_utplsql_test_pkg" )
54
- }
55
-
56
- @ Test
57
- // https://github.com/utPLSQL/utPLSQL-SQLDeveloper/issues/54
58
- def void issue54PackageIconForSuitesWithTests () {
59
- setupAndTeardown
60
- jdbcTemplate .execute ('''
61
- CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS
62
- -- %suite
63
-
64
- -- %test
65
- PROCEDURE t1 ;
66
-
67
- END junit_utplsql_test_pkg ;
68
- ''')
69
- val dao = new UtplsqlDao (dataSource .connection )
70
- val actualNodes = dao .runnables ()
71
- Assert .assertEquals (6 , actualNodes .size )
72
- val pkg = actualNodes .findFirst [it .id == "SCOTT:junit_utplsql_test_pkg" ]
73
- Assert .assertEquals ("PACKAGE_ICON" , pkg .iconName )
74
- jdbcTemplate .execute ("DROP PACKAGE junit_utplsql_test_pkg" )
75
- }
76
-
77
- @ Test
78
- // https://github.com/utPLSQL/utPLSQL-SQLDeveloper/issues/55
79
- def void issue55SuiteWithoutTests () {
80
- setupAndTeardown
81
- jdbcTemplate .execute ('''
82
- CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS
83
- -- %suite
84
-
85
- END junit_utplsql_test_pkg ;
86
- ''')
87
- val dao = new UtplsqlDao (dataSource .connection )
88
- val actualNodes = dao .runnables ()
89
- Assert .assertEquals (4 , actualNodes .size )
90
- jdbcTemplate .execute ("DROP PACKAGE junit_utplsql_test_pkg" )
91
- }
92
-
93
- @ Test
94
- // https://github.com/utPLSQL/utPLSQL-SQLDeveloper/issues/56
95
- def void issue56SuiteWithoutTests () {
96
- jdbcTemplate .execute ('''
97
- CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS
98
- -- %suite
99
-
100
- END junit_utplsql_test_pkg ;
101
- ''')
102
- val dao = new UtplsqlDao (dataSource .connection )
103
- Assert .assertTrue (dao .containsUtplsqlTest ("scott" , "junit_utplsql_test_pkg" ))
104
- jdbcTemplate .execute ("DROP PACKAGE junit_utplsql_test_pkg" )
105
- }
106
-
107
- }
34
+ @ SuppressWarnings ("all" )
35
+ public class DalBugFixTest extends AbstractJdbcTest {
36
+ @ BeforeClass
37
+ @ AfterClass
38
+ public static void setupAndTeardown () {
39
+ try {
40
+ AbstractJdbcTest .jdbcTemplate .execute ("DROP PACKAGE junit_utplsql_test_pkg" );
41
+ } catch (final Throwable _t ) {
42
+ if (_t instanceof BadSqlGrammarException ) {
43
+ } else {
44
+ throw Exceptions .sneakyThrow (_t );
45
+ }
46
+ }
47
+ }
48
+
49
+ @ Test
50
+ public void issue54FolderIconForSuitesWithoutTests () {
51
+ try {
52
+ DalBugFixTest .setupAndTeardown ();
53
+ StringConcatenation _builder = new StringConcatenation ();
54
+ _builder .append ("CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS" );
55
+ _builder .newLine ();
56
+ _builder .append (" " );
57
+ _builder .append ("-- %suite" );
58
+ _builder .newLine ();
59
+ _builder .newLine ();
60
+ _builder .append ("END junit_utplsql_test_pkg;" );
61
+ _builder .newLine ();
62
+ AbstractJdbcTest .jdbcTemplate .execute (_builder .toString ());
63
+ Connection _connection = AbstractJdbcTest .dataSource .getConnection ();
64
+ final UtplsqlDao dao = new UtplsqlDao (_connection );
65
+ final List <Node > actualNodes = dao .runnables ();
66
+ Assert .assertEquals (4 , actualNodes .size ());
67
+ final Function1 <Node , Boolean > _function = (Node it ) -> {
68
+ String _id = it .getId ();
69
+ return Boolean .valueOf (Objects .equal (_id , "SCOTT:junit_utplsql_test_pkg" ));
70
+ };
71
+ final Node pkg = IterableExtensions .<Node >findFirst (actualNodes , _function );
72
+ Assert .assertEquals ("FOLDER_ICON" , pkg .getIconName ());
73
+ AbstractJdbcTest .jdbcTemplate .execute ("DROP PACKAGE junit_utplsql_test_pkg" );
74
+ } catch (Throwable _e ) {
75
+ throw Exceptions .sneakyThrow (_e );
76
+ }
77
+ }
78
+
79
+ @ Test
80
+ public void issue54PackageIconForSuitesWithTests () {
81
+ try {
82
+ DalBugFixTest .setupAndTeardown ();
83
+ StringConcatenation _builder = new StringConcatenation ();
84
+ _builder .append ("CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS" );
85
+ _builder .newLine ();
86
+ _builder .append (" " );
87
+ _builder .append ("-- %suite" );
88
+ _builder .newLine ();
89
+ _builder .newLine ();
90
+ _builder .append (" " );
91
+ _builder .append ("-- %test" );
92
+ _builder .newLine ();
93
+ _builder .append (" " );
94
+ _builder .append ("PROCEDURE t1;" );
95
+ _builder .newLine ();
96
+ _builder .newLine ();
97
+ _builder .append ("END junit_utplsql_test_pkg;" );
98
+ _builder .newLine ();
99
+ AbstractJdbcTest .jdbcTemplate .execute (_builder .toString ());
100
+ Connection _connection = AbstractJdbcTest .dataSource .getConnection ();
101
+ final UtplsqlDao dao = new UtplsqlDao (_connection );
102
+ final List <Node > actualNodes = dao .runnables ();
103
+ Assert .assertEquals (6 , actualNodes .size ());
104
+ final Function1 <Node , Boolean > _function = (Node it ) -> {
105
+ String _id = it .getId ();
106
+ return Boolean .valueOf (Objects .equal (_id , "SCOTT:junit_utplsql_test_pkg" ));
107
+ };
108
+ final Node pkg = IterableExtensions .<Node >findFirst (actualNodes , _function );
109
+ Assert .assertEquals ("PACKAGE_ICON" , pkg .getIconName ());
110
+ AbstractJdbcTest .jdbcTemplate .execute ("DROP PACKAGE junit_utplsql_test_pkg" );
111
+ } catch (Throwable _e ) {
112
+ throw Exceptions .sneakyThrow (_e );
113
+ }
114
+ }
115
+
116
+ @ Test
117
+ public void issue55SuiteWithoutTests () {
118
+ try {
119
+ DalBugFixTest .setupAndTeardown ();
120
+ StringConcatenation _builder = new StringConcatenation ();
121
+ _builder .append ("CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS" );
122
+ _builder .newLine ();
123
+ _builder .append (" " );
124
+ _builder .append ("-- %suite" );
125
+ _builder .newLine ();
126
+ _builder .newLine ();
127
+ _builder .append ("END junit_utplsql_test_pkg;" );
128
+ _builder .newLine ();
129
+ AbstractJdbcTest .jdbcTemplate .execute (_builder .toString ());
130
+ Connection _connection = AbstractJdbcTest .dataSource .getConnection ();
131
+ final UtplsqlDao dao = new UtplsqlDao (_connection );
132
+ final List <Node > actualNodes = dao .runnables ();
133
+ Assert .assertEquals (4 , actualNodes .size ());
134
+ AbstractJdbcTest .jdbcTemplate .execute ("DROP PACKAGE junit_utplsql_test_pkg" );
135
+ } catch (Throwable _e ) {
136
+ throw Exceptions .sneakyThrow (_e );
137
+ }
138
+ }
139
+
140
+ @ Test
141
+ public void issue56SuiteWithoutTests () {
142
+ try {
143
+ StringConcatenation _builder = new StringConcatenation ();
144
+ _builder .append ("CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS" );
145
+ _builder .newLine ();
146
+ _builder .append (" " );
147
+ _builder .append ("-- %suite" );
148
+ _builder .newLine ();
149
+ _builder .newLine ();
150
+ _builder .append ("END junit_utplsql_test_pkg;" );
151
+ _builder .newLine ();
152
+ AbstractJdbcTest .jdbcTemplate .execute (_builder .toString ());
153
+ Connection _connection = AbstractJdbcTest .dataSource .getConnection ();
154
+ final UtplsqlDao dao = new UtplsqlDao (_connection );
155
+ Assert .assertTrue (dao .containsUtplsqlTest ("scott" , "junit_utplsql_test_pkg" ));
156
+ AbstractJdbcTest .jdbcTemplate .execute ("DROP PACKAGE junit_utplsql_test_pkg" );
157
+ } catch (Throwable _e ) {
158
+ throw Exceptions .sneakyThrow (_e );
159
+ }
160
+ }
161
+ }
0 commit comments