|
5 | 5 | */ |
6 | 6 | package org.elasticsearch.xpack.core.ml.action; |
7 | 7 |
|
| 8 | +import org.elasticsearch.client.ml.PutCalendarResponse; |
8 | 9 | import org.elasticsearch.common.xcontent.XContentParser; |
9 | | -import org.elasticsearch.test.AbstractStreamableXContentTestCase; |
| 10 | +import org.elasticsearch.protocol.AbstractHlrcStreamableXContentTestCase; |
10 | 11 | import org.elasticsearch.xpack.core.ml.calendars.Calendar; |
11 | 12 | import org.elasticsearch.xpack.core.ml.calendars.CalendarTests; |
12 | 13 |
|
13 | 14 | import java.io.IOException; |
14 | 15 |
|
15 | | -public class PutCalendarActionResponseTests extends AbstractStreamableXContentTestCase<PutCalendarAction.Response> { |
| 16 | +public class PutCalendarActionResponseTests |
| 17 | + extends AbstractHlrcStreamableXContentTestCase<PutCalendarAction.Response, PutCalendarResponse> { |
16 | 18 |
|
17 | 19 | @Override |
18 | 20 | protected PutCalendarAction.Response createTestInstance() { |
19 | 21 | return new PutCalendarAction.Response(CalendarTests.testInstance()); |
20 | 22 | } |
21 | 23 |
|
22 | 24 | @Override |
23 | | - protected PutCalendarAction.Response createBlankInstance() { |
24 | | - return new PutCalendarAction.Response(); |
| 25 | + protected PutCalendarAction.Response doParseInstance(XContentParser parser) throws IOException { |
| 26 | + return new PutCalendarAction.Response(Calendar.LENIENT_PARSER.parse(parser, null).build()); |
25 | 27 | } |
26 | 28 |
|
27 | 29 | @Override |
28 | | - protected PutCalendarAction.Response doParseInstance(XContentParser parser) throws IOException { |
29 | | - return new PutCalendarAction.Response(Calendar.LENIENT_PARSER.parse(parser, null).build()); |
| 30 | + protected boolean supportsUnknownFields() { |
| 31 | + return true; |
| 32 | + } |
| 33 | + |
| 34 | + @Override |
| 35 | + public PutCalendarResponse doHlrcParseInstance(XContentParser parser) throws IOException { |
| 36 | + return PutCalendarResponse.fromXContent(parser); |
| 37 | + } |
| 38 | + |
| 39 | + @Override |
| 40 | + public PutCalendarAction.Response convertHlrcToInternal(PutCalendarResponse instance) { |
| 41 | + org.elasticsearch.client.ml.calendars.Calendar hlrcCalendar = instance.getCalendar(); |
| 42 | + Calendar internalCalendar = new Calendar(hlrcCalendar.getId(), hlrcCalendar.getJobIds(), hlrcCalendar.getDescription()); |
| 43 | + return new PutCalendarAction.Response(internalCalendar); |
| 44 | + } |
| 45 | + |
| 46 | + @Override |
| 47 | + protected PutCalendarAction.Response createBlankInstance() { |
| 48 | + return new PutCalendarAction.Response(); |
30 | 49 | } |
31 | 50 | } |
0 commit comments