1
1
package io .dinject .controller ;
2
2
3
- import org .junit .Test ;
3
+ import org .junit .jupiter . api . Test ;
4
4
5
5
import java .time .Instant ;
6
6
import java .time .LocalDate ;
10
10
import java .util .UUID ;
11
11
12
12
import static org .assertj .core .api .AssertionsForInterfaceTypes .assertThat ;
13
- import static org .junit .Assert .assertEquals ;
13
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
14
+ import static org .junit .jupiter .api .Assertions .assertThrows ;
14
15
15
16
public class PathTypeConversionTest {
16
17
17
- @ Test ( expected = RequiredArgumentException . class )
18
+ @ Test
18
19
public void checkNull_when_null () {
19
- PathTypeConversion .checkNull (null , "id" );
20
+ assertThrows ( RequiredArgumentException . class , () -> PathTypeConversion .checkNull (null , "id" ) );
20
21
}
21
22
22
23
@ Test
@@ -29,64 +30,64 @@ public void asInt() {
29
30
assertEquals (42 , PathTypeConversion .asInt ("42" ));
30
31
}
31
32
32
- @ Test ( expected = InvalidPathArgumentException . class )
33
+ @ Test
33
34
public void asInt_when_null () {
34
- PathTypeConversion .asInt (null );
35
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asInt (null ) );
35
36
}
36
37
37
- @ Test ( expected = InvalidPathArgumentException . class )
38
+ @ Test
38
39
public void asInt_when_invalid () {
39
- PathTypeConversion .asInt ("junk" );
40
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asInt ("junk" ) );
40
41
}
41
42
42
43
@ Test
43
44
public void asLong () {
44
45
assertEquals (42L , PathTypeConversion .asInt ("42" ));
45
46
}
46
47
47
- @ Test ( expected = InvalidPathArgumentException . class )
48
+ @ Test
48
49
public void asLong_when_invalid () {
49
- PathTypeConversion .asLong ("junk" );
50
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asLong ("junk" ) );
50
51
}
51
52
52
- @ Test ( expected = InvalidPathArgumentException . class )
53
+ @ Test
53
54
public void asLong_when_null () {
54
- PathTypeConversion .asLong (null );
55
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asLong (null ) );
55
56
}
56
57
57
58
@ Test
58
59
public void asDouble () {
59
60
assertThat (PathTypeConversion .asDouble ("42" )).isEqualTo (42d );
60
61
}
61
62
62
- @ Test ( expected = InvalidPathArgumentException . class )
63
+ @ Test
63
64
public void asDouble_when_invalid () {
64
- PathTypeConversion .asDouble ("jukn" );
65
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asDouble ("jukn" ) );
65
66
}
66
67
67
- @ Test ( expected = InvalidPathArgumentException . class )
68
+ @ Test
68
69
public void asDouble_when_null () {
69
- PathTypeConversion .asDouble (null );
70
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asDouble (null ) );
70
71
}
71
72
72
73
@ Test
73
74
public void asFloat () {
74
75
assertThat (PathTypeConversion .asFloat ("42" )).isEqualTo (42f );
75
76
}
76
77
77
- @ Test ( expected = InvalidPathArgumentException . class )
78
+ @ Test
78
79
public void asFloat_when_null () {
79
- PathTypeConversion .asFloat (null );
80
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asFloat (null ) );
80
81
}
81
82
82
- @ Test ( expected = InvalidPathArgumentException . class )
83
+ @ Test
83
84
public void asFloat_when_invalid () {
84
- PathTypeConversion .asFloat ("junk" );
85
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asFloat ("junk" ) );
85
86
}
86
87
87
- @ Test ( expected = InvalidPathArgumentException . class )
88
+ @ Test
88
89
public void asBool_when_null () {
89
- PathTypeConversion .asBool (null );
90
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asBool (null ) );
90
91
}
91
92
92
93
@ Test
@@ -103,74 +104,74 @@ public void asBigDecimal() {
103
104
assertThat (PathTypeConversion .asBigDecimal ("42.3" )).isEqualByComparingTo ("42.3" );
104
105
}
105
106
106
- @ Test ( expected = InvalidPathArgumentException . class )
107
+ @ Test
107
108
public void asBigDecimal_when_null () {
108
- PathTypeConversion .asBigDecimal (null );
109
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asBigDecimal (null ) );
109
110
}
110
111
111
- @ Test ( expected = InvalidPathArgumentException . class )
112
+ @ Test
112
113
public void asBigDecimal_when_invalid () {
113
- PathTypeConversion .asBigDecimal ("junk" );
114
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asBigDecimal ("junk" ) );
114
115
}
115
116
116
117
@ Test
117
118
public void asLocalDate () {
118
119
assertThat (PathTypeConversion .asLocalDate ("2018-06-03" )).isEqualTo (LocalDate .of (2018 , 6 , 3 ));
119
120
}
120
121
121
- @ Test ( expected = InvalidPathArgumentException . class )
122
+ @ Test
122
123
public void asLocalDate_when_null () {
123
- PathTypeConversion .asLocalDate (null );
124
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asLocalDate (null ) );
124
125
}
125
126
126
- @ Test ( expected = InvalidPathArgumentException . class )
127
+ @ Test
127
128
public void asLocalDate_when_invalid () {
128
- PathTypeConversion .asLocalDate ("junk" );
129
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asLocalDate ("junk" ) );
129
130
}
130
131
131
- @ Test ( expected = InvalidPathArgumentException . class )
132
+ @ Test
132
133
public void asLocalTime_when_invalid () {
133
- PathTypeConversion .asLocalTime ("junk" );
134
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asLocalTime ("junk" ) );
134
135
}
135
136
136
- @ Test ( expected = InvalidPathArgumentException . class )
137
+ @ Test
137
138
public void asLocalTime_when_null () {
138
- PathTypeConversion .asLocalTime (null );
139
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asLocalTime (null ) );
139
140
}
140
141
141
142
@ Test
142
143
public void asLocalTime () {
143
144
assertThat (PathTypeConversion .asLocalTime ("23:34:09" )).isEqualTo (LocalTime .of (23 , 34 , 9 ));
144
145
}
145
146
146
- @ Test ( expected = InvalidPathArgumentException . class )
147
+ @ Test
147
148
public void asInstant_when_null () {
148
- PathTypeConversion .asInstant (null );
149
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asInstant (null ) );
149
150
}
150
151
151
- @ Test ( expected = InvalidPathArgumentException . class )
152
+ @ Test
152
153
public void asOffsetDateTime_when_null () {
153
- PathTypeConversion .asOffsetDateTime (null );
154
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asOffsetDateTime (null ) );
154
155
}
155
156
156
- @ Test ( expected = InvalidPathArgumentException . class )
157
+ @ Test
157
158
public void asLocalDateTime_when_null () {
158
- PathTypeConversion .asLocalDateTime (null );
159
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asLocalDateTime (null ) );
159
160
}
160
161
161
- @ Test ( expected = InvalidPathArgumentException . class )
162
+ @ Test
162
163
public void asInstant_when_invalid () {
163
- PathTypeConversion .asInstant ("junk" );
164
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asInstant ("junk" ) );
164
165
}
165
166
166
- @ Test ( expected = InvalidPathArgumentException . class )
167
+ @ Test
167
168
public void asOffsetDateTime_when_invalid () {
168
- PathTypeConversion .asOffsetDateTime ("junk" );
169
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asOffsetDateTime ("junk" ) );
169
170
}
170
171
171
- @ Test ( expected = InvalidPathArgumentException . class )
172
+ @ Test
172
173
public void asLocalDateTime_when_invalid () {
173
- PathTypeConversion .asLocalDateTime ("junk" );
174
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asLocalDateTime ("junk" ) );
174
175
}
175
176
176
177
@ Test
@@ -197,29 +198,29 @@ public void asUUID() {
197
198
assertThat (PathTypeConversion .asUUID (uuid .toString ())).isEqualTo (uuid );
198
199
}
199
200
200
- @ Test ( expected = InvalidPathArgumentException . class )
201
+ @ Test
201
202
public void asUUID_when_null () {
202
- PathTypeConversion .asUUID (null );
203
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asUUID (null ) );
203
204
}
204
205
205
- @ Test ( expected = InvalidPathArgumentException . class )
206
+ @ Test
206
207
public void asUUID_when_invalid () {
207
- PathTypeConversion .asUUID ("junk" );
208
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asUUID ("junk" ) );
208
209
}
209
210
210
211
@ Test
211
212
public void asInteger () {
212
213
assertThat (PathTypeConversion .asInteger ("42" )).isEqualTo (42 );
213
214
}
214
215
215
- @ Test ( expected = InvalidPathArgumentException . class )
216
+ @ Test
216
217
public void asInteger_null () {
217
- PathTypeConversion .asInteger (null );
218
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asInteger (null ) );
218
219
}
219
220
220
- @ Test ( expected = InvalidPathArgumentException . class )
221
+ @ Test
221
222
public void asInteger_invalid () {
222
- PathTypeConversion .asInteger ("junk" );
223
+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asInteger ("junk" ) );
223
224
}
224
225
225
226
@ Test
@@ -228,9 +229,9 @@ public void toInteger() {
228
229
assertThat (PathTypeConversion .toInteger (null )).isNull ();
229
230
}
230
231
231
- @ Test ( expected = InvalidTypeArgumentException . class )
232
+ @ Test
232
233
public void toInteger_invalid () {
233
- PathTypeConversion .toInteger ("junk" );
234
+ assertThrows ( InvalidTypeArgumentException . class , () -> PathTypeConversion .toInteger ("junk" ) );
234
235
}
235
236
236
237
@ Test
@@ -239,9 +240,9 @@ public void toLong() {
239
240
assertThat (PathTypeConversion .toLong (null )).isNull ();
240
241
}
241
242
242
- @ Test ( expected = InvalidTypeArgumentException . class )
243
+ @ Test
243
244
public void toLong_invalid () {
244
- PathTypeConversion .toLong ("junk" );
245
+ assertThrows ( InvalidTypeArgumentException . class , () -> PathTypeConversion .toLong ("junk" ) );
245
246
}
246
247
247
248
@ Test
@@ -250,9 +251,9 @@ public void toBigDecimal() {
250
251
assertThat (PathTypeConversion .toBigDecimal (null )).isNull ();
251
252
}
252
253
253
- @ Test ( expected = InvalidTypeArgumentException . class )
254
+ @ Test
254
255
public void toBigDecimal_invalid () {
255
- PathTypeConversion .toBigDecimal ("junk" );
256
+ assertThrows ( InvalidTypeArgumentException . class , () -> PathTypeConversion .toBigDecimal ("junk" ) );
256
257
}
257
258
258
259
@ Test
@@ -269,29 +270,29 @@ public void toUUID() {
269
270
assertThat (PathTypeConversion .toUUID (uuid .toString ())).isEqualTo (uuid );
270
271
}
271
272
272
- @ Test ( expected = InvalidTypeArgumentException . class )
273
+ @ Test
273
274
public void toUUID_invalid () {
274
- PathTypeConversion .toUUID ("junk" );
275
+ assertThrows ( InvalidTypeArgumentException . class , () -> PathTypeConversion .toUUID ("junk" ) );
275
276
}
276
277
277
278
@ Test
278
279
public void toLocalDate () {
279
280
assertThat (PathTypeConversion .toLocalDate ("2018-09-07" )).isEqualTo (LocalDate .of (2018 , 9 , 7 ));
280
281
}
281
282
282
- @ Test ( expected = InvalidTypeArgumentException . class )
283
+ @ Test
283
284
public void toLocalDate_invalid () {
284
- PathTypeConversion .toLocalDate ("junk" );
285
+ assertThrows ( InvalidTypeArgumentException . class , () -> PathTypeConversion .toLocalDate ("junk" ) );
285
286
}
286
287
287
288
@ Test
288
289
public void toLocalTime () {
289
290
assertThat (PathTypeConversion .toLocalTime ("23:34:09" )).isEqualTo (LocalTime .of (23 , 34 , 9 ));
290
291
}
291
292
292
- @ Test ( expected = InvalidTypeArgumentException . class )
293
+ @ Test
293
294
public void toLocalTime_invalid () {
294
- PathTypeConversion .toLocalTime ("junk" );
295
+ assertThrows ( InvalidTypeArgumentException . class , () -> PathTypeConversion .toLocalTime ("junk" ) );
295
296
}
296
297
297
298
@ Test
@@ -300,9 +301,9 @@ public void toInstant() {
300
301
assertThat (PathTypeConversion .toInstant ("2018-09-23T23:34:09Z" )).isEqualTo (instant );
301
302
}
302
303
303
- @ Test ( expected = InvalidTypeArgumentException . class )
304
+ @ Test
304
305
public void toInstant_invalid () {
305
- PathTypeConversion .toInstant ("junk" );
306
+ assertThrows ( InvalidTypeArgumentException . class , () -> PathTypeConversion .toInstant ("junk" ) );
306
307
}
307
308
308
309
@ Test
@@ -311,9 +312,9 @@ public void toOffsetDateTime() {
311
312
assertThat (PathTypeConversion .toOffsetDateTime ("2018-09-23T23:34:09Z" )).isEqualTo (instant );
312
313
}
313
314
314
- @ Test ( expected = InvalidTypeArgumentException . class )
315
+ @ Test
315
316
public void OffsetDateTime_invalid () {
316
- PathTypeConversion .toOffsetDateTime ("junk" );
317
+ assertThrows ( InvalidTypeArgumentException . class , () -> PathTypeConversion .toOffsetDateTime ("junk" ) );
317
318
}
318
319
319
320
@ Test
@@ -322,8 +323,8 @@ public void toLocalDateTime() {
322
323
assertThat (PathTypeConversion .toLocalDateTime ("2018-09-23T23:34:09" )).isEqualTo (instant );
323
324
}
324
325
325
- @ Test ( expected = InvalidTypeArgumentException . class )
326
+ @ Test
326
327
public void LocalDateTime_invalid () {
327
- PathTypeConversion .toLocalDateTime ("junk" );
328
+ assertThrows ( InvalidTypeArgumentException . class , () -> PathTypeConversion .toLocalDateTime ("junk" ) );
328
329
}
329
330
}
0 commit comments