|
56 | 56 | import static com.proofpoint.http.client.Request.Builder.prepareDelete; |
57 | 57 | import static com.proofpoint.http.client.Request.Builder.prepareGet; |
58 | 58 | import static com.proofpoint.http.client.Request.Builder.preparePost; |
| 59 | +import static com.proofpoint.http.client.SmileBodyGenerator.smileBodyGenerator; |
59 | 60 | import static com.proofpoint.http.client.StaticBodyGenerator.createStaticBodyGenerator; |
60 | 61 | import static com.proofpoint.http.client.StatusResponseHandler.createStatusResponseHandler; |
61 | 62 | import static com.proofpoint.http.client.StringResponseHandler.createStringResponseHandler; |
@@ -169,18 +170,10 @@ public void testPostSmile() |
169 | 170 | throws IOException, ExecutionException, InterruptedException |
170 | 171 | { |
171 | 172 | StatusResponse response = client.execute(preparePost() |
172 | | - .setUri(urlFor("/v2/event")) |
173 | | - .setHeader("Content-Type", "application/x-jackson-smile") |
174 | | - .setBodyGenerator(new BodyGenerator() |
175 | | - { |
176 | | - @Override |
177 | | - public void write(OutputStream outputStream) |
178 | | - throws Exception |
179 | | - { |
180 | | - MAPPER.writeValue(outputStream, TESTING_SINGLE_EVENT_STRUCTURE); |
181 | | - } |
182 | | - }) |
183 | | - .build(), |
| 173 | + .setUri(urlFor("/v2/event")) |
| 174 | + .setHeader("Content-Type", "application/x-jackson-smile") |
| 175 | + .setBodyGenerator(smileBodyGenerator(OBJECT_CODEC, TESTING_SINGLE_EVENT_STRUCTURE)) |
| 176 | + .build(), |
184 | 177 | createStatusResponseHandler()); |
185 | 178 |
|
186 | 179 | assertEquals(response.getStatusCode(), Status.ACCEPTED.getStatusCode()); |
@@ -248,15 +241,7 @@ public void testDistributeSmile() |
248 | 241 | StatusResponse response = client.execute(preparePost() |
249 | 242 | .setUri(urlFor("/v2/event/distribute")) |
250 | 243 | .setHeader("Content-Type", "application/x-jackson-smile") |
251 | | - .setBodyGenerator(new BodyGenerator() |
252 | | - { |
253 | | - @Override |
254 | | - public void write(OutputStream outputStream) |
255 | | - throws Exception |
256 | | - { |
257 | | - MAPPER.writeValue(outputStream, TESTING_SINGLE_EVENT_STRUCTURE); |
258 | | - } |
259 | | - }) |
| 244 | + .setBodyGenerator(smileBodyGenerator(OBJECT_CODEC, TESTING_SINGLE_EVENT_STRUCTURE)) |
260 | 245 | .build(), |
261 | 246 | createStatusResponseHandler()); |
262 | 247 |
|
|
0 commit comments