Start centralizing XContentParser creation in tests
Original commit: elastic/x-pack-elasticsearch@65be7ecd27
This commit is contained in:
parent
c3d8fd4191
commit
d4939e1972
|
@ -6,13 +6,13 @@
|
||||||
package org.elasticsearch.xpack.common.http;
|
package org.elasticsearch.xpack.common.http;
|
||||||
|
|
||||||
import io.netty.handler.codec.http.HttpHeaders;
|
import io.netty.handler.codec.http.HttpHeaders;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
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.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.xpack.common.http.auth.HttpAuthRegistry;
|
import org.elasticsearch.xpack.common.http.auth.HttpAuthRegistry;
|
||||||
import org.elasticsearch.xpack.common.http.auth.basic.BasicAuth;
|
import org.elasticsearch.xpack.common.http.auth.basic.BasicAuth;
|
||||||
|
@ -84,7 +84,7 @@ public class HttpRequestTemplateTests extends ESTestCase {
|
||||||
HttpRequestTemplate template = builder.build();
|
HttpRequestTemplate template = builder.build();
|
||||||
|
|
||||||
XContentBuilder xContentBuilder = template.toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS);
|
XContentBuilder xContentBuilder = template.toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS);
|
||||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(xContentBuilder.bytes());
|
XContentParser xContentParser = createParser(xContentBuilder);
|
||||||
xContentParser.nextToken();
|
xContentParser.nextToken();
|
||||||
|
|
||||||
HttpRequestTemplate.Parser parser = new HttpRequestTemplate.Parser(mock(HttpAuthRegistry.class));
|
HttpRequestTemplate.Parser parser = new HttpRequestTemplate.Parser(mock(HttpAuthRegistry.class));
|
||||||
|
@ -139,7 +139,7 @@ public class HttpRequestTemplateTests extends ESTestCase {
|
||||||
HttpRequestTemplate.Parser parser = new HttpRequestTemplate.Parser(registry);
|
HttpRequestTemplate.Parser parser = new HttpRequestTemplate.Parser(registry);
|
||||||
|
|
||||||
XContentBuilder xContentBuilder = template.toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS);
|
XContentBuilder xContentBuilder = template.toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS);
|
||||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(xContentBuilder.bytes());
|
XContentParser xContentParser = createParser(xContentBuilder);
|
||||||
xContentParser.nextToken();
|
xContentParser.nextToken();
|
||||||
HttpRequestTemplate parsed = parser.parse(xContentParser);
|
HttpRequestTemplate parsed = parser.parse(xContentParser);
|
||||||
|
|
||||||
|
@ -195,14 +195,14 @@ public class HttpRequestTemplateTests extends ESTestCase {
|
||||||
|
|
||||||
private void assertThatManualBuilderEqualsParsingFromUrl(String url, HttpRequestTemplate.Builder builder) throws Exception {
|
private void assertThatManualBuilderEqualsParsingFromUrl(String url, HttpRequestTemplate.Builder builder) throws Exception {
|
||||||
XContentBuilder urlContentBuilder = jsonBuilder().startObject().field("url", url).endObject();
|
XContentBuilder urlContentBuilder = jsonBuilder().startObject().field("url", url).endObject();
|
||||||
XContentParser urlContentParser = JsonXContent.jsonXContent.createParser(urlContentBuilder.bytes());
|
XContentParser urlContentParser = createParser(urlContentBuilder);
|
||||||
urlContentParser.nextToken();
|
urlContentParser.nextToken();
|
||||||
|
|
||||||
HttpRequestTemplate.Parser parser = new HttpRequestTemplate.Parser(mock(HttpAuthRegistry.class));
|
HttpRequestTemplate.Parser parser = new HttpRequestTemplate.Parser(mock(HttpAuthRegistry.class));
|
||||||
HttpRequestTemplate urlParsedTemplate = parser.parse(urlContentParser);
|
HttpRequestTemplate urlParsedTemplate = parser.parse(urlContentParser);
|
||||||
|
|
||||||
XContentBuilder xContentBuilder = builder.build().toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS);
|
XContentBuilder xContentBuilder = builder.build().toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS);
|
||||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(xContentBuilder.bytes());
|
XContentParser xContentParser = createParser(xContentBuilder);
|
||||||
xContentParser.nextToken();
|
xContentParser.nextToken();
|
||||||
HttpRequestTemplate parsedTemplate = parser.parse(xContentParser);
|
HttpRequestTemplate parsedTemplate = parser.parse(xContentParser);
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentHelper;
|
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.xpack.common.http.auth.HttpAuthRegistry;
|
import org.elasticsearch.xpack.common.http.auth.HttpAuthRegistry;
|
||||||
import org.elasticsearch.xpack.common.http.auth.basic.BasicAuth;
|
import org.elasticsearch.xpack.common.http.auth.basic.BasicAuth;
|
||||||
|
@ -140,14 +139,14 @@ public class HttpRequestTests extends ESTestCase {
|
||||||
|
|
||||||
private void assertThatManualBuilderEqualsParsingFromUrl(String url, HttpRequest.Builder builder) throws Exception {
|
private void assertThatManualBuilderEqualsParsingFromUrl(String url, HttpRequest.Builder builder) throws Exception {
|
||||||
XContentBuilder urlContentBuilder = jsonBuilder().startObject().field("url", url).endObject();
|
XContentBuilder urlContentBuilder = jsonBuilder().startObject().field("url", url).endObject();
|
||||||
XContentParser urlContentParser = JsonXContent.jsonXContent.createParser(urlContentBuilder.bytes());
|
XContentParser urlContentParser = createParser(urlContentBuilder);
|
||||||
urlContentParser.nextToken();
|
urlContentParser.nextToken();
|
||||||
|
|
||||||
HttpRequest.Parser parser = new HttpRequest.Parser(mock(HttpAuthRegistry.class));
|
HttpRequest.Parser parser = new HttpRequest.Parser(mock(HttpAuthRegistry.class));
|
||||||
HttpRequest urlParsedRequest = parser.parse(urlContentParser);
|
HttpRequest urlParsedRequest = parser.parse(urlContentParser);
|
||||||
|
|
||||||
XContentBuilder xContentBuilder = builder.build().toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS);
|
XContentBuilder xContentBuilder = builder.build().toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS);
|
||||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(xContentBuilder.bytes());
|
XContentParser xContentParser = createParser(xContentBuilder);
|
||||||
xContentParser.nextToken();
|
xContentParser.nextToken();
|
||||||
HttpRequest parsedRequest = parser.parse(xContentParser);
|
HttpRequest parsedRequest = parser.parse(xContentParser);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.common.text;
|
package org.elasticsearch.xpack.common.text;
|
||||||
|
|
||||||
import org.elasticsearch.common.ParsingException;
|
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
@ -13,9 +12,9 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||||
import org.elasticsearch.script.CompiledScript;
|
import org.elasticsearch.script.CompiledScript;
|
||||||
import org.elasticsearch.script.ExecutableScript;
|
import org.elasticsearch.script.ExecutableScript;
|
||||||
|
import org.elasticsearch.script.Script;
|
||||||
import org.elasticsearch.script.ScriptService;
|
import org.elasticsearch.script.ScriptService;
|
||||||
import org.elasticsearch.script.ScriptType;
|
import org.elasticsearch.script.ScriptType;
|
||||||
import org.elasticsearch.script.Script;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.xpack.watcher.Watcher;
|
import org.elasticsearch.xpack.watcher.Watcher;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -115,7 +114,7 @@ public class TextTemplateTests extends ESTestCase {
|
||||||
builder.field("params", template.getParams());
|
builder.field("params", template.getParams());
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
TextTemplate parsed = TextTemplate.parse(parser);
|
TextTemplate parsed = TextTemplate.parse(parser);
|
||||||
assertThat(parsed, notNullValue());
|
assertThat(parsed, notNullValue());
|
||||||
|
@ -127,7 +126,7 @@ public class TextTemplateTests extends ESTestCase {
|
||||||
|
|
||||||
XContentBuilder builder = jsonBuilder().value(template);
|
XContentBuilder builder = jsonBuilder().value(template);
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
TextTemplate parsed = TextTemplate.parse(parser);
|
TextTemplate parsed = TextTemplate.parse(parser);
|
||||||
assertThat(parsed, notNullValue());
|
assertThat(parsed, notNullValue());
|
||||||
|
@ -139,7 +138,7 @@ public class TextTemplateTests extends ESTestCase {
|
||||||
.field("unknown_field", "value")
|
.field("unknown_field", "value")
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
try {
|
try {
|
||||||
TextTemplate.parse(parser);
|
TextTemplate.parse(parser);
|
||||||
|
@ -156,7 +155,7 @@ public class TextTemplateTests extends ESTestCase {
|
||||||
.startObject("params").endObject()
|
.startObject("params").endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
try {
|
try {
|
||||||
TextTemplate.parse(parser);
|
TextTemplate.parse(parser);
|
||||||
|
@ -172,7 +171,7 @@ public class TextTemplateTests extends ESTestCase {
|
||||||
.startObject("params").endObject()
|
.startObject("params").endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
try {
|
try {
|
||||||
TextTemplate.parse(parser);
|
TextTemplate.parse(parser);
|
||||||
|
|
|
@ -19,7 +19,6 @@ import org.elasticsearch.xpack.security.authc.support.SecuredString;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.elasticsearch.common.xcontent.support.XContentMapValues.extractValue;
|
import static org.elasticsearch.common.xcontent.support.XContentMapValues.extractValue;
|
||||||
|
@ -66,7 +65,7 @@ public class MonitoringSettingsFilterTests extends MonitoringIntegTestCase {
|
||||||
headers = new Header[0];
|
headers = new Header[0];
|
||||||
}
|
}
|
||||||
Response response = getRestClient().performRequest("GET", "/_nodes/settings", headers);
|
Response response = getRestClient().performRequest("GET", "/_nodes/settings", headers);
|
||||||
Map<String, Object> responseMap = JsonXContent.jsonXContent.createParser(response.getEntity().getContent()).map();
|
Map<String, Object> responseMap = createParser(JsonXContent.jsonXContent, response.getEntity().getContent()).map();
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Map<String, Object> nodes = (Map<String, Object>) responseMap.get("nodes");
|
Map<String, Object> nodes = (Map<String, Object>) responseMap.get("nodes");
|
||||||
for (Object node : nodes.values()) {
|
for (Object node : nodes.values()) {
|
||||||
|
|
|
@ -9,7 +9,6 @@ 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.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||||
|
@ -54,7 +53,7 @@ public class EmailTemplateTests extends ESTestCase {
|
||||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||||
emailTemplate.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
emailTemplate.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
EmailTemplate.Parser emailTemplateParser = new EmailTemplate.Parser();
|
EmailTemplate.Parser emailTemplateParser = new EmailTemplate.Parser();
|
||||||
|
|
|
@ -9,7 +9,6 @@ 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.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.DateTimeZone;
|
import org.joda.time.DateTimeZone;
|
||||||
|
@ -45,7 +44,7 @@ public class EmailTests extends ESTestCase {
|
||||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||||
email.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
email.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
Email parsedEmail = Email.parse(parser);
|
Email parsedEmail = Email.parse(parser);
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class DataAttachmentParserTests extends ESTestCase {
|
||||||
XContentBuilder builder = jsonBuilder().startObject().startObject(id)
|
XContentBuilder builder = jsonBuilder().startObject().startObject(id)
|
||||||
.startObject(DataAttachmentParser.TYPE).field("format", randomFrom("yaml", "json")).endObject()
|
.startObject(DataAttachmentParser.TYPE).field("format", randomFrom("yaml", "json")).endObject()
|
||||||
.endObject().endObject();
|
.endObject().endObject();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||||
logger.info("JSON: {}", builder.string());
|
logger.info("JSON: {}", builder.string());
|
||||||
|
|
||||||
EmailAttachments emailAttachments = emailAttachmentsParser.parse(parser);
|
EmailAttachments emailAttachments = emailAttachmentsParser.parse(parser);
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.elasticsearch.common.ParseField;
|
||||||
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.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.xpack.common.http.HttpRequestTemplate;
|
import org.elasticsearch.xpack.common.http.HttpRequestTemplate;
|
||||||
import org.elasticsearch.xpack.common.http.Scheme;
|
import org.elasticsearch.xpack.common.http.Scheme;
|
||||||
|
@ -58,7 +57,7 @@ public class EmailAttachmentParsersTests extends ESTestCase {
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
logger.info("JSON: {}", builder.string());
|
logger.info("JSON: {}", builder.string());
|
||||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser xContentParser = createParser(builder);
|
||||||
EmailAttachments attachments = parser.parse(xContentParser);
|
EmailAttachments attachments = parser.parse(xContentParser);
|
||||||
assertThat(attachments.getAttachments(), hasSize(2));
|
assertThat(attachments.getAttachments(), hasSize(2));
|
||||||
|
|
||||||
|
@ -80,7 +79,7 @@ public class EmailAttachmentParsersTests extends ESTestCase {
|
||||||
String type = randomAsciiOfLength(8);
|
String type = randomAsciiOfLength(8);
|
||||||
builder.startObject().startObject("some-id").startObject(type).endObject().endObject().endObject();
|
builder.startObject().startObject("some-id").startObject(type).endObject().endObject().endObject();
|
||||||
|
|
||||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser xContentParser = createParser(builder);
|
||||||
try {
|
try {
|
||||||
parser.parse(xContentParser);
|
parser.parse(xContentParser);
|
||||||
fail("Expected random parser of type [" + type + "] to throw an exception");
|
fail("Expected random parser of type [" + type + "] to throw an exception");
|
||||||
|
@ -130,7 +129,7 @@ public class EmailAttachmentParsersTests extends ESTestCase {
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
logger.info("JSON is: " + builder.string());
|
logger.info("JSON is: " + builder.string());
|
||||||
|
|
||||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser xContentParser = createParser(builder);
|
||||||
try {
|
try {
|
||||||
XContentParser.Token token = xContentParser.currentToken();
|
XContentParser.Token token = xContentParser.currentToken();
|
||||||
assertNull(token);
|
assertNull(token);
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.elasticsearch.common.collect.MapBuilder;
|
||||||
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.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||||
|
@ -89,7 +88,7 @@ public class HttpEmailAttachementParserTests extends ESTestCase {
|
||||||
builder.field("inline", true);
|
builder.field("inline", true);
|
||||||
}
|
}
|
||||||
builder.endObject().endObject().endObject();
|
builder.endObject().endObject().endObject();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
|
|
||||||
EmailAttachments emailAttachments = emailAttachmentsParser.parse(parser);
|
EmailAttachments emailAttachments = emailAttachmentsParser.parse(parser);
|
||||||
assertThat(emailAttachments.getAttachments(), hasSize(1));
|
assertThat(emailAttachments.getAttachments(), hasSize(1));
|
||||||
|
|
|
@ -7,6 +7,7 @@ package org.elasticsearch.xpack.notification.email.attachment;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.io.JsonEOFException;
|
import com.fasterxml.jackson.core.io.JsonEOFException;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.common.collect.MapBuilder;
|
import org.elasticsearch.common.collect.MapBuilder;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -14,7 +15,6 @@ import org.elasticsearch.common.unit.TimeValue;
|
||||||
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.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||||
import org.elasticsearch.xpack.common.http.HttpMethod;
|
import org.elasticsearch.xpack.common.http.HttpMethod;
|
||||||
|
@ -123,7 +123,7 @@ public class ReportingAttachmentParserTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.endObject().endObject().endObject();
|
builder.endObject().endObject().endObject();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
|
|
||||||
EmailAttachments emailAttachments = emailAttachmentsParser.parse(parser);
|
EmailAttachments emailAttachments = emailAttachmentsParser.parse(parser);
|
||||||
assertThat(emailAttachments.getAttachments(), hasSize(1));
|
assertThat(emailAttachments.getAttachments(), hasSize(1));
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class HipChatMessageTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
assertThat(parser.currentToken(), is(XContentParser.Token.START_OBJECT));
|
assertThat(parser.currentToken(), is(XContentParser.Token.START_OBJECT));
|
||||||
|
@ -204,7 +204,7 @@ public class HipChatMessageTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
BytesReference bytes = jsonBuilder.endObject().bytes();
|
BytesReference bytes = jsonBuilder.endObject().bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
HipChatMessage.Template template = HipChatMessage.Template.parse(parser);
|
HipChatMessage.Template template = HipChatMessage.Template.parse(parser);
|
||||||
|
@ -261,7 +261,7 @@ public class HipChatMessageTests extends ESTestCase {
|
||||||
template.toXContent(jsonBuilder, ToXContent.EMPTY_PARAMS);
|
template.toXContent(jsonBuilder, ToXContent.EMPTY_PARAMS);
|
||||||
BytesReference bytes = jsonBuilder.bytes();
|
BytesReference bytes = jsonBuilder.bytes();
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
HipChatMessage.Template parsed = HipChatMessage.Template.parse(parser);
|
HipChatMessage.Template parsed = HipChatMessage.Template.parse(parser);
|
||||||
|
|
|
@ -9,7 +9,6 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
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.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||||
|
@ -112,7 +111,7 @@ public class SlackMessageTests extends ESTestCase {
|
||||||
expected.toXContent(builder, ToXContent.EMPTY_PARAMS, includeTarget);
|
expected.toXContent(builder, ToXContent.EMPTY_PARAMS, includeTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
from = null;
|
from = null;
|
||||||
|
@ -336,7 +335,7 @@ public class SlackMessageTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
jsonBuilder.endObject();
|
jsonBuilder.endObject();
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
XContentParser parser = createParser(jsonBuilder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
assertThat(parser.currentToken(), is(XContentParser.Token.START_OBJECT));
|
assertThat(parser.currentToken(), is(XContentParser.Token.START_OBJECT));
|
||||||
|
|
||||||
|
@ -365,7 +364,7 @@ public class SlackMessageTests extends ESTestCase {
|
||||||
XContentBuilder jsonBuilder = jsonBuilder();
|
XContentBuilder jsonBuilder = jsonBuilder();
|
||||||
template.toXContent(jsonBuilder, ToXContent.EMPTY_PARAMS);
|
template.toXContent(jsonBuilder, ToXContent.EMPTY_PARAMS);
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
XContentParser parser = createParser(jsonBuilder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
SlackMessage.Template parsed = SlackMessage.Template.parse(parser);
|
SlackMessage.Template parsed = SlackMessage.Template.parse(parser);
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
package org.elasticsearch.xpack.watcher.actions.email;
|
package org.elasticsearch.xpack.watcher.actions.email;
|
||||||
|
|
||||||
import io.netty.handler.codec.http.HttpHeaders;
|
import io.netty.handler.codec.http.HttpHeaders;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.collect.MapBuilder;
|
import org.elasticsearch.common.collect.MapBuilder;
|
||||||
|
@ -287,7 +288,7 @@ public class EmailActionTests extends ESTestCase {
|
||||||
|
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
logger.info("email action json [{}]", bytes.utf8ToString());
|
logger.info("email action json [{}]", bytes.utf8ToString());
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
ExecutableEmailAction executable = new EmailActionFactory(Settings.EMPTY, emailService, engine,
|
ExecutableEmailAction executable = new EmailActionFactory(Settings.EMPTY, emailService, engine,
|
||||||
|
@ -382,7 +383,7 @@ public class EmailActionTests extends ESTestCase {
|
||||||
executable.toXContent(builder, params);
|
executable.toXContent(builder, params);
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
logger.info("{}", bytes.utf8ToString());
|
logger.info("{}", bytes.utf8ToString());
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
ExecutableEmailAction parsed = new EmailActionFactory(Settings.EMPTY, service, engine, emailAttachmentParser)
|
ExecutableEmailAction parsed = new EmailActionFactory(Settings.EMPTY, service, engine, emailAttachmentParser)
|
||||||
|
@ -412,7 +413,7 @@ public class EmailActionTests extends ESTestCase {
|
||||||
EmailAttachmentsParser emailAttachmentsParser = mock(EmailAttachmentsParser.class);
|
EmailAttachmentsParser emailAttachmentsParser = mock(EmailAttachmentsParser.class);
|
||||||
|
|
||||||
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value").endObject();
|
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value").endObject();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
try {
|
try {
|
||||||
new EmailActionFactory(Settings.EMPTY, emailService, engine, emailAttachmentsParser)
|
new EmailActionFactory(Settings.EMPTY, emailService, engine, emailAttachmentsParser)
|
||||||
|
@ -446,7 +447,7 @@ public class EmailActionTests extends ESTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
logger.info("JSON: {}", builder.string());
|
logger.info("JSON: {}", builder.string());
|
||||||
|
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
@ -481,7 +482,7 @@ public class EmailActionTests extends ESTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
logger.info("JSON: {}", builder.string());
|
logger.info("JSON: {}", builder.string());
|
||||||
|
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
@ -536,7 +537,7 @@ public class EmailActionTests extends ESTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
|
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,10 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.watcher.actions.hipchat;
|
package org.elasticsearch.xpack.watcher.actions.hipchat;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
|
||||||
import org.elasticsearch.common.settings.ClusterSettings;
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
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.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||||
import org.elasticsearch.xpack.notification.hipchat.HipChatAccount;
|
import org.elasticsearch.xpack.notification.hipchat.HipChatAccount;
|
||||||
|
@ -43,7 +41,7 @@ public class HipChatActionFactoryTests extends ESTestCase {
|
||||||
|
|
||||||
HipChatAction action = hipchatAction("_account1", "_body").build();
|
HipChatAction action = hipchatAction("_account1", "_body").build();
|
||||||
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
XContentParser parser = createParser(jsonBuilder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
ExecutableHipChatAction parsedAction = factory.parseExecutable("_w1", "_a1", parser);
|
ExecutableHipChatAction parsedAction = factory.parseExecutable("_w1", "_a1", parser);
|
||||||
|
@ -58,7 +56,7 @@ public class HipChatActionFactoryTests extends ESTestCase {
|
||||||
factory = new HipChatActionFactory(Settings.EMPTY, mock(TextTemplateEngine.class), hipchatService);
|
factory = new HipChatActionFactory(Settings.EMPTY, mock(TextTemplateEngine.class), hipchatService);
|
||||||
HipChatAction action = hipchatAction("_unknown", "_body").build();
|
HipChatAction action = hipchatAction("_unknown", "_body").build();
|
||||||
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
XContentParser parser = createParser(jsonBuilder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
expectThrows(IllegalArgumentException.class, () -> factory.parseExecutable("_w1", "_a1", parser));
|
expectThrows(IllegalArgumentException.class, () -> factory.parseExecutable("_w1", "_a1", parser));
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,7 +174,7 @@ public class HipChatActionTests extends ESTestCase {
|
||||||
|
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
logger.info("hipchat action json [{}]", bytes.utf8ToString());
|
logger.info("hipchat action json [{}]", bytes.utf8ToString());
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
HipChatAction action = HipChatAction.parse("_watch", "_action", parser);
|
HipChatAction action = HipChatAction.parse("_watch", "_action", parser);
|
||||||
|
@ -247,7 +247,7 @@ public class HipChatActionTests extends ESTestCase {
|
||||||
action.toXContent(jsonBuilder, ToXContent.EMPTY_PARAMS);
|
action.toXContent(jsonBuilder, ToXContent.EMPTY_PARAMS);
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
logger.info("{}", bytes.utf8ToString());
|
logger.info("{}", bytes.utf8ToString());
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
HipChatAction parsedAction = HipChatAction.parse("_watch", "_action", parser);
|
HipChatAction parsedAction = HipChatAction.parse("_watch", "_action", parser);
|
||||||
|
@ -258,7 +258,7 @@ public class HipChatActionTests extends ESTestCase {
|
||||||
|
|
||||||
public void testParserInvalid() throws Exception {
|
public void testParserInvalid() throws Exception {
|
||||||
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value").endObject();
|
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value").endObject();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
try {
|
try {
|
||||||
HipChatAction.parse("_watch", "_action", parser);
|
HipChatAction.parse("_watch", "_action", parser);
|
||||||
|
|
|
@ -13,7 +13,6 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
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.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.search.SearchHit;
|
import org.elasticsearch.search.SearchHit;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
|
@ -195,7 +194,7 @@ public class IndexActionTests extends ESIntegTestCase {
|
||||||
InternalClient internalClient = new InternalClient(client.settings(), client.threadPool(), client, null);
|
InternalClient internalClient = new InternalClient(client.settings(), client.threadPool(), client, null);
|
||||||
|
|
||||||
IndexActionFactory actionParser = new IndexActionFactory(Settings.EMPTY, internalClient);
|
IndexActionFactory actionParser = new IndexActionFactory(Settings.EMPTY, internalClient);
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
ExecutableIndexAction executable = actionParser.parseExecutable(randomAsciiOfLength(5), randomAsciiOfLength(3), parser);
|
ExecutableIndexAction executable = actionParser.parseExecutable(randomAsciiOfLength(5), randomAsciiOfLength(3), parser);
|
||||||
|
@ -226,7 +225,7 @@ public class IndexActionTests extends ESIntegTestCase {
|
||||||
InternalClient internalClient = new InternalClient(client.settings(), client.threadPool(), client, null);
|
InternalClient internalClient = new InternalClient(client.settings(), client.threadPool(), client, null);
|
||||||
|
|
||||||
IndexActionFactory actionParser = new IndexActionFactory(Settings.EMPTY, internalClient);
|
IndexActionFactory actionParser = new IndexActionFactory(Settings.EMPTY, internalClient);
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
try {
|
try {
|
||||||
actionParser.parseExecutable(randomAsciiOfLength(4), randomAsciiOfLength(5), parser);
|
actionParser.parseExecutable(randomAsciiOfLength(4), randomAsciiOfLength(5), parser);
|
||||||
|
|
|
@ -9,7 +9,6 @@ import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
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.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||||
import org.elasticsearch.xpack.notification.jira.JiraAccount;
|
import org.elasticsearch.xpack.notification.jira.JiraAccount;
|
||||||
|
@ -42,7 +41,7 @@ public class JiraActionFactoryTests extends ESTestCase {
|
||||||
|
|
||||||
JiraAction action = jiraAction("_account1", randomIssueDefaults()).build();
|
JiraAction action = jiraAction("_account1", randomIssueDefaults()).build();
|
||||||
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
XContentParser parser = createParser(jsonBuilder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
JiraAction parsedAction = JiraAction.parse("_w1", "_a1", parser);
|
JiraAction parsedAction = JiraAction.parse("_w1", "_a1", parser);
|
||||||
|
@ -56,7 +55,7 @@ public class JiraActionFactoryTests extends ESTestCase {
|
||||||
|
|
||||||
JiraAction action = jiraAction("_unknown", randomIssueDefaults()).build();
|
JiraAction action = jiraAction("_unknown", randomIssueDefaults()).build();
|
||||||
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
XContentParser parser = createParser(jsonBuilder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> factory.parseExecutable("_w1", "_a1", parser));
|
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> factory.parseExecutable("_w1", "_a1", parser));
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class JiraActionTests extends ESTestCase {
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
logger.info("jira action json [{}]", bytes.utf8ToString());
|
logger.info("jira action json [{}]", bytes.utf8ToString());
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
JiraAction action = JiraAction.parse("_watch", "_action", parser);
|
JiraAction action = JiraAction.parse("_watch", "_action", parser);
|
||||||
|
@ -94,7 +94,7 @@ public class JiraActionTests extends ESTestCase {
|
||||||
action.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
action.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
logger.info("{}", bytes.utf8ToString());
|
logger.info("{}", bytes.utf8ToString());
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
JiraAction parsedAction = JiraAction.parse("_watch", "_action", parser);
|
JiraAction parsedAction = JiraAction.parse("_watch", "_action", parser);
|
||||||
|
@ -108,7 +108,7 @@ public class JiraActionTests extends ESTestCase {
|
||||||
|
|
||||||
public void testParserInvalid() throws Exception {
|
public void testParserInvalid() throws Exception {
|
||||||
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value").endObject();
|
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value").endObject();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> JiraAction.parse("_w", "_a", parser));
|
ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> JiraAction.parse("_w", "_a", parser));
|
||||||
|
|
|
@ -11,7 +11,6 @@ import org.elasticsearch.common.SuppressLoggerChecks;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
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.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||||
|
@ -113,7 +112,7 @@ public class LoggingActionTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
||||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser xContentParser = createParser(builder);
|
||||||
xContentParser.nextToken();
|
xContentParser.nextToken();
|
||||||
|
|
||||||
ExecutableLoggingAction executable = parser.parseExecutable(randomAsciiOfLength(5), randomAsciiOfLength(3), xContentParser);
|
ExecutableLoggingAction executable = parser.parseExecutable(randomAsciiOfLength(5), randomAsciiOfLength(3), xContentParser);
|
||||||
|
@ -138,7 +137,7 @@ public class LoggingActionTests extends ESTestCase {
|
||||||
XContentBuilder builder = jsonBuilder();
|
XContentBuilder builder = jsonBuilder();
|
||||||
executable.toXContent(builder, Attachment.XContent.EMPTY_PARAMS);
|
executable.toXContent(builder, Attachment.XContent.EMPTY_PARAMS);
|
||||||
|
|
||||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser xContentParser = createParser(builder);
|
||||||
xContentParser.nextToken();
|
xContentParser.nextToken();
|
||||||
|
|
||||||
ExecutableLoggingAction parsedAction = parser.parseExecutable(randomAsciiOfLength(5), randomAsciiOfLength(5), xContentParser);
|
ExecutableLoggingAction parsedAction = parser.parseExecutable(randomAsciiOfLength(5), randomAsciiOfLength(5), xContentParser);
|
||||||
|
@ -162,7 +161,7 @@ public class LoggingActionTests extends ESTestCase {
|
||||||
LoggingAction action = actionBuilder.build();
|
LoggingAction action = actionBuilder.build();
|
||||||
|
|
||||||
XContentBuilder builder = jsonBuilder().value(action);
|
XContentBuilder builder = jsonBuilder().value(action);
|
||||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser xContentParser = createParser(builder);
|
||||||
|
|
||||||
assertThat(xContentParser.nextToken(), is(XContentParser.Token.START_OBJECT));
|
assertThat(xContentParser.nextToken(), is(XContentParser.Token.START_OBJECT));
|
||||||
ExecutableLoggingAction executable = parser.parseExecutable(randomAsciiOfLength(4), randomAsciiOfLength(5), xContentParser);
|
ExecutableLoggingAction executable = parser.parseExecutable(randomAsciiOfLength(4), randomAsciiOfLength(5), xContentParser);
|
||||||
|
@ -179,7 +178,7 @@ public class LoggingActionTests extends ESTestCase {
|
||||||
XContentBuilder builder = jsonBuilder()
|
XContentBuilder builder = jsonBuilder()
|
||||||
.startObject().endObject();
|
.startObject().endObject();
|
||||||
|
|
||||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser xContentParser = createParser(builder);
|
||||||
xContentParser.nextToken();
|
xContentParser.nextToken();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
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.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||||
import org.elasticsearch.xpack.notification.pagerduty.PagerDutyAccount;
|
import org.elasticsearch.xpack.notification.pagerduty.PagerDutyAccount;
|
||||||
|
@ -42,7 +41,7 @@ public class PagerDutyActionFactoryTests extends ESTestCase {
|
||||||
|
|
||||||
PagerDutyAction action = triggerPagerDutyAction("_account1", "_description").build();
|
PagerDutyAction action = triggerPagerDutyAction("_account1", "_description").build();
|
||||||
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
XContentParser parser = createParser(jsonBuilder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
PagerDutyAction parsedAction = PagerDutyAction.parse("_w1", "_a1", parser);
|
PagerDutyAction parsedAction = PagerDutyAction.parse("_w1", "_a1", parser);
|
||||||
|
@ -54,7 +53,7 @@ public class PagerDutyActionFactoryTests extends ESTestCase {
|
||||||
new ClusterSettings(Settings.EMPTY, Collections.singleton(PagerDutyService.PAGERDUTY_ACCOUNT_SETTING))));
|
new ClusterSettings(Settings.EMPTY, Collections.singleton(PagerDutyService.PAGERDUTY_ACCOUNT_SETTING))));
|
||||||
PagerDutyAction action = triggerPagerDutyAction("_unknown", "_body").build();
|
PagerDutyAction action = triggerPagerDutyAction("_unknown", "_body").build();
|
||||||
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
XContentParser parser = createParser(jsonBuilder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
expectThrows(IllegalArgumentException.class, () ->
|
expectThrows(IllegalArgumentException.class, () ->
|
||||||
factory.parseExecutable("_w1", "_a1", parser));
|
factory.parseExecutable("_w1", "_a1", parser));
|
||||||
|
|
|
@ -183,7 +183,7 @@ public class PagerDutyActionTests extends ESTestCase {
|
||||||
|
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
logger.info("pagerduty action json [{}]", bytes.utf8ToString());
|
logger.info("pagerduty action json [{}]", bytes.utf8ToString());
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
PagerDutyAction action = PagerDutyAction.parse("_watch", "_action", parser);
|
PagerDutyAction action = PagerDutyAction.parse("_watch", "_action", parser);
|
||||||
|
@ -231,7 +231,7 @@ public class PagerDutyActionTests extends ESTestCase {
|
||||||
PagerDutyAction action = pagerDutyAction(event).build();
|
PagerDutyAction action = pagerDutyAction(event).build();
|
||||||
XContentBuilder jsonBuilder = jsonBuilder();
|
XContentBuilder jsonBuilder = jsonBuilder();
|
||||||
action.toXContent(jsonBuilder, ToXContent.EMPTY_PARAMS);
|
action.toXContent(jsonBuilder, ToXContent.EMPTY_PARAMS);
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
XContentParser parser = createParser(jsonBuilder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
PagerDutyAction parsedAction = PagerDutyAction.parse("_w1", "_a1", parser);
|
PagerDutyAction parsedAction = PagerDutyAction.parse("_w1", "_a1", parser);
|
||||||
|
@ -242,7 +242,7 @@ public class PagerDutyActionTests extends ESTestCase {
|
||||||
public void testParserInvalid() throws Exception {
|
public void testParserInvalid() throws Exception {
|
||||||
try {
|
try {
|
||||||
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value").endObject();
|
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value").endObject();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
PagerDutyAction.parse("_watch", "_action", parser);
|
PagerDutyAction.parse("_watch", "_action", parser);
|
||||||
fail("Expected ElasticsearchParseException but did not happen");
|
fail("Expected ElasticsearchParseException but did not happen");
|
||||||
|
|
|
@ -5,12 +5,10 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.watcher.actions.slack;
|
package org.elasticsearch.xpack.watcher.actions.slack;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
|
||||||
import org.elasticsearch.common.settings.ClusterSettings;
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
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.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||||
import org.elasticsearch.xpack.notification.slack.SlackAccount;
|
import org.elasticsearch.xpack.notification.slack.SlackAccount;
|
||||||
|
@ -20,8 +18,8 @@ import org.junit.Before;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||||
import static org.elasticsearch.xpack.watcher.actions.ActionBuilders.slackAction;
|
|
||||||
import static org.elasticsearch.xpack.notification.slack.message.SlackMessageTests.createRandomTemplate;
|
import static org.elasticsearch.xpack.notification.slack.message.SlackMessageTests.createRandomTemplate;
|
||||||
|
import static org.elasticsearch.xpack.watcher.actions.ActionBuilders.slackAction;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
@ -42,7 +40,7 @@ public class SlackActionFactoryTests extends ESTestCase {
|
||||||
|
|
||||||
SlackAction action = slackAction("_account1", createRandomTemplate()).build();
|
SlackAction action = slackAction("_account1", createRandomTemplate()).build();
|
||||||
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
XContentParser parser = createParser(jsonBuilder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
SlackAction parsedAction = SlackAction.parse("_w1", "_a1", parser);
|
SlackAction parsedAction = SlackAction.parse("_w1", "_a1", parser);
|
||||||
|
@ -55,7 +53,7 @@ public class SlackActionFactoryTests extends ESTestCase {
|
||||||
factory = new SlackActionFactory(Settings.EMPTY, mock(TextTemplateEngine.class), service);
|
factory = new SlackActionFactory(Settings.EMPTY, mock(TextTemplateEngine.class), service);
|
||||||
SlackAction action = slackAction("_unknown", createRandomTemplate()).build();
|
SlackAction action = slackAction("_unknown", createRandomTemplate()).build();
|
||||||
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
XContentParser parser = createParser(jsonBuilder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
expectThrows(IllegalArgumentException.class, () -> factory.parseExecutable("_w1", "_a1", parser));
|
expectThrows(IllegalArgumentException.class, () -> factory.parseExecutable("_w1", "_a1", parser));
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ public class SlackActionTests extends ESTestCase {
|
||||||
|
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
logger.info("slack action json [{}]", bytes.utf8ToString());
|
logger.info("slack action json [{}]", bytes.utf8ToString());
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
SlackAction action = SlackAction.parse("_watch", "_action", parser);
|
SlackAction action = SlackAction.parse("_watch", "_action", parser);
|
||||||
|
@ -179,7 +179,7 @@ public class SlackActionTests extends ESTestCase {
|
||||||
action.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
action.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
logger.info("{}", bytes.utf8ToString());
|
logger.info("{}", bytes.utf8ToString());
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
SlackAction parsedAction = SlackAction.parse("_watch", "_action", parser);
|
SlackAction parsedAction = SlackAction.parse("_watch", "_action", parser);
|
||||||
|
@ -191,7 +191,7 @@ public class SlackActionTests extends ESTestCase {
|
||||||
|
|
||||||
public void testParserInvalid() throws Exception {
|
public void testParserInvalid() throws Exception {
|
||||||
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value").endObject();
|
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value").endObject();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
try {
|
try {
|
||||||
SlackAction.parse("_watch", "_action", parser);
|
SlackAction.parse("_watch", "_action", parser);
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
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.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.env.Environment;
|
import org.elasticsearch.env.Environment;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.test.http.MockResponse;
|
import org.elasticsearch.test.http.MockResponse;
|
||||||
|
@ -46,10 +45,11 @@ import org.hamcrest.Matchers;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
import javax.mail.internet.AddressException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.mail.internet.AddressException;
|
||||||
|
|
||||||
import static java.util.Collections.singletonMap;
|
import static java.util.Collections.singletonMap;
|
||||||
import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds;
|
import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds;
|
||||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||||
|
@ -137,7 +137,7 @@ public class WebhookActionTests extends ESTestCase {
|
||||||
|
|
||||||
WebhookActionFactory actionParser = webhookFactory(ExecuteScenario.Success.client());
|
WebhookActionFactory actionParser = webhookFactory(ExecuteScenario.Success.client());
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
ExecutableWebhookAction executable = actionParser.parseExecutable(randomAsciiOfLength(5), randomAsciiOfLength(5), parser);
|
ExecutableWebhookAction executable = actionParser.parseExecutable(randomAsciiOfLength(5), randomAsciiOfLength(5), parser);
|
||||||
|
@ -163,7 +163,7 @@ public class WebhookActionTests extends ESTestCase {
|
||||||
|
|
||||||
WebhookActionFactory actionParser = webhookFactory(ExecuteScenario.Success.client());
|
WebhookActionFactory actionParser = webhookFactory(ExecuteScenario.Success.client());
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
ExecutableWebhookAction parsedExecutable = actionParser.parseExecutable(watchId, actionId, parser);
|
ExecutableWebhookAction parsedExecutable = actionParser.parseExecutable(watchId, actionId, parser);
|
||||||
|
@ -189,7 +189,7 @@ public class WebhookActionTests extends ESTestCase {
|
||||||
|
|
||||||
WebhookActionFactory actionParser = webhookFactory(ExecuteScenario.Success.client());
|
WebhookActionFactory actionParser = webhookFactory(ExecuteScenario.Success.client());
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
assertThat(parser.nextToken(), is(XContentParser.Token.START_OBJECT));
|
assertThat(parser.nextToken(), is(XContentParser.Token.START_OBJECT));
|
||||||
ExecutableWebhookAction parsedAction = actionParser.parseExecutable(watchId, actionId, parser);
|
ExecutableWebhookAction parsedAction = actionParser.parseExecutable(watchId, actionId, parser);
|
||||||
assertThat(parsedAction.action(), is(action));
|
assertThat(parsedAction.action(), is(action));
|
||||||
|
@ -204,7 +204,7 @@ public class WebhookActionTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
WebhookActionFactory actionParser = webhookFactory(ExecuteScenario.Success.client());
|
WebhookActionFactory actionParser = webhookFactory(ExecuteScenario.Success.client());
|
||||||
|
|
|
@ -180,7 +180,7 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
ArrayCompareCondition condition = (ArrayCompareCondition) ArrayCompareCondition.parse(ClockMock.frozen(), "_id", parser);
|
ArrayCompareCondition condition = (ArrayCompareCondition) ArrayCompareCondition.parse(ClockMock.frozen(), "_id", parser);
|
||||||
|
@ -212,7 +212,7 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
expectedException.expect(ElasticsearchParseException.class);
|
expectedException.expect(ElasticsearchParseException.class);
|
||||||
|
@ -235,7 +235,7 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
expectedException.expect(ElasticsearchParseException.class);
|
expectedException.expect(ElasticsearchParseException.class);
|
||||||
|
@ -260,7 +260,7 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
expectedException.expect(ElasticsearchParseException.class);
|
expectedException.expect(ElasticsearchParseException.class);
|
||||||
|
@ -285,7 +285,7 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
expectedException.expect(ElasticsearchParseException.class);
|
expectedException.expect(ElasticsearchParseException.class);
|
||||||
|
@ -308,7 +308,7 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
expectedException.expect(ElasticsearchParseException.class);
|
expectedException.expect(ElasticsearchParseException.class);
|
||||||
|
@ -333,7 +333,7 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
expectedException.expect(ElasticsearchParseException.class);
|
expectedException.expect(ElasticsearchParseException.class);
|
||||||
|
|
|
@ -168,7 +168,7 @@ public class CompareConditionTests extends ESTestCase {
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
CompareCondition condition = (CompareCondition) CompareCondition.parse(ClockMock.frozen(), "_id", parser);
|
CompareCondition condition = (CompareCondition) CompareCondition.parse(ClockMock.frozen(), "_id", parser);
|
||||||
|
@ -186,7 +186,7 @@ public class CompareConditionTests extends ESTestCase {
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||||
try {
|
try {
|
||||||
CompareCondition.parse(ClockMock.frozen(), "_id", parser);
|
CompareCondition.parse(ClockMock.frozen(), "_id", parser);
|
||||||
fail("Expected ElasticsearchParseException");
|
fail("Expected ElasticsearchParseException");
|
||||||
|
@ -204,7 +204,7 @@ public class CompareConditionTests extends ESTestCase {
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
try {
|
try {
|
||||||
CompareCondition.parse(ClockMock.frozen(), "_id", parser);
|
CompareCondition.parse(ClockMock.frozen(), "_id", parser);
|
||||||
|
@ -224,7 +224,7 @@ public class CompareConditionTests extends ESTestCase {
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
try {
|
try {
|
||||||
CompareCondition.parse(ClockMock.frozen(), "_id", parser);
|
CompareCondition.parse(ClockMock.frozen(), "_id", parser);
|
||||||
|
|
|
@ -8,7 +8,6 @@ package org.elasticsearch.xpack.watcher.input;
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
|
||||||
import static java.util.Collections.emptyMap;
|
import static java.util.Collections.emptyMap;
|
||||||
|
@ -19,8 +18,7 @@ public class InputRegistryTests extends ESTestCase {
|
||||||
|
|
||||||
public void testParseEmptyInput() throws Exception {
|
public void testParseEmptyInput() throws Exception {
|
||||||
InputRegistry registry = new InputRegistry(Settings.EMPTY, emptyMap());
|
InputRegistry registry = new InputRegistry(Settings.EMPTY, emptyMap());
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(
|
XContentParser parser = createParser(jsonBuilder().startObject().endObject());
|
||||||
jsonBuilder().startObject().endObject().bytes());
|
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
try {
|
try {
|
||||||
registry.parse("_id", parser);
|
registry.parse("_id", parser);
|
||||||
|
@ -32,8 +30,7 @@ public class InputRegistryTests extends ESTestCase {
|
||||||
|
|
||||||
public void testParseArrayInput() throws Exception {
|
public void testParseArrayInput() throws Exception {
|
||||||
InputRegistry registry = new InputRegistry(Settings.EMPTY, emptyMap());
|
InputRegistry registry = new InputRegistry(Settings.EMPTY, emptyMap());
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(
|
XContentParser parser = createParser(jsonBuilder().startArray().endArray());
|
||||||
jsonBuilder().startArray().endArray().bytes());
|
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
try {
|
try {
|
||||||
registry.parse("_id", parser);
|
registry.parse("_id", parser);
|
||||||
|
|
|
@ -9,7 +9,6 @@ import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
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.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.xpack.watcher.input.ExecutableInput;
|
import org.elasticsearch.xpack.watcher.input.ExecutableInput;
|
||||||
import org.elasticsearch.xpack.watcher.input.Input;
|
import org.elasticsearch.xpack.watcher.input.Input;
|
||||||
|
@ -44,7 +43,7 @@ public class SimpleInputTests extends ESTestCase {
|
||||||
|
|
||||||
XContentBuilder jsonBuilder = jsonBuilder().map(data);
|
XContentBuilder jsonBuilder = jsonBuilder().map(data);
|
||||||
InputFactory parser = new SimpleInputFactory(Settings.builder().build());
|
InputFactory parser = new SimpleInputFactory(Settings.builder().build());
|
||||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
XContentParser xContentParser = createParser(jsonBuilder);
|
||||||
xContentParser.nextToken();
|
xContentParser.nextToken();
|
||||||
ExecutableInput input = parser.parseExecutable("_id", xContentParser);
|
ExecutableInput input = parser.parseExecutable("_id", xContentParser);
|
||||||
assertEquals(input.type(), SimpleInput.TYPE);
|
assertEquals(input.type(), SimpleInput.TYPE);
|
||||||
|
@ -60,7 +59,7 @@ public class SimpleInputTests extends ESTestCase {
|
||||||
XContentBuilder jsonBuilder = jsonBuilder().value("just a string");
|
XContentBuilder jsonBuilder = jsonBuilder().value("just a string");
|
||||||
|
|
||||||
InputFactory parser = new SimpleInputFactory(Settings.builder().build());
|
InputFactory parser = new SimpleInputFactory(Settings.builder().build());
|
||||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
XContentParser xContentParser = createParser(jsonBuilder);
|
||||||
xContentParser.nextToken();
|
xContentParser.nextToken();
|
||||||
try {
|
try {
|
||||||
parser.parseInput("_id", xContentParser);
|
parser.parseInput("_id", xContentParser);
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
package org.elasticsearch.xpack.watcher.test;
|
package org.elasticsearch.xpack.watcher.test;
|
||||||
|
|
||||||
import io.netty.util.internal.SystemPropertyUtil;
|
import io.netty.util.internal.SystemPropertyUtil;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.action.admin.indices.alias.Alias;
|
import org.elasticsearch.action.admin.indices.alias.Alias;
|
||||||
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
|
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
|
||||||
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse;
|
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse;
|
||||||
import org.elasticsearch.action.get.GetResponse;
|
|
||||||
import org.elasticsearch.action.search.SearchRequestBuilder;
|
import org.elasticsearch.action.search.SearchRequestBuilder;
|
||||||
import org.elasticsearch.action.search.SearchResponse;
|
import org.elasticsearch.action.search.SearchResponse;
|
||||||
import org.elasticsearch.action.support.IndicesOptions;
|
import org.elasticsearch.action.support.IndicesOptions;
|
||||||
|
@ -65,12 +65,10 @@ import org.elasticsearch.xpack.watcher.WatcherLifeCycleService;
|
||||||
import org.elasticsearch.xpack.watcher.WatcherService;
|
import org.elasticsearch.xpack.watcher.WatcherService;
|
||||||
import org.elasticsearch.xpack.watcher.WatcherState;
|
import org.elasticsearch.xpack.watcher.WatcherState;
|
||||||
import org.elasticsearch.xpack.watcher.client.WatcherClient;
|
import org.elasticsearch.xpack.watcher.client.WatcherClient;
|
||||||
import org.elasticsearch.xpack.watcher.execution.ExecutionService;
|
|
||||||
import org.elasticsearch.xpack.watcher.execution.ExecutionState;
|
import org.elasticsearch.xpack.watcher.execution.ExecutionState;
|
||||||
import org.elasticsearch.xpack.watcher.execution.TriggeredWatchStore;
|
import org.elasticsearch.xpack.watcher.execution.TriggeredWatchStore;
|
||||||
import org.elasticsearch.xpack.watcher.history.HistoryStore;
|
import org.elasticsearch.xpack.watcher.history.HistoryStore;
|
||||||
import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry;
|
import org.elasticsearch.xpack.watcher.support.WatcherIndexTemplateRegistry;
|
||||||
import org.elasticsearch.xpack.watcher.support.init.proxy.WatcherClientProxy;
|
|
||||||
import org.elasticsearch.xpack.watcher.support.xcontent.XContentSource;
|
import org.elasticsearch.xpack.watcher.support.xcontent.XContentSource;
|
||||||
import org.elasticsearch.xpack.watcher.trigger.ScheduleTriggerEngineMock;
|
import org.elasticsearch.xpack.watcher.trigger.ScheduleTriggerEngineMock;
|
||||||
import org.elasticsearch.xpack.watcher.watch.Watch;
|
import org.elasticsearch.xpack.watcher.watch.Watch;
|
||||||
|
@ -91,7 +89,6 @@ import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
@ -322,7 +319,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase
|
||||||
if (rarely()) {
|
if (rarely()) {
|
||||||
String newIndex = ".watches-alias-index";
|
String newIndex = ".watches-alias-index";
|
||||||
BytesReference bytesReference = TemplateUtils.load("/watches.json");
|
BytesReference bytesReference = TemplateUtils.load("/watches.json");
|
||||||
try (XContentParser parser = JsonXContent.jsonXContent.createParser(bytesReference.toBytesRef().bytes)) {
|
try (XContentParser parser = createParser(JsonXContent.jsonXContent, bytesReference.toBytesRef().bytes)) {
|
||||||
Map<String, Object> parserMap = parser.map();
|
Map<String, Object> parserMap = parser.map();
|
||||||
Map<String, Object> allMappings = (Map<String, Object>) parserMap.get("mappings");
|
Map<String, Object> allMappings = (Map<String, Object>) parserMap.get("mappings");
|
||||||
|
|
||||||
|
@ -340,7 +337,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase
|
||||||
if (rarely()) {
|
if (rarely()) {
|
||||||
String newIndex = ".triggered-watches-alias-index";
|
String newIndex = ".triggered-watches-alias-index";
|
||||||
BytesReference bytesReference = TemplateUtils.load("/triggered_watches.json");
|
BytesReference bytesReference = TemplateUtils.load("/triggered_watches.json");
|
||||||
try (XContentParser parser = JsonXContent.jsonXContent.createParser(bytesReference.toBytesRef().bytes)) {
|
try (XContentParser parser = createParser(JsonXContent.jsonXContent, bytesReference.toBytesRef().bytes)) {
|
||||||
Map<String, Object> parserMap = parser.map();
|
Map<String, Object> parserMap = parser.map();
|
||||||
Map<String, Object> allMappings = (Map<String, Object>) parserMap.get("mappings");
|
Map<String, Object> allMappings = (Map<String, Object>) parserMap.get("mappings");
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
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.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
||||||
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
|
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
|
||||||
import org.elasticsearch.plugins.Plugin;
|
import org.elasticsearch.plugins.Plugin;
|
||||||
|
@ -142,7 +141,7 @@ public class SearchInputTests extends ESIntegTestCase {
|
||||||
TimeValue timeout = randomBoolean() ? TimeValue.timeValueSeconds(randomInt(10)) : null;
|
TimeValue timeout = randomBoolean() ? TimeValue.timeValueSeconds(randomInt(10)) : null;
|
||||||
XContentBuilder builder = jsonBuilder().value(
|
XContentBuilder builder = jsonBuilder().value(
|
||||||
new SearchInput(WatcherTestUtils.templateRequest(source), null, timeout, null));
|
new SearchInput(WatcherTestUtils.templateRequest(source), null, timeout, null));
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
IndicesQueriesRegistry indicesQueryRegistry = internalCluster().getInstance(IndicesQueriesRegistry.class);
|
IndicesQueriesRegistry indicesQueryRegistry = internalCluster().getInstance(IndicesQueriesRegistry.class);
|
||||||
|
|
|
@ -13,7 +13,6 @@ 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.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
||||||
import org.elasticsearch.index.query.QueryBuilders;
|
import org.elasticsearch.index.query.QueryBuilders;
|
||||||
import org.elasticsearch.plugins.Plugin;
|
import org.elasticsearch.plugins.Plugin;
|
||||||
|
@ -212,7 +211,7 @@ public class SearchTransformTests extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
SearchRequestParsers searchRequestParsers = internalCluster().getInstance(SearchRequestParsers.class);
|
SearchRequestParsers searchRequestParsers = internalCluster().getInstance(SearchRequestParsers.class);
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class WatcherSettingsFilterTests extends AbstractWatcherIntegrationTestCa
|
||||||
headers = new Header[0];
|
headers = new Header[0];
|
||||||
}
|
}
|
||||||
Response response = getRestClient().performRequest("GET", "/_nodes/settings", headers);
|
Response response = getRestClient().performRequest("GET", "/_nodes/settings", headers);
|
||||||
Map<String, Object> responseMap = JsonXContent.jsonXContent.createParser(response.getEntity().getContent()).map();
|
Map<String, Object> responseMap = createParser(JsonXContent.jsonXContent, response.getEntity().getContent()).map();
|
||||||
Map<String, Object> nodes = (Map<String, Object>) responseMap.get("nodes");
|
Map<String, Object> nodes = (Map<String, Object>) responseMap.get("nodes");
|
||||||
for (Object node : nodes.values()) {
|
for (Object node : nodes.values()) {
|
||||||
Map<String, Object> settings = (Map<String, Object>) ((Map<String, Object>) node).get("settings");
|
Map<String, Object> settings = (Map<String, Object>) ((Map<String, Object>) node).get("settings");
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class ChainTransformTests extends ESTestCase {
|
||||||
.startObject().field("named", "name4").endObject()
|
.startObject().field("named", "name4").endObject()
|
||||||
.endArray();
|
.endArray();
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
ExecutableChainTransform executable = transformParser.parseExecutable("_id", parser);
|
ExecutableChainTransform executable = transformParser.parseExecutable("_id", parser);
|
||||||
assertThat(executable, notNullValue());
|
assertThat(executable, notNullValue());
|
||||||
|
|
|
@ -9,7 +9,6 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
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;
|
||||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.script.CompiledScript;
|
import org.elasticsearch.script.CompiledScript;
|
||||||
import org.elasticsearch.script.ExecutableScript;
|
import org.elasticsearch.script.ExecutableScript;
|
||||||
import org.elasticsearch.script.Script;
|
import org.elasticsearch.script.Script;
|
||||||
|
@ -147,7 +146,7 @@ public class ScriptTransformTests extends ESTestCase {
|
||||||
builder.startObject("params").field("key", "value").endObject();
|
builder.startObject("params").field("key", "value").endObject();
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
ExecutableScriptTransform transform = new ScriptTransformFactory(Settings.EMPTY, service).parseExecutable("_id", parser);
|
ExecutableScriptTransform transform = new ScriptTransformFactory(Settings.EMPTY, service).parseExecutable("_id", parser);
|
||||||
Script script = new Script(type, "_lang", "_script", singletonMap("key", "value"));
|
Script script = new Script(type, "_lang", "_script", singletonMap("key", "value"));
|
||||||
|
@ -158,7 +157,7 @@ public class ScriptTransformTests extends ESTestCase {
|
||||||
ScriptService service = mock(ScriptService.class);
|
ScriptService service = mock(ScriptService.class);
|
||||||
XContentBuilder builder = jsonBuilder().value("_script");
|
XContentBuilder builder = jsonBuilder().value("_script");
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
XContentParser parser = createParser(builder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
ExecutableScriptTransform transform = new ScriptTransformFactory(Settings.EMPTY, service).parseExecutable("_id", parser);
|
ExecutableScriptTransform transform = new ScriptTransformFactory(Settings.EMPTY, service).parseExecutable("_id", parser);
|
||||||
assertThat(transform.transform().getScript(), equalTo(new Script("_script")));
|
assertThat(transform.transform().getScript(), equalTo(new Script("_script")));
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class CronScheduleTests extends ScheduleTestCase {
|
||||||
public void testParseSingle() throws Exception {
|
public void testParseSingle() throws Exception {
|
||||||
XContentBuilder builder = jsonBuilder().value("0 0/5 * * * ?");
|
XContentBuilder builder = jsonBuilder().value("0 0/5 * * * ?");
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
CronSchedule schedule = new CronSchedule.Parser().parse(parser);
|
CronSchedule schedule = new CronSchedule.Parser().parse(parser);
|
||||||
assertThat(schedule.crons(), arrayWithSize(1));
|
assertThat(schedule.crons(), arrayWithSize(1));
|
||||||
|
@ -44,7 +44,7 @@ public class CronScheduleTests extends ScheduleTestCase {
|
||||||
"0 0/3 * * * ?"
|
"0 0/3 * * * ?"
|
||||||
});
|
});
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
CronSchedule schedule = new CronSchedule.Parser().parse(parser);
|
CronSchedule schedule = new CronSchedule.Parser().parse(parser);
|
||||||
String[] crons = expressions(schedule);
|
String[] crons = expressions(schedule);
|
||||||
|
@ -57,7 +57,7 @@ public class CronScheduleTests extends ScheduleTestCase {
|
||||||
public void testParseInvalidBadExpression() throws Exception {
|
public void testParseInvalidBadExpression() throws Exception {
|
||||||
XContentBuilder builder = jsonBuilder().value("0 0/5 * * ?");
|
XContentBuilder builder = jsonBuilder().value("0 0/5 * * ?");
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
try {
|
try {
|
||||||
new CronSchedule.Parser().parse(parser);
|
new CronSchedule.Parser().parse(parser);
|
||||||
|
@ -71,7 +71,7 @@ public class CronScheduleTests extends ScheduleTestCase {
|
||||||
public void testParseInvalidEmpty() throws Exception {
|
public void testParseInvalidEmpty() throws Exception {
|
||||||
XContentBuilder builder = jsonBuilder();
|
XContentBuilder builder = jsonBuilder();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
try {
|
try {
|
||||||
new CronSchedule.Parser().parse(parser);
|
new CronSchedule.Parser().parse(parser);
|
||||||
|
@ -85,7 +85,7 @@ public class CronScheduleTests extends ScheduleTestCase {
|
||||||
public void testParseInvalidObject() throws Exception {
|
public void testParseInvalidObject() throws Exception {
|
||||||
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
try {
|
try {
|
||||||
new CronSchedule.Parser().parse(parser);
|
new CronSchedule.Parser().parse(parser);
|
||||||
|
@ -99,7 +99,7 @@ public class CronScheduleTests extends ScheduleTestCase {
|
||||||
public void testParseInvalidEmptyArray() throws Exception {
|
public void testParseInvalidEmptyArray() throws Exception {
|
||||||
XContentBuilder builder = jsonBuilder().value(new String[0]);
|
XContentBuilder builder = jsonBuilder().value(new String[0]);
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
try {
|
try {
|
||||||
new CronSchedule.Parser().parse(parser);
|
new CronSchedule.Parser().parse(parser);
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class DailyScheduleTests extends ScheduleTestCase {
|
||||||
public void testParserEmpty() throws Exception {
|
public void testParserEmpty() throws Exception {
|
||||||
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
DailySchedule schedule = new DailySchedule.Parser().parse(parser);
|
DailySchedule schedule = new DailySchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -80,7 +80,7 @@ public class DailyScheduleTests extends ScheduleTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
DailySchedule schedule = new DailySchedule.Parser().parse(parser);
|
DailySchedule schedule = new DailySchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -98,7 +98,7 @@ public class DailyScheduleTests extends ScheduleTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
try {
|
try {
|
||||||
new DailySchedule.Parser().parse(parser);
|
new DailySchedule.Parser().parse(parser);
|
||||||
|
@ -115,7 +115,7 @@ public class DailyScheduleTests extends ScheduleTestCase {
|
||||||
.field("at", timeStr)
|
.field("at", timeStr)
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
DailySchedule schedule = new DailySchedule.Parser().parse(parser);
|
DailySchedule schedule = new DailySchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -129,7 +129,7 @@ public class DailyScheduleTests extends ScheduleTestCase {
|
||||||
.field("at", invalidDayTimeStr())
|
.field("at", invalidDayTimeStr())
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
try {
|
try {
|
||||||
new DailySchedule.Parser().parse(parser);
|
new DailySchedule.Parser().parse(parser);
|
||||||
|
@ -146,7 +146,7 @@ public class DailyScheduleTests extends ScheduleTestCase {
|
||||||
.array("at", (Object[]) times)
|
.array("at", (Object[]) times)
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
DailySchedule schedule = new DailySchedule.Parser().parse(parser);
|
DailySchedule schedule = new DailySchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -163,7 +163,7 @@ public class DailyScheduleTests extends ScheduleTestCase {
|
||||||
.array("at", (Object[]) times)
|
.array("at", (Object[]) times)
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
try {
|
try {
|
||||||
new DailySchedule.Parser().parse(parser);
|
new DailySchedule.Parser().parse(parser);
|
||||||
|
@ -180,7 +180,7 @@ public class DailyScheduleTests extends ScheduleTestCase {
|
||||||
.array("at", (Object[]) times)
|
.array("at", (Object[]) times)
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
DailySchedule schedule = new DailySchedule.Parser().parse(parser);
|
DailySchedule schedule = new DailySchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -197,7 +197,7 @@ public class DailyScheduleTests extends ScheduleTestCase {
|
||||||
.array("at", times)
|
.array("at", times)
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
try {
|
try {
|
||||||
new DailySchedule.Parser().parse(parser);
|
new DailySchedule.Parser().parse(parser);
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class HourlyScheduleTests extends ScheduleTestCase {
|
||||||
public void testParserEmpty() throws Exception {
|
public void testParserEmpty() throws Exception {
|
||||||
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
HourlySchedule schedule = new HourlySchedule.Parser().parse(parser);
|
HourlySchedule schedule = new HourlySchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -88,7 +88,7 @@ public class HourlyScheduleTests extends ScheduleTestCase {
|
||||||
.field("minute", minute)
|
.field("minute", minute)
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
HourlySchedule schedule = new HourlySchedule.Parser().parse(parser);
|
HourlySchedule schedule = new HourlySchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -102,7 +102,7 @@ public class HourlyScheduleTests extends ScheduleTestCase {
|
||||||
.field("minute", invalidMinute())
|
.field("minute", invalidMinute())
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
try {
|
try {
|
||||||
new HourlySchedule.Parser().parse(parser);
|
new HourlySchedule.Parser().parse(parser);
|
||||||
|
@ -119,7 +119,7 @@ public class HourlyScheduleTests extends ScheduleTestCase {
|
||||||
.field("minute", String.valueOf(minute))
|
.field("minute", String.valueOf(minute))
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
HourlySchedule schedule = new HourlySchedule.Parser().parse(parser);
|
HourlySchedule schedule = new HourlySchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -133,7 +133,7 @@ public class HourlyScheduleTests extends ScheduleTestCase {
|
||||||
.field("minute", String.valueOf(invalidMinute()))
|
.field("minute", String.valueOf(invalidMinute()))
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
try {
|
try {
|
||||||
new HourlySchedule.Parser().parse(parser);
|
new HourlySchedule.Parser().parse(parser);
|
||||||
|
@ -150,7 +150,7 @@ public class HourlyScheduleTests extends ScheduleTestCase {
|
||||||
.field("minute", asIterable(minutes))
|
.field("minute", asIterable(minutes))
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
HourlySchedule schedule = new HourlySchedule.Parser().parse(parser);
|
HourlySchedule schedule = new HourlySchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -167,7 +167,7 @@ public class HourlyScheduleTests extends ScheduleTestCase {
|
||||||
.field("minute", asIterable(minutes))
|
.field("minute", asIterable(minutes))
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
try {
|
try {
|
||||||
new HourlySchedule.Parser().parse(parser);
|
new HourlySchedule.Parser().parse(parser);
|
||||||
|
@ -184,7 +184,7 @@ public class HourlyScheduleTests extends ScheduleTestCase {
|
||||||
.field("minute", Arrays.stream(minutes).mapToObj(p -> Integer.toString(p)).collect(Collectors.toList()))
|
.field("minute", Arrays.stream(minutes).mapToObj(p -> Integer.toString(p)).collect(Collectors.toList()))
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
HourlySchedule schedule = new HourlySchedule.Parser().parse(parser);
|
HourlySchedule schedule = new HourlySchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -201,7 +201,7 @@ public class HourlyScheduleTests extends ScheduleTestCase {
|
||||||
.field("minute", Arrays.stream(minutes).mapToObj(p -> Integer.toString(p)).collect(Collectors.toList()))
|
.field("minute", Arrays.stream(minutes).mapToObj(p -> Integer.toString(p)).collect(Collectors.toList()))
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
try {
|
try {
|
||||||
new HourlySchedule.Parser().parse(parser);
|
new HourlySchedule.Parser().parse(parser);
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class IntervalScheduleTests extends ESTestCase {
|
||||||
long value = randomIntBetween(0, Integer.MAX_VALUE);
|
long value = randomIntBetween(0, Integer.MAX_VALUE);
|
||||||
XContentBuilder builder = jsonBuilder().value(value);
|
XContentBuilder builder = jsonBuilder().value(value);
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
IntervalSchedule schedule = new IntervalSchedule.Parser().parse(parser);
|
IntervalSchedule schedule = new IntervalSchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -34,7 +34,7 @@ public class IntervalScheduleTests extends ESTestCase {
|
||||||
long value = randomIntBetween(Integer.MIN_VALUE, 0);
|
long value = randomIntBetween(Integer.MIN_VALUE, 0);
|
||||||
XContentBuilder builder = jsonBuilder().value(value);
|
XContentBuilder builder = jsonBuilder().value(value);
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
try {
|
try {
|
||||||
new IntervalSchedule.Parser().parse(parser);
|
new IntervalSchedule.Parser().parse(parser);
|
||||||
|
@ -49,7 +49,7 @@ public class IntervalScheduleTests extends ESTestCase {
|
||||||
IntervalSchedule.Interval value = randomTimeInterval();
|
IntervalSchedule.Interval value = randomTimeInterval();
|
||||||
XContentBuilder builder = jsonBuilder().value(value);
|
XContentBuilder builder = jsonBuilder().value(value);
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
IntervalSchedule schedule = new IntervalSchedule.Parser().parse(parser);
|
IntervalSchedule schedule = new IntervalSchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -59,7 +59,7 @@ public class IntervalScheduleTests extends ESTestCase {
|
||||||
public void testParseInvalidString() throws Exception {
|
public void testParseInvalidString() throws Exception {
|
||||||
XContentBuilder builder = jsonBuilder().value("43S");
|
XContentBuilder builder = jsonBuilder().value("43S");
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
try {
|
try {
|
||||||
new IntervalSchedule.Parser().parse(parser);
|
new IntervalSchedule.Parser().parse(parser);
|
||||||
|
@ -72,7 +72,7 @@ public class IntervalScheduleTests extends ESTestCase {
|
||||||
public void testParseInvalidObject() throws Exception {
|
public void testParseInvalidObject() throws Exception {
|
||||||
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
try {
|
try {
|
||||||
new IntervalSchedule.Parser().parse(parser);
|
new IntervalSchedule.Parser().parse(parser);
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class MonthlyScheduleTests extends ScheduleTestCase {
|
||||||
public void testParserEmpty() throws Exception {
|
public void testParserEmpty() throws Exception {
|
||||||
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
MonthlySchedule schedule = new MonthlySchedule.Parser().parse(parser);
|
MonthlySchedule schedule = new MonthlySchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -86,7 +86,7 @@ public class MonthlyScheduleTests extends ScheduleTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
MonthlySchedule schedule = new MonthlySchedule.Parser().parse(parser);
|
MonthlySchedule schedule = new MonthlySchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -108,7 +108,7 @@ public class MonthlyScheduleTests extends ScheduleTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
try {
|
try {
|
||||||
new MonthlySchedule.Parser().parse(parser);
|
new MonthlySchedule.Parser().parse(parser);
|
||||||
|
@ -122,7 +122,7 @@ public class MonthlyScheduleTests extends ScheduleTestCase {
|
||||||
MonthTimes[] times = validMonthTimes();
|
MonthTimes[] times = validMonthTimes();
|
||||||
XContentBuilder builder = jsonBuilder().value(times);
|
XContentBuilder builder = jsonBuilder().value(times);
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
MonthlySchedule schedule = new MonthlySchedule.Parser().parse(parser);
|
MonthlySchedule schedule = new MonthlySchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -140,7 +140,7 @@ public class MonthlyScheduleTests extends ScheduleTestCase {
|
||||||
.array("at", (Object[]) times)
|
.array("at", (Object[]) times)
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
try {
|
try {
|
||||||
new MonthlySchedule.Parser().parse(parser);
|
new MonthlySchedule.Parser().parse(parser);
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class ScheduleRegistryTests extends ScheduleTestCase {
|
||||||
.field(IntervalSchedule.TYPE, interval)
|
.field(IntervalSchedule.TYPE, interval)
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
Schedule schedule = registry.parse("ctx", parser);
|
Schedule schedule = registry.parse("ctx", parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -60,7 +60,7 @@ public class ScheduleRegistryTests extends ScheduleTestCase {
|
||||||
.field(CronSchedule.TYPE, cron)
|
.field(CronSchedule.TYPE, cron)
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
Schedule schedule = registry.parse("ctx", parser);
|
Schedule schedule = registry.parse("ctx", parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -75,7 +75,7 @@ public class ScheduleRegistryTests extends ScheduleTestCase {
|
||||||
.field(HourlySchedule.TYPE, hourly)
|
.field(HourlySchedule.TYPE, hourly)
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
Schedule schedule = registry.parse("ctx", parser);
|
Schedule schedule = registry.parse("ctx", parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -90,7 +90,7 @@ public class ScheduleRegistryTests extends ScheduleTestCase {
|
||||||
.field(DailySchedule.TYPE, daily)
|
.field(DailySchedule.TYPE, daily)
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
Schedule schedule = registry.parse("ctx", parser);
|
Schedule schedule = registry.parse("ctx", parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -105,7 +105,7 @@ public class ScheduleRegistryTests extends ScheduleTestCase {
|
||||||
.field(WeeklySchedule.TYPE, weekly)
|
.field(WeeklySchedule.TYPE, weekly)
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
Schedule schedule = registry.parse("ctx", parser);
|
Schedule schedule = registry.parse("ctx", parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -120,7 +120,7 @@ public class ScheduleRegistryTests extends ScheduleTestCase {
|
||||||
.field(MonthlySchedule.TYPE, monthly)
|
.field(MonthlySchedule.TYPE, monthly)
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
Schedule schedule = registry.parse("ctx", parser);
|
Schedule schedule = registry.parse("ctx", parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
|
|
@ -9,7 +9,6 @@ package org.elasticsearch.xpack.watcher.trigger.schedule;
|
||||||
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;
|
||||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
|
||||||
import java.time.Clock;
|
import java.time.Clock;
|
||||||
|
@ -26,7 +25,7 @@ public class ScheduleTriggerEventTests extends ESTestCase {
|
||||||
jsonBuilder.field(ScheduleTriggerEvent.Field.TRIGGERED_TIME.getPreferredName(), triggeredTime);
|
jsonBuilder.field(ScheduleTriggerEvent.Field.TRIGGERED_TIME.getPreferredName(), triggeredTime);
|
||||||
jsonBuilder.endObject();
|
jsonBuilder.endObject();
|
||||||
|
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
XContentParser parser = createParser(jsonBuilder);
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
ScheduleTriggerEvent scheduleTriggerEvent = ScheduleTriggerEvent.parse(parser, "_id", "_context", Clock.systemUTC());
|
ScheduleTriggerEvent scheduleTriggerEvent = ScheduleTriggerEvent.parse(parser, "_id", "_context", Clock.systemUTC());
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class WeeklyScheduleTests extends ScheduleTestCase {
|
||||||
public void testParserEmpty() throws Exception {
|
public void testParserEmpty() throws Exception {
|
||||||
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
WeeklySchedule schedule = new WeeklySchedule.Parser().parse(parser);
|
WeeklySchedule schedule = new WeeklySchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -84,7 +84,7 @@ public class WeeklyScheduleTests extends ScheduleTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
WeeklySchedule schedule = new WeeklySchedule.Parser().parse(parser);
|
WeeklySchedule schedule = new WeeklySchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -106,7 +106,7 @@ public class WeeklyScheduleTests extends ScheduleTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
try {
|
try {
|
||||||
new WeeklySchedule.Parser().parse(parser);
|
new WeeklySchedule.Parser().parse(parser);
|
||||||
|
@ -120,7 +120,7 @@ public class WeeklyScheduleTests extends ScheduleTestCase {
|
||||||
WeekTimes[] times = validWeekTimes();
|
WeekTimes[] times = validWeekTimes();
|
||||||
XContentBuilder builder = jsonBuilder().value(times);
|
XContentBuilder builder = jsonBuilder().value(times);
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
WeeklySchedule schedule = new WeeklySchedule.Parser().parse(parser);
|
WeeklySchedule schedule = new WeeklySchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -138,7 +138,7 @@ public class WeeklyScheduleTests extends ScheduleTestCase {
|
||||||
.array("at", (Object[]) times)
|
.array("at", (Object[]) times)
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
try {
|
try {
|
||||||
new WeeklySchedule.Parser().parse(parser);
|
new WeeklySchedule.Parser().parse(parser);
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class YearlyScheduleTests extends ScheduleTestCase {
|
||||||
public void testParserEmpty() throws Exception {
|
public void testParserEmpty() throws Exception {
|
||||||
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
YearlySchedule schedule = new YearlySchedule.Parser().parse(parser);
|
YearlySchedule schedule = new YearlySchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -94,7 +94,7 @@ public class YearlyScheduleTests extends ScheduleTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
YearlySchedule schedule = new YearlySchedule.Parser().parse(parser);
|
YearlySchedule schedule = new YearlySchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -117,7 +117,7 @@ public class YearlyScheduleTests extends ScheduleTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
try {
|
try {
|
||||||
new MonthlySchedule.Parser().parse(parser);
|
new MonthlySchedule.Parser().parse(parser);
|
||||||
|
@ -131,7 +131,7 @@ public class YearlyScheduleTests extends ScheduleTestCase {
|
||||||
YearTimes[] times = validYearTimes();
|
YearTimes[] times = validYearTimes();
|
||||||
XContentBuilder builder = jsonBuilder().value(times);
|
XContentBuilder builder = jsonBuilder().value(times);
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
YearlySchedule schedule = new YearlySchedule.Parser().parse(parser);
|
YearlySchedule schedule = new YearlySchedule.Parser().parse(parser);
|
||||||
assertThat(schedule, notNullValue());
|
assertThat(schedule, notNullValue());
|
||||||
|
@ -150,7 +150,7 @@ public class YearlyScheduleTests extends ScheduleTestCase {
|
||||||
.array("at", (Object[]) times)
|
.array("at", (Object[]) times)
|
||||||
.endObject();
|
.endObject();
|
||||||
BytesReference bytes = builder.bytes();
|
BytesReference bytes = builder.bytes();
|
||||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||||
parser.nextToken(); // advancing to the start object
|
parser.nextToken(); // advancing to the start object
|
||||||
try {
|
try {
|
||||||
new YearlySchedule.Parser().parse(parser);
|
new YearlySchedule.Parser().parse(parser);
|
||||||
|
|
Loading…
Reference in New Issue