@@ -70,10 +70,9 @@ public void performGet() {
70
70
String responseBody = "{\" name\" : \" Ludwig van Beethoven\" , \" someDouble\" : \" 1.6035\" }" ;
71
71
72
72
this .mockServer .expect (requestTo ("/composers/42" )).andExpect (method (HttpMethod .GET ))
73
- .andRespond (withSuccess (responseBody , MediaType .APPLICATION_JSON ));
73
+ .andRespond (withSuccess (responseBody , MediaType .APPLICATION_JSON ));
74
74
75
- @ SuppressWarnings ("unused" )
76
- Person ludwig = this .restTemplate .getForObject ("/composers/{id}" , Person .class , 42 );
75
+ this .restTemplate .getForObject ("/composers/{id}" , Person .class , 42 );
77
76
78
77
// We are only validating the request. The response is mocked out.
79
78
// hotel.getId() == 42
@@ -90,8 +89,7 @@ public void performGetManyTimes() {
90
89
this .mockServer .expect (manyTimes (), requestTo ("/composers/42" )).andExpect (method (HttpMethod .GET ))
91
90
.andRespond (withSuccess (responseBody , MediaType .APPLICATION_JSON ));
92
91
93
- @ SuppressWarnings ("unused" )
94
- Person ludwig = this .restTemplate .getForObject ("/composers/{id}" , Person .class , 42 );
92
+ this .restTemplate .getForObject ("/composers/{id}" , Person .class , 42 );
95
93
96
94
// We are only validating the request. The response is mocked out.
97
95
// hotel.getId() == 42
@@ -142,8 +140,7 @@ public void performGetWithResponseBodyFromFile() {
142
140
this .mockServer .expect (requestTo ("/composers/42" )).andExpect (method (HttpMethod .GET ))
143
141
.andRespond (withSuccess (responseBody , MediaType .APPLICATION_JSON ));
144
142
145
- @ SuppressWarnings ("unused" )
146
- Person ludwig = this .restTemplate .getForObject ("/composers/{id}" , Person .class , 42 );
143
+ this .restTemplate .getForObject ("/composers/{id}" , Person .class , 42 );
147
144
148
145
// hotel.getId() == 42
149
146
// hotel.getName().equals("Holiday Inn")
@@ -155,24 +152,19 @@ public void performGetWithResponseBodyFromFile() {
155
152
public void verify () {
156
153
157
154
this .mockServer .expect (requestTo ("/number" )).andExpect (method (HttpMethod .GET ))
158
- .andRespond (withSuccess ("1" , MediaType .TEXT_PLAIN ));
155
+ .andRespond (withSuccess ("1" , MediaType .TEXT_PLAIN ));
159
156
160
157
this .mockServer .expect (requestTo ("/number" )).andExpect (method (HttpMethod .GET ))
161
- .andRespond (withSuccess ("2" , MediaType .TEXT_PLAIN ));
158
+ .andRespond (withSuccess ("2" , MediaType .TEXT_PLAIN ));
162
159
163
160
this .mockServer .expect (requestTo ("/number" )).andExpect (method (HttpMethod .GET ))
164
- .andRespond (withSuccess ("4" , MediaType .TEXT_PLAIN ));
161
+ .andRespond (withSuccess ("4" , MediaType .TEXT_PLAIN ));
165
162
166
163
this .mockServer .expect (requestTo ("/number" )).andExpect (method (HttpMethod .GET ))
167
- .andRespond (withSuccess ("8" , MediaType .TEXT_PLAIN ));
168
-
169
- @ SuppressWarnings ("unused" )
170
- String result1 = this .restTemplate .getForObject ("/number" , String .class );
171
- // result1 == "1"
164
+ .andRespond (withSuccess ("8" , MediaType .TEXT_PLAIN ));
172
165
173
- @ SuppressWarnings ("unused" )
174
- String result2 = this .restTemplate .getForObject ("/number" , String .class );
175
- // result == "2"
166
+ assertThat (this .restTemplate .getForObject ("/number" , String .class )).isEqualTo ("1" );
167
+ assertThat (this .restTemplate .getForObject ("/number" , String .class )).isEqualTo ("2" );
176
168
177
169
try {
178
170
this .mockServer .verify ();
@@ -215,7 +207,7 @@ private ContentInterceptor(Resource resource) {
215
207
216
208
@ Override
217
209
public ClientHttpResponse intercept (HttpRequest request , byte [] body ,
218
- ClientHttpRequestExecution execution ) throws IOException {
210
+ ClientHttpRequestExecution execution ) throws IOException {
219
211
220
212
ClientHttpResponse response = execution .execute (request , body );
221
213
byte [] expected = FileCopyUtils .copyToByteArray (this .resource .getInputStream ());
0 commit comments