|
@@ -5,14 +5,16 @@
|
|
|
*/
|
|
|
package org.elasticsearch.xpack.core.ml.action;
|
|
|
|
|
|
+import org.elasticsearch.client.ml.PutCalendarResponse;
|
|
|
import org.elasticsearch.common.xcontent.XContentParser;
|
|
|
-import org.elasticsearch.test.AbstractStreamableXContentTestCase;
|
|
|
+import org.elasticsearch.protocol.AbstractHlrcStreamableXContentTestCase;
|
|
|
import org.elasticsearch.xpack.core.ml.calendars.Calendar;
|
|
|
import org.elasticsearch.xpack.core.ml.calendars.CalendarTests;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
-public class PutCalendarActionResponseTests extends AbstractStreamableXContentTestCase<PutCalendarAction.Response> {
|
|
|
+public class PutCalendarActionResponseTests
|
|
|
+ extends AbstractHlrcStreamableXContentTestCase<PutCalendarAction.Response, PutCalendarResponse> {
|
|
|
|
|
|
@Override
|
|
|
protected PutCalendarAction.Response createTestInstance() {
|
|
@@ -20,12 +22,29 @@ public class PutCalendarActionResponseTests extends AbstractStreamableXContentTe
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- protected PutCalendarAction.Response createBlankInstance() {
|
|
|
- return new PutCalendarAction.Response();
|
|
|
+ protected PutCalendarAction.Response doParseInstance(XContentParser parser) throws IOException {
|
|
|
+ return new PutCalendarAction.Response(Calendar.LENIENT_PARSER.parse(parser, null).build());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- protected PutCalendarAction.Response doParseInstance(XContentParser parser) throws IOException {
|
|
|
- return new PutCalendarAction.Response(Calendar.LENIENT_PARSER.parse(parser, null).build());
|
|
|
+ protected boolean supportsUnknownFields() {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PutCalendarResponse doHlrcParseInstance(XContentParser parser) throws IOException {
|
|
|
+ return PutCalendarResponse.fromXContent(parser);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PutCalendarAction.Response convertHlrcToInternal(PutCalendarResponse instance) {
|
|
|
+ org.elasticsearch.client.ml.calendars.Calendar hlrcCalendar = instance.getCalendar();
|
|
|
+ Calendar internalCalendar = new Calendar(hlrcCalendar.getId(), hlrcCalendar.getJobIds(), hlrcCalendar.getDescription());
|
|
|
+ return new PutCalendarAction.Response(internalCalendar);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected PutCalendarAction.Response createBlankInstance() {
|
|
|
+ return new PutCalendarAction.Response();
|
|
|
}
|
|
|
}
|