Skip to content

Commit d91dc73

Browse files
committed
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
1 parent 13f90fd commit d91dc73

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/action/PutCalendarActionResponseTests.java

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,46 @@
55
*/
66
package org.elasticsearch.xpack.core.ml.action;
77

8+
import org.elasticsearch.client.ml.PutCalendarResponse;
89
import org.elasticsearch.common.xcontent.XContentParser;
9-
import org.elasticsearch.test.AbstractStreamableXContentTestCase;
10+
import org.elasticsearch.protocol.AbstractHlrcStreamableXContentTestCase;
1011
import org.elasticsearch.xpack.core.ml.calendars.Calendar;
1112
import org.elasticsearch.xpack.core.ml.calendars.CalendarTests;
1213

1314
import java.io.IOException;
1415

15-
public class PutCalendarActionResponseTests extends AbstractStreamableXContentTestCase<PutCalendarAction.Response> {
16+
public class PutCalendarActionResponseTests
17+
extends AbstractHlrcStreamableXContentTestCase<PutCalendarAction.Response, PutCalendarResponse> {
1618

1719
@Override
1820
protected PutCalendarAction.Response createTestInstance() {
1921
return new PutCalendarAction.Response(CalendarTests.testInstance());
2022
}
2123

2224
@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());
2527
}
2628

2729
@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();
3049
}
3150
}

0 commit comments

Comments
 (0)