|
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"); |
|
15 | 15 | */ |
16 | 16 | package org.utplsql.sqldev.test.dal; |
17 | 17 |
|
18 | | -import com.google.common.base.Objects; |
19 | | -import java.sql.Connection; |
20 | 18 | 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; |
| 19 | + |
| 20 | +import org.junit.After; |
26 | 21 | import org.junit.Assert; |
27 | | -import org.junit.BeforeClass; |
| 22 | +import org.junit.Before; |
28 | 23 | import org.junit.Test; |
29 | 24 | import org.oddgen.sqldev.generators.model.Node; |
30 | | -import org.springframework.jdbc.BadSqlGrammarException; |
31 | 25 | import org.utplsql.sqldev.dal.UtplsqlDao; |
| 26 | +import org.utplsql.sqldev.model.DatabaseTools; |
32 | 27 | import org.utplsql.sqldev.test.AbstractJdbcTest; |
33 | 28 |
|
34 | | -@SuppressWarnings("all") |
35 | 29 | 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 | | - } |
| 30 | + @Before |
| 31 | + @After |
| 32 | + public void setupAndTeardown() { |
| 33 | + executeAndIgnore(jdbcTemplate, "DROP PACKAGE junit_utplsql_test_pkg"); |
46 | 34 | } |
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); |
| 35 | + |
| 36 | + @Test |
| 37 | + // https://github.com/utPLSQL/utPLSQL-SQLDeveloper/issues/54 |
| 38 | + public void issue54FolderIconForSuitesWithoutTests() { |
| 39 | + StringBuilder sb = new StringBuilder(); |
| 40 | + sb.append("CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS\n"); |
| 41 | + sb.append(" -- %suite\n\n"); |
| 42 | + sb.append("END junit_utplsql_test_pkg;"); |
| 43 | + jdbcTemplate.execute(sb.toString()); |
| 44 | + final UtplsqlDao dao = new UtplsqlDao(DatabaseTools.getConnection(dataSource)); |
| 45 | + final List<Node> actualNodes = dao.runnables(); |
| 46 | + final Node pkg = actualNodes.stream().filter(it -> it.getId().equals("SCOTT:junit_utplsql_test_pkg")) |
| 47 | + .findFirst().get(); |
| 48 | + Assert.assertEquals("FOLDER_ICON", pkg.getIconName()); |
76 | 49 | } |
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); |
| 50 | + |
| 51 | + @Test |
| 52 | + // https://github.com/utPLSQL/utPLSQL-SQLDeveloper/issues/54 |
| 53 | + public void issue54PackageIconForSuitesWithTests() { |
| 54 | + StringBuilder sb = new StringBuilder(); |
| 55 | + sb.append("CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS\n"); |
| 56 | + sb.append(" -- %suite\n\n"); |
| 57 | + sb.append(" -- %test\n"); |
| 58 | + sb.append(" PROCEDURE t1;\n\n"); |
| 59 | + sb.append("END junit_utplsql_test_pkg;"); |
| 60 | + jdbcTemplate.execute(sb.toString()); |
| 61 | + final UtplsqlDao dao = new UtplsqlDao(DatabaseTools.getConnection(dataSource)); |
| 62 | + final List<Node> actualNodes = dao.runnables(); |
| 63 | + final Node pkg = actualNodes.stream().filter(it -> it.getId().equals("SCOTT:junit_utplsql_test_pkg")) |
| 64 | + .findFirst().get(); |
| 65 | + Assert.assertEquals("PACKAGE_ICON", pkg.getIconName()); |
113 | 66 | } |
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); |
| 67 | + |
| 68 | + @Test |
| 69 | + // https://github.com/utPLSQL/utPLSQL-SQLDeveloper/issues/55 |
| 70 | + public void issue55SuiteWithoutTests() { |
| 71 | + StringBuilder sb = new StringBuilder(); |
| 72 | + sb.append("CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS\n"); |
| 73 | + sb.append(" -- %suite\n\n"); |
| 74 | + sb.append("END junit_utplsql_test_pkg;"); |
| 75 | + jdbcTemplate.execute(sb.toString()); |
| 76 | + final UtplsqlDao dao = new UtplsqlDao(DatabaseTools.getConnection(dataSource)); |
| 77 | + final List<Node> actualNodes = dao.runnables(); |
| 78 | + Assert.assertEquals(4, actualNodes.size()); |
137 | 79 | } |
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); |
| 80 | + |
| 81 | + @Test |
| 82 | + public void issue56SuiteWithoutTests() { |
| 83 | + // https://github.com/utPLSQL/utPLSQL-SQLDeveloper/issues/56 |
| 84 | + StringBuilder sb = new StringBuilder(); |
| 85 | + sb.append("CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS\n"); |
| 86 | + sb.append(" -- %suite\n\n"); |
| 87 | + sb.append("END junit_utplsql_test_pkg;"); |
| 88 | + jdbcTemplate.execute(sb.toString()); |
| 89 | + final UtplsqlDao dao = new UtplsqlDao(DatabaseTools.getConnection(dataSource)); |
| 90 | + Assert.assertTrue(dao.containsUtplsqlTest("scott", "junit_utplsql_test_pkg")); |
159 | 91 | } |
160 | | - } |
161 | 92 | } |
0 commit comments