|
18 | 18 | */ |
19 | 19 | package org.elasticsearch.client.watcher; |
20 | 20 |
|
21 | | -import org.elasticsearch.common.xcontent.XContentParser; |
22 | | -import org.elasticsearch.test.AbstractXContentTestCase; |
| 21 | +import org.elasticsearch.common.xcontent.XContentBuilder; |
| 22 | +import org.elasticsearch.test.ESTestCase; |
23 | 23 |
|
24 | 24 | import java.io.IOException; |
25 | 25 |
|
26 | | -public class PutWatchResponseTests extends AbstractXContentTestCase<PutWatchResponse> { |
| 26 | +import static org.elasticsearch.test.AbstractXContentTestCase.xContentTester; |
27 | 27 |
|
28 | | - @Override |
29 | | - protected PutWatchResponse createTestInstance() { |
30 | | - String id = randomAlphaOfLength(10); |
31 | | - long version = randomLongBetween(1, 10); |
32 | | - boolean created = randomBoolean(); |
33 | | - return new PutWatchResponse(id, version, created); |
| 28 | +public class PutWatchResponseTests extends ESTestCase { |
| 29 | + |
| 30 | + public void testFromXContent() throws IOException { |
| 31 | + xContentTester(this::createParser, |
| 32 | + PutWatchResponseTests::createTestInstance, |
| 33 | + PutWatchResponseTests::toXContent, |
| 34 | + PutWatchResponse::fromXContent) |
| 35 | + .supportsUnknownFields(true) |
| 36 | + .assertToXContentEquivalence(false) |
| 37 | + .test(); |
34 | 38 | } |
35 | 39 |
|
36 | | - @Override |
37 | | - protected PutWatchResponse doParseInstance(XContentParser parser) throws IOException { |
38 | | - return PutWatchResponse.fromXContent(parser); |
| 40 | + private static XContentBuilder toXContent(PutWatchResponse response, XContentBuilder builder) throws IOException { |
| 41 | + return builder.startObject() |
| 42 | + .field("_id", response.getId()) |
| 43 | + .field("_version", response.getVersion()) |
| 44 | + .field("created", response.isCreated()) |
| 45 | + .endObject(); |
39 | 46 | } |
40 | 47 |
|
41 | | - @Override |
42 | | - protected boolean supportsUnknownFields() { |
43 | | - return false; |
| 48 | + private static PutWatchResponse createTestInstance() { |
| 49 | + String id = randomAlphaOfLength(10); |
| 50 | + long version = randomLongBetween(1, 10); |
| 51 | + boolean created = randomBoolean(); |
| 52 | + return new PutWatchResponse(id, version, created); |
44 | 53 | } |
45 | 54 | } |
0 commit comments