11package io .dinject .controller ;
22
3- import org .junit .Test ;
3+ import org .junit .jupiter . api . Test ;
44
55import java .time .Instant ;
66import java .time .LocalDate ;
1010import java .util .UUID ;
1111
1212import 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 ;
1415
1516public class PathTypeConversionTest {
1617
17- @ Test ( expected = RequiredArgumentException . class )
18+ @ Test
1819 public void checkNull_when_null () {
19- PathTypeConversion .checkNull (null , "id" );
20+ assertThrows ( RequiredArgumentException . class , () -> PathTypeConversion .checkNull (null , "id" ) );
2021 }
2122
2223 @ Test
@@ -29,64 +30,64 @@ public void asInt() {
2930 assertEquals (42 , PathTypeConversion .asInt ("42" ));
3031 }
3132
32- @ Test ( expected = InvalidPathArgumentException . class )
33+ @ Test
3334 public void asInt_when_null () {
34- PathTypeConversion .asInt (null );
35+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asInt (null ) );
3536 }
3637
37- @ Test ( expected = InvalidPathArgumentException . class )
38+ @ Test
3839 public void asInt_when_invalid () {
39- PathTypeConversion .asInt ("junk" );
40+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asInt ("junk" ) );
4041 }
4142
4243 @ Test
4344 public void asLong () {
4445 assertEquals (42L , PathTypeConversion .asInt ("42" ));
4546 }
4647
47- @ Test ( expected = InvalidPathArgumentException . class )
48+ @ Test
4849 public void asLong_when_invalid () {
49- PathTypeConversion .asLong ("junk" );
50+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asLong ("junk" ) );
5051 }
5152
52- @ Test ( expected = InvalidPathArgumentException . class )
53+ @ Test
5354 public void asLong_when_null () {
54- PathTypeConversion .asLong (null );
55+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asLong (null ) );
5556 }
5657
5758 @ Test
5859 public void asDouble () {
5960 assertThat (PathTypeConversion .asDouble ("42" )).isEqualTo (42d );
6061 }
6162
62- @ Test ( expected = InvalidPathArgumentException . class )
63+ @ Test
6364 public void asDouble_when_invalid () {
64- PathTypeConversion .asDouble ("jukn" );
65+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asDouble ("jukn" ) );
6566 }
6667
67- @ Test ( expected = InvalidPathArgumentException . class )
68+ @ Test
6869 public void asDouble_when_null () {
69- PathTypeConversion .asDouble (null );
70+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asDouble (null ) );
7071 }
7172
7273 @ Test
7374 public void asFloat () {
7475 assertThat (PathTypeConversion .asFloat ("42" )).isEqualTo (42f );
7576 }
7677
77- @ Test ( expected = InvalidPathArgumentException . class )
78+ @ Test
7879 public void asFloat_when_null () {
79- PathTypeConversion .asFloat (null );
80+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asFloat (null ) );
8081 }
8182
82- @ Test ( expected = InvalidPathArgumentException . class )
83+ @ Test
8384 public void asFloat_when_invalid () {
84- PathTypeConversion .asFloat ("junk" );
85+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asFloat ("junk" ) );
8586 }
8687
87- @ Test ( expected = InvalidPathArgumentException . class )
88+ @ Test
8889 public void asBool_when_null () {
89- PathTypeConversion .asBool (null );
90+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asBool (null ) );
9091 }
9192
9293 @ Test
@@ -103,74 +104,74 @@ public void asBigDecimal() {
103104 assertThat (PathTypeConversion .asBigDecimal ("42.3" )).isEqualByComparingTo ("42.3" );
104105 }
105106
106- @ Test ( expected = InvalidPathArgumentException . class )
107+ @ Test
107108 public void asBigDecimal_when_null () {
108- PathTypeConversion .asBigDecimal (null );
109+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asBigDecimal (null ) );
109110 }
110111
111- @ Test ( expected = InvalidPathArgumentException . class )
112+ @ Test
112113 public void asBigDecimal_when_invalid () {
113- PathTypeConversion .asBigDecimal ("junk" );
114+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asBigDecimal ("junk" ) );
114115 }
115116
116117 @ Test
117118 public void asLocalDate () {
118119 assertThat (PathTypeConversion .asLocalDate ("2018-06-03" )).isEqualTo (LocalDate .of (2018 , 6 , 3 ));
119120 }
120121
121- @ Test ( expected = InvalidPathArgumentException . class )
122+ @ Test
122123 public void asLocalDate_when_null () {
123- PathTypeConversion .asLocalDate (null );
124+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asLocalDate (null ) );
124125 }
125126
126- @ Test ( expected = InvalidPathArgumentException . class )
127+ @ Test
127128 public void asLocalDate_when_invalid () {
128- PathTypeConversion .asLocalDate ("junk" );
129+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asLocalDate ("junk" ) );
129130 }
130131
131- @ Test ( expected = InvalidPathArgumentException . class )
132+ @ Test
132133 public void asLocalTime_when_invalid () {
133- PathTypeConversion .asLocalTime ("junk" );
134+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asLocalTime ("junk" ) );
134135 }
135136
136- @ Test ( expected = InvalidPathArgumentException . class )
137+ @ Test
137138 public void asLocalTime_when_null () {
138- PathTypeConversion .asLocalTime (null );
139+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asLocalTime (null ) );
139140 }
140141
141142 @ Test
142143 public void asLocalTime () {
143144 assertThat (PathTypeConversion .asLocalTime ("23:34:09" )).isEqualTo (LocalTime .of (23 , 34 , 9 ));
144145 }
145146
146- @ Test ( expected = InvalidPathArgumentException . class )
147+ @ Test
147148 public void asInstant_when_null () {
148- PathTypeConversion .asInstant (null );
149+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asInstant (null ) );
149150 }
150151
151- @ Test ( expected = InvalidPathArgumentException . class )
152+ @ Test
152153 public void asOffsetDateTime_when_null () {
153- PathTypeConversion .asOffsetDateTime (null );
154+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asOffsetDateTime (null ) );
154155 }
155156
156- @ Test ( expected = InvalidPathArgumentException . class )
157+ @ Test
157158 public void asLocalDateTime_when_null () {
158- PathTypeConversion .asLocalDateTime (null );
159+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asLocalDateTime (null ) );
159160 }
160161
161- @ Test ( expected = InvalidPathArgumentException . class )
162+ @ Test
162163 public void asInstant_when_invalid () {
163- PathTypeConversion .asInstant ("junk" );
164+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asInstant ("junk" ) );
164165 }
165166
166- @ Test ( expected = InvalidPathArgumentException . class )
167+ @ Test
167168 public void asOffsetDateTime_when_invalid () {
168- PathTypeConversion .asOffsetDateTime ("junk" );
169+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asOffsetDateTime ("junk" ) );
169170 }
170171
171- @ Test ( expected = InvalidPathArgumentException . class )
172+ @ Test
172173 public void asLocalDateTime_when_invalid () {
173- PathTypeConversion .asLocalDateTime ("junk" );
174+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asLocalDateTime ("junk" ) );
174175 }
175176
176177 @ Test
@@ -197,29 +198,29 @@ public void asUUID() {
197198 assertThat (PathTypeConversion .asUUID (uuid .toString ())).isEqualTo (uuid );
198199 }
199200
200- @ Test ( expected = InvalidPathArgumentException . class )
201+ @ Test
201202 public void asUUID_when_null () {
202- PathTypeConversion .asUUID (null );
203+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asUUID (null ) );
203204 }
204205
205- @ Test ( expected = InvalidPathArgumentException . class )
206+ @ Test
206207 public void asUUID_when_invalid () {
207- PathTypeConversion .asUUID ("junk" );
208+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asUUID ("junk" ) );
208209 }
209210
210211 @ Test
211212 public void asInteger () {
212213 assertThat (PathTypeConversion .asInteger ("42" )).isEqualTo (42 );
213214 }
214215
215- @ Test ( expected = InvalidPathArgumentException . class )
216+ @ Test
216217 public void asInteger_null () {
217- PathTypeConversion .asInteger (null );
218+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asInteger (null ) );
218219 }
219220
220- @ Test ( expected = InvalidPathArgumentException . class )
221+ @ Test
221222 public void asInteger_invalid () {
222- PathTypeConversion .asInteger ("junk" );
223+ assertThrows ( InvalidPathArgumentException . class , () -> PathTypeConversion .asInteger ("junk" ) );
223224 }
224225
225226 @ Test
@@ -228,9 +229,9 @@ public void toInteger() {
228229 assertThat (PathTypeConversion .toInteger (null )).isNull ();
229230 }
230231
231- @ Test ( expected = InvalidTypeArgumentException . class )
232+ @ Test
232233 public void toInteger_invalid () {
233- PathTypeConversion .toInteger ("junk" );
234+ assertThrows ( InvalidTypeArgumentException . class , () -> PathTypeConversion .toInteger ("junk" ) );
234235 }
235236
236237 @ Test
@@ -239,9 +240,9 @@ public void toLong() {
239240 assertThat (PathTypeConversion .toLong (null )).isNull ();
240241 }
241242
242- @ Test ( expected = InvalidTypeArgumentException . class )
243+ @ Test
243244 public void toLong_invalid () {
244- PathTypeConversion .toLong ("junk" );
245+ assertThrows ( InvalidTypeArgumentException . class , () -> PathTypeConversion .toLong ("junk" ) );
245246 }
246247
247248 @ Test
@@ -250,9 +251,9 @@ public void toBigDecimal() {
250251 assertThat (PathTypeConversion .toBigDecimal (null )).isNull ();
251252 }
252253
253- @ Test ( expected = InvalidTypeArgumentException . class )
254+ @ Test
254255 public void toBigDecimal_invalid () {
255- PathTypeConversion .toBigDecimal ("junk" );
256+ assertThrows ( InvalidTypeArgumentException . class , () -> PathTypeConversion .toBigDecimal ("junk" ) );
256257 }
257258
258259 @ Test
@@ -269,29 +270,29 @@ public void toUUID() {
269270 assertThat (PathTypeConversion .toUUID (uuid .toString ())).isEqualTo (uuid );
270271 }
271272
272- @ Test ( expected = InvalidTypeArgumentException . class )
273+ @ Test
273274 public void toUUID_invalid () {
274- PathTypeConversion .toUUID ("junk" );
275+ assertThrows ( InvalidTypeArgumentException . class , () -> PathTypeConversion .toUUID ("junk" ) );
275276 }
276277
277278 @ Test
278279 public void toLocalDate () {
279280 assertThat (PathTypeConversion .toLocalDate ("2018-09-07" )).isEqualTo (LocalDate .of (2018 , 9 , 7 ));
280281 }
281282
282- @ Test ( expected = InvalidTypeArgumentException . class )
283+ @ Test
283284 public void toLocalDate_invalid () {
284- PathTypeConversion .toLocalDate ("junk" );
285+ assertThrows ( InvalidTypeArgumentException . class , () -> PathTypeConversion .toLocalDate ("junk" ) );
285286 }
286287
287288 @ Test
288289 public void toLocalTime () {
289290 assertThat (PathTypeConversion .toLocalTime ("23:34:09" )).isEqualTo (LocalTime .of (23 , 34 , 9 ));
290291 }
291292
292- @ Test ( expected = InvalidTypeArgumentException . class )
293+ @ Test
293294 public void toLocalTime_invalid () {
294- PathTypeConversion .toLocalTime ("junk" );
295+ assertThrows ( InvalidTypeArgumentException . class , () -> PathTypeConversion .toLocalTime ("junk" ) );
295296 }
296297
297298 @ Test
@@ -300,9 +301,9 @@ public void toInstant() {
300301 assertThat (PathTypeConversion .toInstant ("2018-09-23T23:34:09Z" )).isEqualTo (instant );
301302 }
302303
303- @ Test ( expected = InvalidTypeArgumentException . class )
304+ @ Test
304305 public void toInstant_invalid () {
305- PathTypeConversion .toInstant ("junk" );
306+ assertThrows ( InvalidTypeArgumentException . class , () -> PathTypeConversion .toInstant ("junk" ) );
306307 }
307308
308309 @ Test
@@ -311,9 +312,9 @@ public void toOffsetDateTime() {
311312 assertThat (PathTypeConversion .toOffsetDateTime ("2018-09-23T23:34:09Z" )).isEqualTo (instant );
312313 }
313314
314- @ Test ( expected = InvalidTypeArgumentException . class )
315+ @ Test
315316 public void OffsetDateTime_invalid () {
316- PathTypeConversion .toOffsetDateTime ("junk" );
317+ assertThrows ( InvalidTypeArgumentException . class , () -> PathTypeConversion .toOffsetDateTime ("junk" ) );
317318 }
318319
319320 @ Test
@@ -322,8 +323,8 @@ public void toLocalDateTime() {
322323 assertThat (PathTypeConversion .toLocalDateTime ("2018-09-23T23:34:09" )).isEqualTo (instant );
323324 }
324325
325- @ Test ( expected = InvalidTypeArgumentException . class )
326+ @ Test
326327 public void LocalDateTime_invalid () {
327- PathTypeConversion .toLocalDateTime ("junk" );
328+ assertThrows ( InvalidTypeArgumentException . class , () -> PathTypeConversion .toLocalDateTime ("junk" ) );
328329 }
329330}
0 commit comments