Moving xpack.plugin.core ml response to use new base class (#35157)

* Moving xpack.plugin.core ml response to use new base class

* changing back to streamable
This commit is contained in:
Benjamin Trent 2018-11-02 07:46:53 -05:00 committed by GitHub
parent 8f592bda27
commit 7fb95be8bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 7 deletions

View File

@ -5,27 +5,46 @@
*/
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() {
return new PutCalendarAction.Response(CalendarTests.testInstance());
}
@Override
protected PutCalendarAction.Response createBlankInstance() {
return new PutCalendarAction.Response();
}
@Override
protected PutCalendarAction.Response doParseInstance(XContentParser parser) throws IOException {
return new PutCalendarAction.Response(Calendar.LENIENT_PARSER.parse(parser, null).build());
}
@Override
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();
}
}