Adapt to upstream changes made to AbstractStreamableXContentTestCase (elastic/x-pack-elasticsearch#2117)
Original commit: elastic/x-pack-elasticsearch@0b1be31ffa
This commit is contained in:
parent
a35234de56
commit
9fcb230d90
|
@ -32,7 +32,6 @@ import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
|
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
|
||||||
import org.elasticsearch.common.util.concurrent.AtomicArray;
|
import org.elasticsearch.common.util.concurrent.AtomicArray;
|
||||||
import org.elasticsearch.common.xcontent.ObjectParser;
|
import org.elasticsearch.common.xcontent.ObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
@ -86,7 +85,7 @@ public class CloseJobAction extends Action<CloseJobAction.Request, CloseJobActio
|
||||||
return new Response();
|
return new Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Request extends BaseTasksRequest<Request> implements ToXContent {
|
public static class Request extends BaseTasksRequest<Request> implements ToXContentObject {
|
||||||
|
|
||||||
public static final ParseField TIMEOUT = new ParseField("timeout");
|
public static final ParseField TIMEOUT = new ParseField("timeout");
|
||||||
public static final ParseField FORCE = new ParseField("force");
|
public static final ParseField FORCE = new ParseField("force");
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.ObjectParser;
|
import org.elasticsearch.common.xcontent.ObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
@ -62,7 +61,7 @@ public class GetBucketsAction extends Action<GetBucketsAction.Request, GetBucket
|
||||||
return new Response();
|
return new Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Request extends ActionRequest implements ToXContent {
|
public static class Request extends ActionRequest implements ToXContentObject {
|
||||||
|
|
||||||
public static final ParseField EXPAND = new ParseField("expand");
|
public static final ParseField EXPAND = new ParseField("expand");
|
||||||
public static final ParseField EXCLUDE_INTERIM = new ParseField("exclude_interim");
|
public static final ParseField EXCLUDE_INTERIM = new ParseField("exclude_interim");
|
||||||
|
|
|
@ -22,7 +22,6 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.ObjectParser;
|
import org.elasticsearch.common.xcontent.ObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
@ -61,7 +60,7 @@ Action<GetCategoriesAction.Request, GetCategoriesAction.Response, GetCategoriesA
|
||||||
return new Response();
|
return new Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Request extends ActionRequest implements ToXContent {
|
public static class Request extends ActionRequest implements ToXContentObject {
|
||||||
|
|
||||||
public static final ParseField CATEGORY_ID = new ParseField("category_id");
|
public static final ParseField CATEGORY_ID = new ParseField("category_id");
|
||||||
public static final ParseField FROM = new ParseField("from");
|
public static final ParseField FROM = new ParseField("from");
|
||||||
|
|
|
@ -23,7 +23,6 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.ObjectParser;
|
import org.elasticsearch.common.xcontent.ObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
@ -61,7 +60,7 @@ extends Action<GetInfluencersAction.Request, GetInfluencersAction.Response, GetI
|
||||||
return new Response();
|
return new Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Request extends ActionRequest implements ToXContent {
|
public static class Request extends ActionRequest implements ToXContentObject {
|
||||||
|
|
||||||
public static final ParseField START = new ParseField("start");
|
public static final ParseField START = new ParseField("start");
|
||||||
public static final ParseField END = new ParseField("end");
|
public static final ParseField END = new ParseField("end");
|
||||||
|
|
|
@ -23,7 +23,6 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.ObjectParser;
|
import org.elasticsearch.common.xcontent.ObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
@ -61,7 +60,7 @@ extends Action<GetModelSnapshotsAction.Request, GetModelSnapshotsAction.Response
|
||||||
return new Response();
|
return new Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Request extends ActionRequest implements ToXContent {
|
public static class Request extends ActionRequest implements ToXContentObject {
|
||||||
|
|
||||||
public static final ParseField SNAPSHOT_ID = new ParseField("snapshot_id");
|
public static final ParseField SNAPSHOT_ID = new ParseField("snapshot_id");
|
||||||
public static final ParseField SORT = new ParseField("sort");
|
public static final ParseField SORT = new ParseField("sort");
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class GetRecordsAction extends Action<GetRecordsAction.Request, GetRecord
|
||||||
return new Response();
|
return new Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Request extends ActionRequest implements ToXContent {
|
public static class Request extends ActionRequest implements ToXContentObject {
|
||||||
|
|
||||||
public static final ParseField START = new ParseField("start");
|
public static final ParseField START = new ParseField("start");
|
||||||
public static final ParseField END = new ParseField("end");
|
public static final ParseField END = new ParseField("end");
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.ObjectParser;
|
import org.elasticsearch.common.xcontent.ObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.Index;
|
||||||
|
@ -106,7 +107,7 @@ public class OpenJobAction extends Action<OpenJobAction.Request, OpenJobAction.R
|
||||||
return new Response();
|
return new Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Request extends MasterNodeRequest<Request> implements ToXContent {
|
public static class Request extends MasterNodeRequest<Request> implements ToXContentObject {
|
||||||
|
|
||||||
public static Request fromXContent(XContentParser parser) {
|
public static Request fromXContent(XContentParser parser) {
|
||||||
return parseRequest(null, parser);
|
return parseRequest(null, parser);
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class PutDatafeedAction extends Action<PutDatafeedAction.Request, PutData
|
||||||
return new Response();
|
return new Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Request extends AcknowledgedRequest<Request> implements ToXContent {
|
public static class Request extends AcknowledgedRequest<Request> implements ToXContentObject {
|
||||||
|
|
||||||
public static Request parseRequest(String datafeedId, XContentParser parser) {
|
public static Request parseRequest(String datafeedId, XContentParser parser) {
|
||||||
DatafeedConfig.Builder datafeed = DatafeedConfig.CONFIG_PARSER.apply(parser, null);
|
DatafeedConfig.Builder datafeed = DatafeedConfig.CONFIG_PARSER.apply(parser, null);
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
@ -62,7 +63,7 @@ public class PutFilterAction extends Action<PutFilterAction.Request, PutFilterAc
|
||||||
return new Response();
|
return new Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Request extends MasterNodeReadRequest<Request> implements ToXContent {
|
public static class Request extends MasterNodeReadRequest<Request> implements ToXContentObject {
|
||||||
|
|
||||||
public static Request parseRequest(String filterId, XContentParser parser) {
|
public static Request parseRequest(String filterId, XContentParser parser) {
|
||||||
MlFilter.Builder filter = MlFilter.PARSER.apply(parser, null);
|
MlFilter.Builder filter = MlFilter.PARSER.apply(parser, null);
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
@ -61,7 +60,7 @@ public class PutJobAction extends Action<PutJobAction.Request, PutJobAction.Resp
|
||||||
return new Response();
|
return new Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Request extends AcknowledgedRequest<Request> implements ToXContent {
|
public static class Request extends AcknowledgedRequest<Request> implements ToXContentObject {
|
||||||
|
|
||||||
public static Request parseRequest(String jobId, XContentParser parser) {
|
public static Request parseRequest(String jobId, XContentParser parser) {
|
||||||
Job.Builder jobBuilder = Job.CONFIG_PARSER.apply(parser, null);
|
Job.Builder jobBuilder = Job.CONFIG_PARSER.apply(parser, null);
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.ObjectParser;
|
import org.elasticsearch.common.xcontent.ObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.StatusToXContentObject;
|
import org.elasticsearch.common.xcontent.StatusToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.rest.RestStatus;
|
import org.elasticsearch.rest.RestStatus;
|
||||||
|
@ -72,7 +72,7 @@ extends Action<RevertModelSnapshotAction.Request, RevertModelSnapshotAction.Resp
|
||||||
return new Response();
|
return new Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Request extends AcknowledgedRequest<Request> implements ToXContent {
|
public static class Request extends AcknowledgedRequest<Request> implements ToXContentObject {
|
||||||
|
|
||||||
public static final ParseField SNAPSHOT_ID = new ParseField("snapshot_id");
|
public static final ParseField SNAPSHOT_ID = new ParseField("snapshot_id");
|
||||||
public static final ParseField DELETE_INTERVENING = new ParseField("delete_intervening_results");
|
public static final ParseField DELETE_INTERVENING = new ParseField("delete_intervening_results");
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.elasticsearch.common.joda.DateMathParser;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.ObjectParser;
|
import org.elasticsearch.common.xcontent.ObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.index.mapper.DateFieldMapper;
|
import org.elasticsearch.index.mapper.DateFieldMapper;
|
||||||
|
@ -96,7 +96,7 @@ public class StartDatafeedAction
|
||||||
return new Response();
|
return new Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Request extends MasterNodeRequest<Request> implements ToXContent {
|
public static class Request extends MasterNodeRequest<Request> implements ToXContentObject {
|
||||||
|
|
||||||
public static Request fromXContent(XContentParser parser) {
|
public static Request fromXContent(XContentParser parser) {
|
||||||
return parseRequest(null, parser);
|
return parseRequest(null, parser);
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.elasticsearch.common.util.concurrent.AbstractRunnable;
|
||||||
import org.elasticsearch.common.util.concurrent.AtomicArray;
|
import org.elasticsearch.common.util.concurrent.AtomicArray;
|
||||||
import org.elasticsearch.common.xcontent.ObjectParser;
|
import org.elasticsearch.common.xcontent.ObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.discovery.MasterNotDiscoveredException;
|
import org.elasticsearch.discovery.MasterNotDiscoveredException;
|
||||||
|
@ -84,7 +85,7 @@ public class StopDatafeedAction
|
||||||
return new Response();
|
return new Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Request extends BaseTasksRequest<Request> implements ToXContent {
|
public static class Request extends BaseTasksRequest<Request> implements ToXContentObject {
|
||||||
|
|
||||||
public static ObjectParser<Request, Void> PARSER = new ObjectParser<>(NAME, Request::new);
|
public static ObjectParser<Request, Void> PARSER = new ObjectParser<>(NAME, Request::new);
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
|
@ -57,7 +57,7 @@ public class UpdateDatafeedAction extends Action<UpdateDatafeedAction.Request, P
|
||||||
return new PutDatafeedAction.Response();
|
return new PutDatafeedAction.Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Request extends AcknowledgedRequest<Request> implements ToXContent {
|
public static class Request extends AcknowledgedRequest<Request> implements ToXContentObject {
|
||||||
|
|
||||||
public static Request parseRequest(String datafeedId, XContentParser parser) {
|
public static Request parseRequest(String datafeedId, XContentParser parser) {
|
||||||
DatafeedUpdate.Builder update = DatafeedUpdate.PARSER.apply(parser, null);
|
DatafeedUpdate.Builder update = DatafeedUpdate.PARSER.apply(parser, null);
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.ObjectParser;
|
import org.elasticsearch.common.xcontent.ObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.StatusToXContentObject;
|
import org.elasticsearch.common.xcontent.StatusToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
@ -67,7 +68,7 @@ public class UpdateModelSnapshotAction extends Action<UpdateModelSnapshotAction.
|
||||||
return new Response();
|
return new Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Request extends ActionRequest implements ToXContent {
|
public static class Request extends ActionRequest implements ToXContentObject {
|
||||||
|
|
||||||
private static final ObjectParser<Request, Void> PARSER = new ObjectParser<>(NAME, Request::new);
|
private static final ObjectParser<Request, Void> PARSER = new ObjectParser<>(NAME, Request::new);
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
|
@ -57,7 +57,7 @@ extends Action<ValidateDetectorAction.Request, ValidateDetectorAction.Response,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Request extends ActionRequest implements ToXContent {
|
public static class Request extends ActionRequest implements ToXContentObject {
|
||||||
|
|
||||||
private Detector detector;
|
private Detector detector;
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,11 @@ public class CloseJobActionRequestTests extends AbstractStreamableXContentTestCa
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean supportsUnknownFields() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Request createBlankInstance() {
|
protected Request createBlankInstance() {
|
||||||
return new Request();
|
return new Request();
|
||||||
|
|
|
@ -51,6 +51,11 @@ public class GetBucketActionRequestTests extends AbstractStreamableXContentTestC
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean supportsUnknownFields() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Request createBlankInstance() {
|
protected Request createBlankInstance() {
|
||||||
return new GetBucketsAction.Request();
|
return new GetBucketsAction.Request();
|
||||||
|
|
|
@ -26,6 +26,11 @@ public class GetCategoriesRequestTests extends AbstractStreamableXContentTestCas
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean supportsUnknownFields() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected GetCategoriesAction.Request createBlankInstance() {
|
protected GetCategoriesAction.Request createBlankInstance() {
|
||||||
return new GetCategoriesAction.Request();
|
return new GetCategoriesAction.Request();
|
||||||
|
|
|
@ -49,6 +49,11 @@ public class GetInfluencersActionRequestTests extends AbstractStreamableXContent
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean supportsUnknownFields() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Request createBlankInstance() {
|
protected Request createBlankInstance() {
|
||||||
return new Request();
|
return new Request();
|
||||||
|
|
|
@ -41,6 +41,11 @@ public class GetModelSnapshotsActionRequestTests extends AbstractStreamableXCont
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean supportsUnknownFields() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Request createBlankInstance() {
|
protected Request createBlankInstance() {
|
||||||
return new Request();
|
return new Request();
|
||||||
|
|
|
@ -49,6 +49,11 @@ public class GetRecordsActionRequestTests extends AbstractStreamableXContentTest
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean supportsUnknownFields() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Request createBlankInstance() {
|
protected Request createBlankInstance() {
|
||||||
return new Request();
|
return new Request();
|
||||||
|
|
|
@ -21,6 +21,11 @@ public class OpenJobActionRequestTests extends AbstractStreamableXContentTestCas
|
||||||
return new Request(params);
|
return new Request(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean supportsUnknownFields() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Request createBlankInstance() {
|
protected Request createBlankInstance() {
|
||||||
return new Request();
|
return new Request();
|
||||||
|
|
|
@ -16,7 +16,6 @@ import org.elasticsearch.xpack.ml.datafeed.DatafeedConfig;
|
||||||
import org.elasticsearch.xpack.ml.datafeed.DatafeedConfigTests;
|
import org.elasticsearch.xpack.ml.datafeed.DatafeedConfigTests;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
public class PutDatafeedActionRequestTests extends AbstractStreamableXContentTestCase<Request> {
|
public class PutDatafeedActionRequestTests extends AbstractStreamableXContentTestCase<Request> {
|
||||||
|
@ -31,11 +30,16 @@ public class PutDatafeedActionRequestTests extends AbstractStreamableXContentTes
|
||||||
@Override
|
@Override
|
||||||
protected Request createTestInstance() {
|
protected Request createTestInstance() {
|
||||||
DatafeedConfig.Builder datafeedConfig = new DatafeedConfig.Builder(datafeedId, randomAlphaOfLength(10));
|
DatafeedConfig.Builder datafeedConfig = new DatafeedConfig.Builder(datafeedId, randomAlphaOfLength(10));
|
||||||
datafeedConfig.setIndices(Arrays.asList(randomAlphaOfLength(10)));
|
datafeedConfig.setIndices(Collections.singletonList(randomAlphaOfLength(10)));
|
||||||
datafeedConfig.setTypes(Arrays.asList(randomAlphaOfLength(10)));
|
datafeedConfig.setTypes(Collections.singletonList(randomAlphaOfLength(10)));
|
||||||
return new Request(datafeedConfig.build());
|
return new Request(datafeedConfig.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean supportsUnknownFields() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Request createBlankInstance() {
|
protected Request createBlankInstance() {
|
||||||
return new Request();
|
return new Request();
|
||||||
|
|
|
@ -28,6 +28,11 @@ public class PutFilterActionRequestTests extends AbstractStreamableXContentTestC
|
||||||
return new PutFilterAction.Request(filter);
|
return new PutFilterAction.Request(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean supportsUnknownFields() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Request createBlankInstance() {
|
protected Request createBlankInstance() {
|
||||||
return new PutFilterAction.Request();
|
return new PutFilterAction.Request();
|
||||||
|
|
|
@ -5,9 +5,8 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.ml.action;
|
package org.elasticsearch.xpack.ml.action;
|
||||||
|
|
||||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.test.AbstractStreamableXContentTestCase;
|
import org.elasticsearch.test.AbstractStreamableXContentTestCase;
|
||||||
|
@ -35,6 +34,11 @@ public class PutJobActionRequestTests extends AbstractStreamableXContentTestCase
|
||||||
return new Request();
|
return new Request();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean supportsUnknownFields() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Request doParseInstance(XContentParser parser) {
|
protected Request doParseInstance(XContentParser parser) {
|
||||||
return Request.parseRequest(jobId, parser);
|
return Request.parseRequest(jobId, parser);
|
||||||
|
@ -43,10 +47,8 @@ public class PutJobActionRequestTests extends AbstractStreamableXContentTestCase
|
||||||
public void testParseRequest_InvalidCreateSetting() throws IOException {
|
public void testParseRequest_InvalidCreateSetting() throws IOException {
|
||||||
Job.Builder jobConfiguration = buildJobBuilder(jobId, null);
|
Job.Builder jobConfiguration = buildJobBuilder(jobId, null);
|
||||||
jobConfiguration.setLastDataTime(new Date());
|
jobConfiguration.setLastDataTime(new Date());
|
||||||
XContentBuilder xContentBuilder = toXContent(jobConfiguration, XContentType.JSON);
|
BytesReference bytes = XContentHelper.toXContent(jobConfiguration, XContentType.JSON, false);
|
||||||
XContentParser parser = XContentFactory.xContent(XContentType.JSON)
|
XContentParser parser = createParser(XContentType.JSON.xContent(), bytes);
|
||||||
.createParser(NamedXContentRegistry.EMPTY, xContentBuilder.bytes());
|
|
||||||
|
|
||||||
expectThrows(IllegalArgumentException.class, () -> Request.parseRequest(jobId, parser));
|
expectThrows(IllegalArgumentException.class, () -> Request.parseRequest(jobId, parser));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,11 @@ public class RevertModelSnapshotActionRequestTests extends AbstractStreamableXCo
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean supportsUnknownFields() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Request createBlankInstance() {
|
protected Request createBlankInstance() {
|
||||||
return new RevertModelSnapshotAction.Request();
|
return new RevertModelSnapshotAction.Request();
|
||||||
|
|
|
@ -28,6 +28,11 @@ public class StartDatafeedActionRequestTests extends AbstractStreamableXContentT
|
||||||
return new Request(params);
|
return new Request(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean supportsUnknownFields() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Request createBlankInstance() {
|
protected Request createBlankInstance() {
|
||||||
return new Request();
|
return new Request();
|
||||||
|
|
|
@ -41,6 +41,11 @@ public class StopDatafeedActionRequestTests extends AbstractStreamableXContentTe
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean supportsUnknownFields() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Request createBlankInstance() {
|
protected Request createBlankInstance() {
|
||||||
return new Request();
|
return new Request();
|
||||||
|
|
|
@ -32,6 +32,11 @@ public class UpdateDatafeedActionRequestTests extends AbstractStreamableXContent
|
||||||
return new Request(DatafeedUpdateTests.createRandomized(datafeedId));
|
return new Request(DatafeedUpdateTests.createRandomized(datafeedId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean supportsUnknownFields() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Request createBlankInstance() {
|
protected Request createBlankInstance() {
|
||||||
return new Request();
|
return new Request();
|
||||||
|
|
|
@ -30,6 +30,11 @@ public class UpdateModelSnapshotActionRequestTests
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean supportsUnknownFields() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Request createBlankInstance() {
|
protected Request createBlankInstance() {
|
||||||
return new Request();
|
return new Request();
|
||||||
|
|
|
@ -23,6 +23,11 @@ public class ValidateDetectorActionRequestTests extends AbstractStreamableXConte
|
||||||
return new Request(detector.build());
|
return new Request(detector.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean supportsUnknownFields() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Request createBlankInstance() {
|
protected Request createBlankInstance() {
|
||||||
return new Request();
|
return new Request();
|
||||||
|
|
|
@ -7,11 +7,12 @@ package org.elasticsearch.xpack.ml.job.config;
|
||||||
|
|
||||||
import com.carrotsearch.randomizedtesting.generators.CodepointSetGenerator;
|
import com.carrotsearch.randomizedtesting.generators.CodepointSetGenerator;
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.io.stream.Writeable;
|
import org.elasticsearch.common.io.stream.Writeable;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
|
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.test.AbstractSerializingTestCase;
|
import org.elasticsearch.test.AbstractSerializingTestCase;
|
||||||
|
@ -405,9 +406,8 @@ public class JobTests extends AbstractSerializingTestCase<Job> {
|
||||||
|
|
||||||
// Assert parsing a job without version works as expected
|
// Assert parsing a job without version works as expected
|
||||||
XContentType xContentType = randomFrom(XContentType.values());
|
XContentType xContentType = randomFrom(XContentType.values());
|
||||||
XContentBuilder xContentBuilder = toXContent(job, xContentType);
|
BytesReference bytes = XContentHelper.toXContent(job, xContentType, false);
|
||||||
|
try(XContentParser parser = createParser(xContentType.xContent(), bytes)) {
|
||||||
try(XContentParser parser = createParser(XContentFactory.xContent(xContentType), xContentBuilder.bytes())) {
|
|
||||||
Job parsed = parseInstance(parser);
|
Job parsed = parseInstance(parser);
|
||||||
assertThat(parsed, equalTo(job));
|
assertThat(parsed, equalTo(job));
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,12 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.ml.job.results;
|
package org.elasticsearch.xpack.ml.job.results;
|
||||||
|
|
||||||
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.io.stream.Writeable;
|
import org.elasticsearch.common.io.stream.Writeable;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
|
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.test.AbstractSerializingTestCase;
|
import org.elasticsearch.test.AbstractSerializingTestCase;
|
||||||
|
@ -101,8 +103,8 @@ public class AnomalyRecordTests extends AbstractSerializingTestCase<AnomalyRecor
|
||||||
Influence influence2 = new Influence("inffn", Arrays.asList("inffv1", "inffv2"));
|
Influence influence2 = new Influence("inffn", Arrays.asList("inffv1", "inffv2"));
|
||||||
record.setInfluencers(Arrays.asList(influence1, influence2));
|
record.setInfluencers(Arrays.asList(influence1, influence2));
|
||||||
|
|
||||||
XContentBuilder builder = toXContent(record, XContentType.JSON);
|
BytesReference bytes = XContentHelper.toXContent(record, XContentType.JSON, false);
|
||||||
XContentParser parser = createParser(builder);
|
XContentParser parser = createParser(XContentType.JSON.xContent(), bytes);
|
||||||
Map<String, Object> map = parser.map();
|
Map<String, Object> map = parser.map();
|
||||||
List<String> serialisedByFieldValues = (List<String>) map.get(record.getByFieldName());
|
List<String> serialisedByFieldValues = (List<String>) map.get(record.getByFieldName());
|
||||||
assertEquals(Collections.singletonList(record.getByFieldValue()), serialisedByFieldValues);
|
assertEquals(Collections.singletonList(record.getByFieldValue()), serialisedByFieldValues);
|
||||||
|
@ -133,8 +135,8 @@ public class AnomalyRecordTests extends AbstractSerializingTestCase<AnomalyRecor
|
||||||
|
|
||||||
// influencer fields with the same name as a by/over/partitiion field
|
// influencer fields with the same name as a by/over/partitiion field
|
||||||
// come second in the list
|
// come second in the list
|
||||||
XContentBuilder builder = toXContent(record, XContentType.JSON);
|
BytesReference bytes = XContentHelper.toXContent(record, XContentType.JSON, false);
|
||||||
XContentParser parser = createParser(builder);
|
XContentParser parser = createParser(XContentType.JSON.xContent(), bytes);
|
||||||
Map<String, Object> map = parser.map();
|
Map<String, Object> map = parser.map();
|
||||||
List<String> serialisedCarMakeFieldValues = (List<String>) map.get("car-make");
|
List<String> serialisedCarMakeFieldValues = (List<String>) map.get("car-make");
|
||||||
assertEquals(Arrays.asList("ford", "VW"), serialisedCarMakeFieldValues);
|
assertEquals(Arrays.asList("ford", "VW"), serialisedCarMakeFieldValues);
|
||||||
|
@ -150,8 +152,8 @@ public class AnomalyRecordTests extends AbstractSerializingTestCase<AnomalyRecor
|
||||||
record.setByFieldName(AnomalyRecord.BUCKET_SPAN.getPreferredName());
|
record.setByFieldName(AnomalyRecord.BUCKET_SPAN.getPreferredName());
|
||||||
record.setByFieldValue("bar");
|
record.setByFieldValue("bar");
|
||||||
|
|
||||||
XContentBuilder builder = toXContent(record, XContentType.JSON);
|
BytesReference bytes = XContentHelper.toXContent(record, XContentType.JSON, false);
|
||||||
XContentParser parser = createParser(builder);
|
XContentParser parser = createParser(XContentType.JSON.xContent(), bytes);
|
||||||
Object value = parser.map().get(AnomalyRecord.BUCKET_SPAN.getPreferredName());
|
Object value = parser.map().get(AnomalyRecord.BUCKET_SPAN.getPreferredName());
|
||||||
assertNotEquals("bar", value);
|
assertNotEquals("bar", value);
|
||||||
assertEquals((Long)record.getBucketSpan(), (Long)value);
|
assertEquals((Long)record.getBucketSpan(), (Long)value);
|
||||||
|
|
|
@ -5,10 +5,12 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.ml.job.results;
|
package org.elasticsearch.xpack.ml.job.results;
|
||||||
|
|
||||||
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.io.stream.Writeable.Reader;
|
import org.elasticsearch.common.io.stream.Writeable.Reader;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
|
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.test.AbstractSerializingTestCase;
|
import org.elasticsearch.test.AbstractSerializingTestCase;
|
||||||
|
@ -45,8 +47,8 @@ public class InfluencerTests extends AbstractSerializingTestCase<Influencer> {
|
||||||
|
|
||||||
public void testToXContentIncludesNameValueField() throws IOException {
|
public void testToXContentIncludesNameValueField() throws IOException {
|
||||||
Influencer influencer = createTestInstance("foo");
|
Influencer influencer = createTestInstance("foo");
|
||||||
XContentBuilder builder = toXContent(influencer, XContentType.JSON);
|
BytesReference bytes = XContentHelper.toXContent(influencer, XContentType.JSON, false);
|
||||||
XContentParser parser = createParser(builder);
|
XContentParser parser = createParser(XContentType.JSON.xContent(), bytes);
|
||||||
String serialisedFieldName = (String) parser.map().get(influencer.getInfluencerFieldName());
|
String serialisedFieldName = (String) parser.map().get(influencer.getInfluencerFieldName());
|
||||||
assertNotNull(serialisedFieldName);
|
assertNotNull(serialisedFieldName);
|
||||||
assertEquals(influencer.getInfluencerFieldValue(), serialisedFieldName);
|
assertEquals(influencer.getInfluencerFieldValue(), serialisedFieldName);
|
||||||
|
@ -54,8 +56,8 @@ public class InfluencerTests extends AbstractSerializingTestCase<Influencer> {
|
||||||
|
|
||||||
public void testToXContentDoesNotIncludeNameValueFieldWhenReservedWord() throws IOException {
|
public void testToXContentDoesNotIncludeNameValueFieldWhenReservedWord() throws IOException {
|
||||||
Influencer influencer = new Influencer("foo", Influencer.INFLUENCER_SCORE.getPreferredName(), "bar", new Date(), 300L);
|
Influencer influencer = new Influencer("foo", Influencer.INFLUENCER_SCORE.getPreferredName(), "bar", new Date(), 300L);
|
||||||
XContentBuilder builder = toXContent(influencer, XContentType.JSON);
|
BytesReference bytes = XContentHelper.toXContent(influencer, XContentType.JSON, false);
|
||||||
XContentParser parser = createParser(builder);
|
XContentParser parser = createParser(XContentType.JSON.xContent(), bytes);
|
||||||
Object serialisedFieldValue = parser.map().get(Influencer.INFLUENCER_SCORE.getPreferredName());
|
Object serialisedFieldValue = parser.map().get(Influencer.INFLUENCER_SCORE.getPreferredName());
|
||||||
assertNotNull(serialisedFieldValue);
|
assertNotNull(serialisedFieldValue);
|
||||||
assertNotEquals("bar", serialisedFieldValue);
|
assertNotEquals("bar", serialisedFieldValue);
|
||||||
|
|
|
@ -12,12 +12,12 @@ import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
import org.elasticsearch.cluster.metadata.MetaData.Custom;
|
import org.elasticsearch.cluster.metadata.MetaData.Custom;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.UUIDs;
|
import org.elasticsearch.common.UUIDs;
|
||||||
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry;
|
import org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry;
|
||||||
import org.elasticsearch.common.io.stream.Writeable;
|
import org.elasticsearch.common.io.stream.Writeable;
|
||||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
|
@ -27,8 +27,8 @@ import org.elasticsearch.xpack.persistent.PersistentTasksCustomMetaData.Assignme
|
||||||
import org.elasticsearch.xpack.persistent.PersistentTasksCustomMetaData.Builder;
|
import org.elasticsearch.xpack.persistent.PersistentTasksCustomMetaData.Builder;
|
||||||
import org.elasticsearch.xpack.persistent.PersistentTasksCustomMetaData.PersistentTask;
|
import org.elasticsearch.xpack.persistent.PersistentTasksCustomMetaData.PersistentTask;
|
||||||
import org.elasticsearch.xpack.persistent.TestPersistentTasksPlugin.Status;
|
import org.elasticsearch.xpack.persistent.TestPersistentTasksPlugin.Status;
|
||||||
import org.elasticsearch.xpack.persistent.TestPersistentTasksPlugin.TestPersistentTasksExecutor;
|
|
||||||
import org.elasticsearch.xpack.persistent.TestPersistentTasksPlugin.TestParams;
|
import org.elasticsearch.xpack.persistent.TestPersistentTasksPlugin.TestParams;
|
||||||
|
import org.elasticsearch.xpack.persistent.TestPersistentTasksPlugin.TestPersistentTasksExecutor;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -114,27 +114,13 @@ public class PersistentTasksCustomMetaDataTests extends AbstractDiffableSerializ
|
||||||
return PersistentTasksCustomMetaData.fromXContent(parser);
|
return PersistentTasksCustomMetaData.fromXContent(parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
@Override
|
@Override
|
||||||
protected XContentBuilder toXContent(Custom instance, XContentType contentType) throws IOException {
|
protected XContentBuilder toXContent(Custom instance, XContentType contentType) throws IOException {
|
||||||
return toXContent(instance, contentType, new ToXContent.MapParams(
|
return toXContent(instance, contentType, new ToXContent.MapParams(
|
||||||
Collections.singletonMap(MetaData.CONTEXT_MODE_PARAM, MetaData.XContentContext.API.toString())));
|
Collections.singletonMap(MetaData.CONTEXT_MODE_PARAM, MetaData.XContentContext.API.toString())));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
protected XContentBuilder toXContent(Custom instance, XContentType contentType, ToXContent.MapParams params) throws IOException {
|
|
||||||
// We need all attribute to be serialized/de-serialized for testing
|
|
||||||
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
|
|
||||||
if (randomBoolean()) {
|
|
||||||
builder.prettyPrint();
|
|
||||||
}
|
|
||||||
if (instance.isFragment()) {
|
|
||||||
builder.startObject();
|
|
||||||
}
|
|
||||||
instance.toXContent(builder, params);
|
|
||||||
if (instance.isFragment()) {
|
|
||||||
builder.endObject();
|
|
||||||
}
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String addRandomTask(Builder builder) {
|
private String addRandomTask(Builder builder) {
|
||||||
String taskId = UUIDs.base64UUID();
|
String taskId = UUIDs.base64UUID();
|
||||||
|
@ -166,10 +152,9 @@ public class PersistentTasksCustomMetaDataTests extends AbstractDiffableSerializ
|
||||||
Collections.singletonMap(MetaData.CONTEXT_MODE_PARAM, randomFrom(CONTEXT_MODE_SNAPSHOT, CONTEXT_MODE_GATEWAY)));
|
Collections.singletonMap(MetaData.CONTEXT_MODE_PARAM, randomFrom(CONTEXT_MODE_SNAPSHOT, CONTEXT_MODE_GATEWAY)));
|
||||||
|
|
||||||
XContentType xContentType = randomFrom(XContentType.values());
|
XContentType xContentType = randomFrom(XContentType.values());
|
||||||
XContentBuilder builder = toXContent(testInstance, xContentType, params);
|
BytesReference shuffled = toShuffledXContent(testInstance, xContentType, params, false);
|
||||||
XContentBuilder shuffled = shuffleXContent(builder);
|
|
||||||
|
|
||||||
XContentParser parser = createParser(XContentFactory.xContent(xContentType), shuffled.bytes());
|
XContentParser parser = createParser(XContentFactory.xContent(xContentType), shuffled);
|
||||||
PersistentTasksCustomMetaData newInstance = doParseInstance(parser);
|
PersistentTasksCustomMetaData newInstance = doParseInstance(parser);
|
||||||
assertNotSame(newInstance, testInstance);
|
assertNotSame(newInstance, testInstance);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue