|
21 | 21 |
|
22 | 22 | import org.elasticsearch.common.xcontent.DeprecationHandler;
|
23 | 23 | import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
| 24 | +import org.elasticsearch.common.xcontent.XContentBuilder; |
24 | 25 | import org.elasticsearch.common.xcontent.XContentParser;
|
25 | 26 | import org.elasticsearch.common.xcontent.XContentType;
|
26 | 27 | import org.elasticsearch.test.ESTestCase;
|
|
30 | 31 | import java.util.EnumSet;
|
31 | 32 | import java.util.stream.Collectors;
|
32 | 33 |
|
| 34 | +import static org.elasticsearch.test.AbstractXContentTestCase.xContentTester; |
| 35 | + |
33 | 36 | public class LifecycleManagementStatusResponseTests extends ESTestCase {
|
34 | 37 |
|
| 38 | + public void testFromXContent() throws IOException { |
| 39 | + xContentTester(this::createParser, |
| 40 | + LifecycleManagementStatusResponseTests::createTestInstance, |
| 41 | + LifecycleManagementStatusResponseTests::toXContent, |
| 42 | + LifecycleManagementStatusResponse::fromXContent) |
| 43 | + .supportsUnknownFields(true) |
| 44 | + .assertToXContentEquivalence(false) |
| 45 | + .test(); |
| 46 | + } |
| 47 | + |
| 48 | + private static XContentBuilder toXContent(LifecycleManagementStatusResponse response, XContentBuilder builder) throws IOException { |
| 49 | + builder.startObject(); |
| 50 | + builder.field("operation_mode", response.getOperationMode()); |
| 51 | + builder.endObject(); |
| 52 | + return builder; |
| 53 | + } |
| 54 | + |
| 55 | + private static LifecycleManagementStatusResponse createTestInstance() { |
| 56 | + return new LifecycleManagementStatusResponse(randomFrom(OperationMode.values()).name()); |
| 57 | + } |
| 58 | + |
35 | 59 | public void testAllValidStatuses() {
|
36 | 60 | EnumSet.allOf(OperationMode.class)
|
37 | 61 | .forEach(e -> assertEquals(new LifecycleManagementStatusResponse(e.name()).getOperationMode(), e));
|
|
0 commit comments