20
20
21
21
import static org .assertj .core .api .Assertions .assertThat ;
22
22
23
+ /**
24
+ * Tests for {@link WebClientResponseException}.
25
+ *
26
+ * @author Simon Baslé
27
+ */
23
28
class WebClientResponseExceptionTests {
24
29
25
30
@ Test
@@ -31,57 +36,58 @@ void constructWithSuccessStatusCodeAndNoCauseAdditionalMessage() {
31
36
32
37
@ Test
33
38
void constructWith1xxStatusCodeAndCauseAdditionalMessage () {
34
- final WebClientResponseException ex = new WebClientResponseException (100 , "reasonPhrase" , null , null , null );
39
+ WebClientResponseException ex = new WebClientResponseException (100 , "reasonPhrase" , null , null , null );
35
40
ex .initCause (new RuntimeException ("example cause" ));
36
41
assertThat (ex ).hasMessage ("100 reasonPhrase, but response failed with cause: java.lang.RuntimeException: example cause" );
37
42
}
38
43
39
44
@ Test
40
45
void constructWith2xxStatusCodeAndCauseAdditionalMessage () {
41
- final WebClientResponseException ex = new WebClientResponseException (200 , "reasonPhrase" , null , null , null );
46
+ WebClientResponseException ex = new WebClientResponseException (200 , "reasonPhrase" , null , null , null );
42
47
ex .initCause (new RuntimeException ("example cause" ));
43
48
assertThat (ex ).hasMessage ("200 reasonPhrase, but response failed with cause: java.lang.RuntimeException: example cause" );
44
49
}
45
50
46
51
@ Test
47
52
void constructWith3xxStatusCodeAndCauseAdditionalMessage () {
48
- final WebClientResponseException ex = new WebClientResponseException (300 , "reasonPhrase" , null , null , null );
53
+ WebClientResponseException ex = new WebClientResponseException (300 , "reasonPhrase" , null , null , null );
49
54
ex .initCause (new RuntimeException ("example cause" ));
50
55
assertThat (ex ).hasMessage ("300 reasonPhrase, but response failed with cause: java.lang.RuntimeException: example cause" );
51
56
}
52
57
53
58
@ Test
54
59
void constructWithExplicitMessageAndNotErrorCodeAdditionalMessage () {
55
- final WebClientResponseException ex = new WebClientResponseException ("explicit message" , 100 , "reasonPhrase" , null , null , null );
60
+ WebClientResponseException ex = new WebClientResponseException ("explicit message" , 100 , "reasonPhrase" , null , null , null );
56
61
assertThat (ex ).hasMessage ("explicit message, but response failed with cause: null" );
57
62
}
58
63
59
64
@ Test
60
65
void constructWithExplicitMessageAndNotErrorCodeAndCauseAdditionalMessage () {
61
- final WebClientResponseException ex = new WebClientResponseException ("explicit message" , 100 , "reasonPhrase" , null , null , null );
66
+ WebClientResponseException ex = new WebClientResponseException ("explicit message" , 100 , "reasonPhrase" , null , null , null );
62
67
ex .initCause (new RuntimeException ("example cause" ));
63
68
assertThat (ex ).hasMessage ("explicit message, but response failed with cause: java.lang.RuntimeException: example cause" )
64
69
.hasRootCauseMessage ("example cause" );
65
70
}
66
71
67
72
@ Test
68
73
void constructWithExplicitMessageAndErrorCodeAndCauseNoAdditionalMessage () {
69
- final WebClientResponseException ex = new WebClientResponseException ("explicit message" , 404 , "reasonPhrase" , null , null , null );
74
+ WebClientResponseException ex = new WebClientResponseException ("explicit message" , 404 , "reasonPhrase" , null , null , null );
70
75
ex .initCause (new RuntimeException ("example cause" ));
71
76
assertThat (ex ).hasMessage ("explicit message" ).hasRootCauseMessage ("example cause" );
72
77
}
73
78
74
79
@ Test
75
80
void constructWith4xxStatusCodeAndCauseNoAdditionalMessage () {
76
- final WebClientResponseException ex = new WebClientResponseException (400 , "reasonPhrase" , null , null , null );
81
+ WebClientResponseException ex = new WebClientResponseException (400 , "reasonPhrase" , null , null , null );
77
82
ex .initCause (new RuntimeException ("example cause" ));
78
83
assertThat (ex ).hasMessage ("400 reasonPhrase" ).hasRootCauseMessage ("example cause" );
79
84
}
80
85
81
86
@ Test
82
87
void constructWith5xxStatusCodeAndCauseNoAdditionalMessage () {
83
- final WebClientResponseException ex = new WebClientResponseException (500 , "reasonPhrase" , null , null , null );
88
+ WebClientResponseException ex = new WebClientResponseException (500 , "reasonPhrase" , null , null , null );
84
89
ex .initCause (new RuntimeException ("example cause" ));
85
90
assertThat (ex ).hasMessage ("500 reasonPhrase" ).hasRootCauseMessage ("example cause" );
86
91
}
92
+
87
93
}
0 commit comments