1
1
package com .bobocode ;
2
2
3
3
import com .bobocode .util .JdbcUtil ;
4
- import org .junit .BeforeClass ;
5
- import org .junit .Test ;
6
- import org .junit .runner .RunWith ;
7
- import org .junit .runners .JUnit4 ;
4
+ import org .junit .jupiter .api .BeforeAll ;
5
+ import org .junit .jupiter .api .Test ;
8
6
9
7
import javax .sql .DataSource ;
10
8
import java .sql .Connection ;
14
12
import java .util .ArrayList ;
15
13
import java .util .List ;
16
14
17
- import static org .junit .Assert .assertEquals ;
18
- import static org .junit .Assert .assertTrue ;
15
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
16
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
17
+
19
18
20
- @ RunWith (JUnit4 .class )
21
19
public class AccountDbInitializerTest {
22
20
private static DataSource dataSource ;
23
21
24
- @ BeforeClass
25
- public static void init () throws SQLException {
22
+ @ BeforeAll
23
+ static void init () throws SQLException {
26
24
dataSource = JdbcUtil .createDefaultInMemoryH2DataSource ();
27
25
AccountDbInitializer dbInitializer = new AccountDbInitializer (dataSource );
28
26
dbInitializer .init ();
29
27
}
30
28
31
29
@ Test
32
- public void testTableHasCorrectName () throws SQLException {
30
+ void testTableHasCorrectName () throws SQLException {
33
31
try (Connection connection = dataSource .getConnection ()) {
34
32
Statement statement = connection .createStatement ();
35
33
@@ -42,7 +40,7 @@ public void testTableHasCorrectName() throws SQLException {
42
40
}
43
41
44
42
@ Test
45
- public void testTableHasPrimaryKey () throws SQLException {
43
+ void testTableHasPrimaryKey () throws SQLException {
46
44
try (Connection connection = dataSource .getConnection ()) {
47
45
Statement statement = connection .createStatement ();
48
46
ResultSet resultSet = statement .executeQuery ("SELECT * FROM INFORMATION_SCHEMA.CONSTRAINTS" +
@@ -55,7 +53,7 @@ public void testTableHasPrimaryKey() throws SQLException {
55
53
}
56
54
57
55
@ Test
58
- public void testPrimaryKeyHasCorrectName () throws SQLException {
56
+ void testPrimaryKeyHasCorrectName () throws SQLException {
59
57
try (Connection connection = dataSource .getConnection ()) {
60
58
Statement statement = connection .createStatement ();
61
59
ResultSet resultSet = statement .executeQuery ("SELECT * FROM INFORMATION_SCHEMA.CONSTRAINTS" +
@@ -69,7 +67,7 @@ public void testPrimaryKeyHasCorrectName() throws SQLException {
69
67
}
70
68
71
69
@ Test
72
- public void testPrimaryKeyBasedOnIdField () throws SQLException {
70
+ void testPrimaryKeyBasedOnIdField () throws SQLException {
73
71
try (Connection connection = dataSource .getConnection ()) {
74
72
Statement statement = connection .createStatement ();
75
73
ResultSet resultSet = statement .executeQuery ("SELECT * FROM INFORMATION_SCHEMA.CONSTRAINTS" +
@@ -83,7 +81,7 @@ public void testPrimaryKeyBasedOnIdField() throws SQLException {
83
81
}
84
82
85
83
@ Test
86
- public void testTableHasCorrectAlternativeKey () throws SQLException {
84
+ void testTableHasCorrectAlternativeKey () throws SQLException {
87
85
try (Connection connection = dataSource .getConnection ()) {
88
86
Statement statement = connection .createStatement ();
89
87
ResultSet resultSet = statement .executeQuery ("SELECT * FROM INFORMATION_SCHEMA.CONSTRAINTS" +
@@ -99,7 +97,7 @@ public void testTableHasCorrectAlternativeKey() throws SQLException {
99
97
}
100
98
101
99
@ Test
102
- public void testTableHasAllRequiredColumns () throws SQLException {
100
+ void testTableHasAllRequiredColumns () throws SQLException {
103
101
try (Connection connection = dataSource .getConnection ()) {
104
102
Statement statement = connection .createStatement ();
105
103
ResultSet resultSet = statement .executeQuery ("SELECT * FROM INFORMATION_SCHEMA.COLUMNS" +
@@ -123,7 +121,7 @@ private List<String> fetchColumnsNames(ResultSet resultSet) throws SQLException
123
121
124
122
125
123
@ Test
126
- public void testRequiredColumnsHaveHaveNotNullConstraint () throws SQLException {
124
+ void testRequiredColumnsHaveHaveNotNullConstraint () throws SQLException {
127
125
try (Connection connection = dataSource .getConnection ()) {
128
126
Statement statement = connection .createStatement ();
129
127
ResultSet resultSet = statement .executeQuery ("SELECT * FROM INFORMATION_SCHEMA.COLUMNS" +
@@ -137,7 +135,7 @@ public void testRequiredColumnsHaveHaveNotNullConstraint() throws SQLException {
137
135
}
138
136
139
137
@ Test
140
- public void testIdHasTypeBiInteger () throws SQLException {
138
+ void testIdHasTypeBiInteger () throws SQLException {
141
139
try (Connection connection = dataSource .getConnection ()) {
142
140
Statement statement = connection .createStatement ();
143
141
ResultSet resultSet = statement .executeQuery ("SELECT * FROM INFORMATION_SCHEMA.COLUMNS" +
@@ -151,7 +149,7 @@ public void testIdHasTypeBiInteger() throws SQLException {
151
149
}
152
150
153
151
@ Test
154
- public void testCreationTimeHasTypeTimestamp () throws SQLException {
152
+ void testCreationTimeHasTypeTimestamp () throws SQLException {
155
153
try (Connection connection = dataSource .getConnection ()) {
156
154
Statement statement = connection .createStatement ();
157
155
ResultSet resultSet = statement .executeQuery ("SELECT * FROM INFORMATION_SCHEMA.COLUMNS" +
@@ -165,7 +163,7 @@ public void testCreationTimeHasTypeTimestamp() throws SQLException {
165
163
}
166
164
167
165
@ Test
168
- public void testCreationTimeHasDefaultValue () throws SQLException {
166
+ void testCreationTimeHasDefaultValue () throws SQLException {
169
167
try (Connection connection = dataSource .getConnection ()) {
170
168
Statement statement = connection .createStatement ();
171
169
ResultSet resultSet = statement .executeQuery ("SELECT * FROM INFORMATION_SCHEMA.COLUMNS" +
@@ -179,7 +177,7 @@ public void testCreationTimeHasDefaultValue() throws SQLException {
179
177
}
180
178
181
179
@ Test
182
- public void testEmailColumnHasCorrectSize () throws SQLException {
180
+ void testEmailColumnHasCorrectSize () throws SQLException {
183
181
try (Connection connection = dataSource .getConnection ()) {
184
182
Statement statement = connection .createStatement ();
185
183
ResultSet resultSet = statement .executeQuery ("SELECT * FROM INFORMATION_SCHEMA.COLUMNS" +
@@ -195,7 +193,7 @@ public void testEmailColumnHasCorrectSize() throws SQLException {
195
193
}
196
194
197
195
@ Test
198
- public void testBirthdayColumnHasCorrectType () throws SQLException {
196
+ void testBirthdayColumnHasCorrectType () throws SQLException {
199
197
try (Connection connection = dataSource .getConnection ()) {
200
198
Statement statement = connection .createStatement ();
201
199
ResultSet resultSet = statement .executeQuery ("SELECT * FROM INFORMATION_SCHEMA.COLUMNS" +
@@ -209,7 +207,7 @@ public void testBirthdayColumnHasCorrectType() throws SQLException {
209
207
}
210
208
211
209
@ Test
212
- public void testBalanceColumnHasCorrectType () throws SQLException {
210
+ void testBalanceColumnHasCorrectType () throws SQLException {
213
211
try (Connection connection = dataSource .getConnection ()) {
214
212
Statement statement = connection .createStatement ();
215
213
ResultSet resultSet = statement .executeQuery ("SELECT * FROM INFORMATION_SCHEMA.COLUMNS" +
@@ -227,7 +225,7 @@ public void testBalanceColumnHasCorrectType() throws SQLException {
227
225
}
228
226
229
227
@ Test
230
- public void testBalanceIsNotMandatory () throws SQLException {
228
+ void testBalanceIsNotMandatory () throws SQLException {
231
229
try (Connection connection = dataSource .getConnection ()) {
232
230
Statement statement = connection .createStatement ();
233
231
ResultSet resultSet = statement .executeQuery ("SELECT * FROM INFORMATION_SCHEMA.COLUMNS" +
@@ -241,7 +239,7 @@ public void testBalanceIsNotMandatory() throws SQLException {
241
239
}
242
240
243
241
@ Test
244
- public void testStringColumnsHaveCorrectTypeAndLength () throws SQLException {
242
+ void testStringColumnsHaveCorrectTypeAndLength () throws SQLException {
245
243
try (Connection connection = dataSource .getConnection ()) {
246
244
Statement statement = connection .createStatement ();
247
245
ResultSet resultSet = statement .executeQuery ("SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS" +
0 commit comments