Merge remote-tracking branch 'origin/master' into json_strict_duplicate_checks
Original commit: elastic/x-pack-elasticsearch@af25e460d0
This commit is contained in:
commit
83240e25b4
|
@ -30,11 +30,11 @@ import java.net.InetAddress;
|
|||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static org.elasticsearch.test.ESTestCase.terminate;
|
||||
|
||||
|
@ -49,13 +49,12 @@ import static org.elasticsearch.test.ESTestCase.terminate;
|
|||
public class MockWebServer implements Closeable {
|
||||
|
||||
private HttpServer server;
|
||||
private final AtomicInteger index = new AtomicInteger(0);
|
||||
private final List<MockResponse> responses = new ArrayList<>();
|
||||
private final List<MockRequest> requests = new ArrayList<>();
|
||||
private final Queue<MockResponse> responses = ConcurrentCollections.newQueue();
|
||||
private final Queue<MockRequest> requests = ConcurrentCollections.newQueue();
|
||||
private final Logger logger;
|
||||
private final SSLContext sslContext;
|
||||
private boolean needClientAuth;
|
||||
private Set<CountDownLatch> latches = ConcurrentCollections.newConcurrentSet();
|
||||
private final boolean needClientAuth;
|
||||
private final Set<CountDownLatch> latches = ConcurrentCollections.newConcurrentSet();
|
||||
|
||||
/**
|
||||
* Instantiates a webserver without https
|
||||
|
@ -93,13 +92,16 @@ public class MockWebServer implements Closeable {
|
|||
|
||||
server.start();
|
||||
server.createContext("/", s -> {
|
||||
logger.debug("incoming HTTP request [{} {}]", s.getRequestMethod(), s.getRequestURI());
|
||||
|
||||
try {
|
||||
MockResponse response = responses.get(index.getAndAdd(1));
|
||||
MockResponse response = responses.poll();
|
||||
MockRequest request = createRequest(s);
|
||||
requests.add(request);
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("[{}:{}] incoming HTTP request [{} {}], returning status [{}] body [{}]", getHostName(), getPort(),
|
||||
s.getRequestMethod(), s.getRequestURI(), response.getStatusCode(), getStartOfBody(response));
|
||||
}
|
||||
|
||||
sleepIfNeeded(response.getBeforeReplyDelay());
|
||||
|
||||
s.getResponseHeaders().putAll(response.getHeaders().headers);
|
||||
|
@ -196,6 +198,10 @@ public class MockWebServer implements Closeable {
|
|||
* @param response The created mock response
|
||||
*/
|
||||
public void enqueue(MockResponse response) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("[{}:{}] Enqueueing response [{}], status [{}] body [{}]", getHostName(), getPort(), responses.size(),
|
||||
response.getStatusCode(), getStartOfBody(response));
|
||||
}
|
||||
responses.add(response);
|
||||
}
|
||||
|
||||
|
@ -203,15 +209,23 @@ public class MockWebServer implements Closeable {
|
|||
* @return The requests that have been made to this mock web server
|
||||
*/
|
||||
public List<MockRequest> requests() {
|
||||
return requests;
|
||||
return new ArrayList<>(requests);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the first request in the list of requests and returns it to the caller.
|
||||
* This can be used as a queue if you know the order of your requests deone.
|
||||
* This can be used as a queue if you are sure the order of your requests.
|
||||
*/
|
||||
public MockRequest takeRequest() {
|
||||
return requests.remove(0);
|
||||
return requests.poll();
|
||||
}
|
||||
|
||||
/**
|
||||
* A utility method to peek into the requests and find out if #MockWebServer.takeRequests will not throw an out of bound exception
|
||||
* @return true if more requests are available, false otherwise
|
||||
*/
|
||||
public boolean hasMoreRequests() {
|
||||
return requests.isEmpty() == false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -220,7 +234,7 @@ public class MockWebServer implements Closeable {
|
|||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
logger.debug("Counting down all latches before terminating executor");
|
||||
logger.debug("[{}:{}] Counting down all latches before terminating executor", getHostName(), getPort());
|
||||
latches.forEach(CountDownLatch::countDown);
|
||||
|
||||
if (server.getExecutor() instanceof ExecutorService) {
|
||||
|
@ -231,4 +245,17 @@ public class MockWebServer implements Closeable {
|
|||
}
|
||||
server.stop(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to return the first 20 chars of a request's body
|
||||
* @param response The MockResponse to inspect
|
||||
* @return Returns the first 20 chars or an empty string if the response body is not configured
|
||||
*/
|
||||
private String getStartOfBody(MockResponse response) {
|
||||
if (Strings.isEmpty(response.getBody())) {
|
||||
return "";
|
||||
}
|
||||
int length = Math.min(20, response.getBody().length());
|
||||
return response.getBody().substring(0, length).replaceAll("\n", "");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
package org.elasticsearch.xpack.common.http;
|
||||
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.common.http.auth.HttpAuthRegistry;
|
||||
import org.elasticsearch.xpack.common.http.auth.basic.BasicAuth;
|
||||
|
@ -84,7 +84,7 @@ public class HttpRequestTemplateTests extends ESTestCase {
|
|||
HttpRequestTemplate template = builder.build();
|
||||
|
||||
XContentBuilder xContentBuilder = template.toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS);
|
||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(xContentBuilder.bytes());
|
||||
XContentParser xContentParser = createParser(xContentBuilder);
|
||||
xContentParser.nextToken();
|
||||
|
||||
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);
|
||||
|
||||
XContentBuilder xContentBuilder = template.toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS);
|
||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(xContentBuilder.bytes());
|
||||
XContentParser xContentParser = createParser(xContentBuilder);
|
||||
xContentParser.nextToken();
|
||||
HttpRequestTemplate parsed = parser.parse(xContentParser);
|
||||
|
||||
|
@ -195,14 +195,14 @@ public class HttpRequestTemplateTests extends ESTestCase {
|
|||
|
||||
private void assertThatManualBuilderEqualsParsingFromUrl(String url, HttpRequestTemplate.Builder builder) throws Exception {
|
||||
XContentBuilder urlContentBuilder = jsonBuilder().startObject().field("url", url).endObject();
|
||||
XContentParser urlContentParser = JsonXContent.jsonXContent.createParser(urlContentBuilder.bytes());
|
||||
XContentParser urlContentParser = createParser(urlContentBuilder);
|
||||
urlContentParser.nextToken();
|
||||
|
||||
HttpRequestTemplate.Parser parser = new HttpRequestTemplate.Parser(mock(HttpAuthRegistry.class));
|
||||
HttpRequestTemplate urlParsedTemplate = parser.parse(urlContentParser);
|
||||
|
||||
XContentBuilder xContentBuilder = builder.build().toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS);
|
||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(xContentBuilder.bytes());
|
||||
XContentParser xContentParser = createParser(xContentBuilder);
|
||||
xContentParser.nextToken();
|
||||
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.XContentHelper;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.common.http.auth.HttpAuthRegistry;
|
||||
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 {
|
||||
XContentBuilder urlContentBuilder = jsonBuilder().startObject().field("url", url).endObject();
|
||||
XContentParser urlContentParser = JsonXContent.jsonXContent.createParser(urlContentBuilder.bytes());
|
||||
XContentParser urlContentParser = createParser(urlContentBuilder);
|
||||
urlContentParser.nextToken();
|
||||
|
||||
HttpRequest.Parser parser = new HttpRequest.Parser(mock(HttpAuthRegistry.class));
|
||||
HttpRequest urlParsedRequest = parser.parse(urlContentParser);
|
||||
|
||||
XContentBuilder xContentBuilder = builder.build().toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS);
|
||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(xContentBuilder.bytes());
|
||||
XContentParser xContentParser = createParser(xContentBuilder);
|
||||
xContentParser.nextToken();
|
||||
HttpRequest parsedRequest = parser.parse(xContentParser);
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.common.text;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
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.script.CompiledScript;
|
||||
import org.elasticsearch.script.ExecutableScript;
|
||||
import org.elasticsearch.script.Script;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.script.ScriptType;
|
||||
import org.elasticsearch.script.Script;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.Watcher;
|
||||
import org.junit.Before;
|
||||
|
@ -115,7 +114,7 @@ public class TextTemplateTests extends ESTestCase {
|
|||
builder.field("params", template.getParams());
|
||||
builder.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
TextTemplate parsed = TextTemplate.parse(parser);
|
||||
assertThat(parsed, notNullValue());
|
||||
|
@ -127,7 +126,7 @@ public class TextTemplateTests extends ESTestCase {
|
|||
|
||||
XContentBuilder builder = jsonBuilder().value(template);
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
TextTemplate parsed = TextTemplate.parse(parser);
|
||||
assertThat(parsed, notNullValue());
|
||||
|
@ -139,7 +138,7 @@ public class TextTemplateTests extends ESTestCase {
|
|||
.field("unknown_field", "value")
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
try {
|
||||
TextTemplate.parse(parser);
|
||||
|
@ -156,7 +155,7 @@ public class TextTemplateTests extends ESTestCase {
|
|||
.startObject("params").endObject()
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
try {
|
||||
TextTemplate.parse(parser);
|
||||
|
@ -172,7 +171,7 @@ public class TextTemplateTests extends ESTestCase {
|
|||
.startObject("params").endObject()
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
try {
|
||||
TextTemplate.parse(parser);
|
||||
|
|
|
@ -58,7 +58,12 @@ public class ListXPackExtensionCommandTests extends ESTestCase {
|
|||
|
||||
static MockTerminal listExtensions(Path home) throws Exception {
|
||||
MockTerminal terminal = new MockTerminal();
|
||||
int status = new ListXPackExtensionCommand().main(new String[] { "-Epath.home=" + home }, terminal);
|
||||
int status = new ListXPackExtensionCommand() {
|
||||
@Override
|
||||
protected boolean addShutdownHook() {
|
||||
return false;
|
||||
}
|
||||
}.main(new String[] { "-Epath.home=" + home }, terminal);
|
||||
assertEquals(ExitCodes.OK, status);
|
||||
return terminal;
|
||||
}
|
||||
|
@ -68,7 +73,12 @@ public class ListXPackExtensionCommandTests extends ESTestCase {
|
|||
System.arraycopy(args, 0, argsAndHome, 0, args.length);
|
||||
argsAndHome[args.length] = "-Epath.home=" + home;
|
||||
MockTerminal terminal = new MockTerminal();
|
||||
int status = new ListXPackExtensionCommand().main(argsAndHome, terminal);
|
||||
int status = new ListXPackExtensionCommand() {
|
||||
@Override
|
||||
protected boolean addShutdownHook() {
|
||||
return false;
|
||||
}
|
||||
}.main(argsAndHome, terminal);
|
||||
assertEquals(ExitCodes.OK, status);
|
||||
return terminal;
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ import static org.hamcrest.Matchers.containsString;
|
|||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
|
||||
|
@ -229,10 +230,10 @@ public class HttpExporterIT extends MonitoringIntegTestCase {
|
|||
// pretend that one of the templates is missing
|
||||
for (Tuple<String, String> template : monitoringTemplates()) {
|
||||
if (template.v1().contains(MonitoringBulkTimestampedResolver.Data.DATA)) {
|
||||
enqueueResponse(secondWebServer, 200, "template [" + template + "] exists");
|
||||
enqueueResponse(secondWebServer, 200, "template [" + template.v1() + "] exists");
|
||||
} else {
|
||||
enqueueResponse(secondWebServer, 404, "template [" + template + "] does not exist");
|
||||
enqueueResponse(secondWebServer, 201, "template [" + template + "] created");
|
||||
enqueueResponse(secondWebServer, 404, "template [" + template.v1() + "] does not exist");
|
||||
enqueueResponse(secondWebServer, 201, "template [" + template.v1() + "] created");
|
||||
}
|
||||
}
|
||||
// opposite of if it existed before
|
||||
|
@ -450,6 +451,8 @@ public class HttpExporterIT extends MonitoringIntegTestCase {
|
|||
@Nullable final Map<String, String[]> customHeaders, @Nullable final String basePath)
|
||||
throws Exception {
|
||||
final String pathPrefix = basePathToAssertablePrefix(basePath);
|
||||
// the bulk request is fired off asynchronously so we might need to take a while, until we can get the request from the webserver
|
||||
assertBusy(() -> assertThat("Waiting for further requests in web server", webServer.hasMoreRequests(), is(true)));
|
||||
final MockRequest request = webServer.takeRequest();
|
||||
|
||||
assertThat(request.getMethod(), equalTo("POST"));
|
||||
|
|
|
@ -19,7 +19,6 @@ import org.elasticsearch.xpack.security.authc.support.SecuredString;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.common.xcontent.support.XContentMapValues.extractValue;
|
||||
|
@ -66,7 +65,7 @@ public class MonitoringSettingsFilterTests extends MonitoringIntegTestCase {
|
|||
headers = new Header[0];
|
||||
}
|
||||
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")
|
||||
Map<String, Object> nodes = (Map<String, Object>) responseMap.get("nodes");
|
||||
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.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
|
@ -54,7 +53,7 @@ public class EmailTemplateTests extends ESTestCase {
|
|||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
emailTemplate.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
parser.nextToken();
|
||||
|
||||
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.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
|
@ -45,7 +44,7 @@ public class EmailTests extends ESTestCase {
|
|||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
email.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
parser.nextToken();
|
||||
|
||||
Email parsedEmail = Email.parse(parser);
|
||||
|
|
|
@ -31,7 +31,7 @@ public class DataAttachmentParserTests extends ESTestCase {
|
|||
XContentBuilder builder = jsonBuilder().startObject().startObject(id)
|
||||
.startObject(DataAttachmentParser.TYPE).field("format", randomFrom("yaml", "json")).endObject()
|
||||
.endObject().endObject();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||
logger.info("JSON: {}", builder.string());
|
||||
|
||||
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.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequestTemplate;
|
||||
import org.elasticsearch.xpack.common.http.Scheme;
|
||||
|
@ -58,7 +57,7 @@ public class EmailAttachmentParsersTests extends ESTestCase {
|
|||
.endObject();
|
||||
|
||||
logger.info("JSON: {}", builder.string());
|
||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser xContentParser = createParser(builder);
|
||||
EmailAttachments attachments = parser.parse(xContentParser);
|
||||
assertThat(attachments.getAttachments(), hasSize(2));
|
||||
|
||||
|
@ -80,7 +79,7 @@ public class EmailAttachmentParsersTests extends ESTestCase {
|
|||
String type = randomAsciiOfLength(8);
|
||||
builder.startObject().startObject("some-id").startObject(type).endObject().endObject().endObject();
|
||||
|
||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser xContentParser = createParser(builder);
|
||||
try {
|
||||
parser.parse(xContentParser);
|
||||
fail("Expected random parser of type [" + type + "] to throw an exception");
|
||||
|
@ -132,7 +131,7 @@ public class EmailAttachmentParsersTests extends ESTestCase {
|
|||
builder.endObject();
|
||||
logger.info("JSON is: " + builder.string());
|
||||
|
||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser xContentParser = createParser(builder);
|
||||
try {
|
||||
XContentParser.Token token = xContentParser.currentToken();
|
||||
assertNull(token);
|
||||
|
|
|
@ -10,7 +10,6 @@ import org.elasticsearch.common.collect.MapBuilder;
|
|||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||
|
@ -89,7 +88,7 @@ public class HttpEmailAttachementParserTests extends ESTestCase {
|
|||
builder.field("inline", true);
|
||||
}
|
||||
builder.endObject().endObject().endObject();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
|
||||
EmailAttachments emailAttachments = emailAttachmentsParser.parse(parser);
|
||||
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.google.common.collect.Maps;
|
||||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.common.collect.MapBuilder;
|
||||
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.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
import org.elasticsearch.xpack.common.http.HttpMethod;
|
||||
|
@ -123,7 +123,7 @@ public class ReportingAttachmentParserTests extends ESTestCase {
|
|||
}
|
||||
|
||||
builder.endObject().endObject().endObject();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
|
||||
EmailAttachments emailAttachments = emailAttachmentsParser.parse(parser);
|
||||
assertThat(emailAttachments.getAttachments(), hasSize(1));
|
||||
|
|
|
@ -45,7 +45,7 @@ public class HipChatMessageTests extends ESTestCase {
|
|||
}
|
||||
BytesReference bytes = builder.bytes();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
|
||||
assertThat(parser.currentToken(), is(XContentParser.Token.START_OBJECT));
|
||||
|
@ -204,7 +204,7 @@ public class HipChatMessageTests extends ESTestCase {
|
|||
}
|
||||
|
||||
BytesReference bytes = jsonBuilder.endObject().bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
|
||||
HipChatMessage.Template template = HipChatMessage.Template.parse(parser);
|
||||
|
@ -261,7 +261,7 @@ public class HipChatMessageTests extends ESTestCase {
|
|||
template.toXContent(jsonBuilder, ToXContent.EMPTY_PARAMS);
|
||||
BytesReference bytes = jsonBuilder.bytes();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
|
||||
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.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
|
@ -112,7 +111,7 @@ public class SlackMessageTests extends ESTestCase {
|
|||
expected.toXContent(builder, ToXContent.EMPTY_PARAMS, includeTarget);
|
||||
}
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
parser.nextToken();
|
||||
|
||||
from = null;
|
||||
|
@ -336,7 +335,7 @@ public class SlackMessageTests extends ESTestCase {
|
|||
}
|
||||
jsonBuilder.endObject();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
||||
XContentParser parser = createParser(jsonBuilder);
|
||||
parser.nextToken();
|
||||
assertThat(parser.currentToken(), is(XContentParser.Token.START_OBJECT));
|
||||
|
||||
|
@ -365,7 +364,7 @@ public class SlackMessageTests extends ESTestCase {
|
|||
XContentBuilder jsonBuilder = jsonBuilder();
|
||||
template.toXContent(jsonBuilder, ToXContent.EMPTY_PARAMS);
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
||||
XContentParser parser = createParser(jsonBuilder);
|
||||
parser.nextToken();
|
||||
|
||||
SlackMessage.Template parsed = SlackMessage.Template.parse(parser);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
package org.elasticsearch.xpack.watcher.actions.email;
|
||||
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.collect.MapBuilder;
|
||||
|
@ -285,7 +286,7 @@ public class EmailActionTests extends ESTestCase {
|
|||
|
||||
BytesReference bytes = builder.bytes();
|
||||
logger.info("email action json [{}]", bytes.utf8ToString());
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
|
||||
ExecutableEmailAction executable = new EmailActionFactory(Settings.EMPTY, emailService, engine,
|
||||
|
@ -380,7 +381,7 @@ public class EmailActionTests extends ESTestCase {
|
|||
executable.toXContent(builder, params);
|
||||
BytesReference bytes = builder.bytes();
|
||||
logger.info("{}", bytes.utf8ToString());
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
|
||||
ExecutableEmailAction parsed = new EmailActionFactory(Settings.EMPTY, service, engine, emailAttachmentParser)
|
||||
|
@ -410,7 +411,7 @@ public class EmailActionTests extends ESTestCase {
|
|||
EmailAttachmentsParser emailAttachmentsParser = mock(EmailAttachmentsParser.class);
|
||||
|
||||
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value").endObject();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
parser.nextToken();
|
||||
try {
|
||||
new EmailActionFactory(Settings.EMPTY, emailService, engine, emailAttachmentsParser)
|
||||
|
@ -444,7 +445,7 @@ public class EmailActionTests extends ESTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
logger.info("JSON: {}", builder.string());
|
||||
|
||||
parser.nextToken();
|
||||
|
@ -479,7 +480,7 @@ public class EmailActionTests extends ESTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
logger.info("JSON: {}", builder.string());
|
||||
|
||||
parser.nextToken();
|
||||
|
@ -534,7 +535,7 @@ public class EmailActionTests extends ESTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
|
||||
parser.nextToken();
|
||||
|
||||
|
|
|
@ -5,12 +5,10 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.watcher.actions.hipchat;
|
||||
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.notification.hipchat.HipChatAccount;
|
||||
|
@ -43,7 +41,7 @@ public class HipChatActionFactoryTests extends ESTestCase {
|
|||
|
||||
HipChatAction action = hipchatAction("_account1", "_body").build();
|
||||
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
||||
XContentParser parser = createParser(jsonBuilder);
|
||||
parser.nextToken();
|
||||
|
||||
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);
|
||||
HipChatAction action = hipchatAction("_unknown", "_body").build();
|
||||
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
||||
XContentParser parser = createParser(jsonBuilder);
|
||||
parser.nextToken();
|
||||
expectThrows(IllegalArgumentException.class, () -> factory.parseExecutable("_w1", "_a1", parser));
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ public class HipChatActionTests extends ESTestCase {
|
|||
|
||||
BytesReference bytes = builder.bytes();
|
||||
logger.info("hipchat action json [{}]", bytes.utf8ToString());
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
|
||||
HipChatAction action = HipChatAction.parse("_watch", "_action", parser);
|
||||
|
@ -247,7 +247,7 @@ public class HipChatActionTests extends ESTestCase {
|
|||
action.toXContent(jsonBuilder, ToXContent.EMPTY_PARAMS);
|
||||
BytesReference bytes = builder.bytes();
|
||||
logger.info("{}", bytes.utf8ToString());
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
|
||||
HipChatAction parsedAction = HipChatAction.parse("_watch", "_action", parser);
|
||||
|
@ -258,7 +258,7 @@ public class HipChatActionTests extends ESTestCase {
|
|||
|
||||
public void testParserInvalid() throws Exception {
|
||||
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value").endObject();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
parser.nextToken();
|
||||
try {
|
||||
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.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||
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);
|
||||
|
||||
IndexActionFactory actionParser = new IndexActionFactory(Settings.EMPTY, internalClient);
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
parser.nextToken();
|
||||
|
||||
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);
|
||||
|
||||
IndexActionFactory actionParser = new IndexActionFactory(Settings.EMPTY, internalClient);
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
parser.nextToken();
|
||||
try {
|
||||
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.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.notification.jira.JiraAccount;
|
||||
|
@ -42,7 +41,7 @@ public class JiraActionFactoryTests extends ESTestCase {
|
|||
|
||||
JiraAction action = jiraAction("_account1", randomIssueDefaults()).build();
|
||||
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
||||
XContentParser parser = createParser(jsonBuilder);
|
||||
parser.nextToken();
|
||||
|
||||
JiraAction parsedAction = JiraAction.parse("_w1", "_a1", parser);
|
||||
|
@ -56,7 +55,7 @@ public class JiraActionFactoryTests extends ESTestCase {
|
|||
|
||||
JiraAction action = jiraAction("_unknown", randomIssueDefaults()).build();
|
||||
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
||||
XContentParser parser = createParser(jsonBuilder);
|
||||
parser.nextToken();
|
||||
|
||||
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> factory.parseExecutable("_w1", "_a1", parser));
|
||||
|
|
|
@ -76,7 +76,7 @@ public class JiraActionTests extends ESTestCase {
|
|||
BytesReference bytes = builder.bytes();
|
||||
logger.info("jira action json [{}]", bytes.utf8ToString());
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
|
||||
JiraAction action = JiraAction.parse("_watch", "_action", parser);
|
||||
|
@ -94,7 +94,7 @@ public class JiraActionTests extends ESTestCase {
|
|||
action.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
BytesReference bytes = builder.bytes();
|
||||
logger.info("{}", bytes.utf8ToString());
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
|
||||
JiraAction parsedAction = JiraAction.parse("_watch", "_action", parser);
|
||||
|
@ -108,7 +108,7 @@ public class JiraActionTests extends ESTestCase {
|
|||
|
||||
public void testParserInvalid() throws Exception {
|
||||
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value").endObject();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
parser.nextToken();
|
||||
|
||||
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.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
|
@ -113,7 +112,7 @@ public class LoggingActionTests extends ESTestCase {
|
|||
}
|
||||
builder.endObject();
|
||||
|
||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser xContentParser = createParser(builder);
|
||||
xContentParser.nextToken();
|
||||
|
||||
ExecutableLoggingAction executable = parser.parseExecutable(randomAsciiOfLength(5), randomAsciiOfLength(3), xContentParser);
|
||||
|
@ -138,7 +137,7 @@ public class LoggingActionTests extends ESTestCase {
|
|||
XContentBuilder builder = jsonBuilder();
|
||||
executable.toXContent(builder, Attachment.XContent.EMPTY_PARAMS);
|
||||
|
||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser xContentParser = createParser(builder);
|
||||
xContentParser.nextToken();
|
||||
|
||||
ExecutableLoggingAction parsedAction = parser.parseExecutable(randomAsciiOfLength(5), randomAsciiOfLength(5), xContentParser);
|
||||
|
@ -162,7 +161,7 @@ public class LoggingActionTests extends ESTestCase {
|
|||
LoggingAction action = actionBuilder.build();
|
||||
|
||||
XContentBuilder builder = jsonBuilder().value(action);
|
||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser xContentParser = createParser(builder);
|
||||
|
||||
assertThat(xContentParser.nextToken(), is(XContentParser.Token.START_OBJECT));
|
||||
ExecutableLoggingAction executable = parser.parseExecutable(randomAsciiOfLength(4), randomAsciiOfLength(5), xContentParser);
|
||||
|
@ -179,7 +178,7 @@ public class LoggingActionTests extends ESTestCase {
|
|||
XContentBuilder builder = jsonBuilder()
|
||||
.startObject().endObject();
|
||||
|
||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser xContentParser = createParser(builder);
|
||||
xContentParser.nextToken();
|
||||
|
||||
try {
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.elasticsearch.common.settings.ClusterSettings;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.notification.pagerduty.PagerDutyAccount;
|
||||
|
@ -42,7 +41,7 @@ public class PagerDutyActionFactoryTests extends ESTestCase {
|
|||
|
||||
PagerDutyAction action = triggerPagerDutyAction("_account1", "_description").build();
|
||||
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
||||
XContentParser parser = createParser(jsonBuilder);
|
||||
parser.nextToken();
|
||||
|
||||
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))));
|
||||
PagerDutyAction action = triggerPagerDutyAction("_unknown", "_body").build();
|
||||
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
||||
XContentParser parser = createParser(jsonBuilder);
|
||||
parser.nextToken();
|
||||
expectThrows(IllegalArgumentException.class, () ->
|
||||
factory.parseExecutable("_w1", "_a1", parser));
|
||||
|
|
|
@ -183,7 +183,7 @@ public class PagerDutyActionTests extends ESTestCase {
|
|||
|
||||
BytesReference bytes = builder.bytes();
|
||||
logger.info("pagerduty action json [{}]", bytes.utf8ToString());
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
|
||||
PagerDutyAction action = PagerDutyAction.parse("_watch", "_action", parser);
|
||||
|
@ -231,7 +231,7 @@ public class PagerDutyActionTests extends ESTestCase {
|
|||
PagerDutyAction action = pagerDutyAction(event).build();
|
||||
XContentBuilder jsonBuilder = jsonBuilder();
|
||||
action.toXContent(jsonBuilder, ToXContent.EMPTY_PARAMS);
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
||||
XContentParser parser = createParser(jsonBuilder);
|
||||
parser.nextToken();
|
||||
|
||||
PagerDutyAction parsedAction = PagerDutyAction.parse("_w1", "_a1", parser);
|
||||
|
@ -242,7 +242,7 @@ public class PagerDutyActionTests extends ESTestCase {
|
|||
public void testParserInvalid() throws Exception {
|
||||
try {
|
||||
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value").endObject();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
parser.nextToken();
|
||||
PagerDutyAction.parse("_watch", "_action", parser);
|
||||
fail("Expected ElasticsearchParseException but did not happen");
|
||||
|
|
|
@ -5,12 +5,10 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.watcher.actions.slack;
|
||||
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.common.text.TextTemplateEngine;
|
||||
import org.elasticsearch.xpack.notification.slack.SlackAccount;
|
||||
|
@ -20,8 +18,8 @@ import org.junit.Before;
|
|||
import java.util.Collections;
|
||||
|
||||
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.watcher.actions.ActionBuilders.slackAction;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
@ -42,7 +40,7 @@ public class SlackActionFactoryTests extends ESTestCase {
|
|||
|
||||
SlackAction action = slackAction("_account1", createRandomTemplate()).build();
|
||||
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
||||
XContentParser parser = createParser(jsonBuilder);
|
||||
parser.nextToken();
|
||||
|
||||
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);
|
||||
SlackAction action = slackAction("_unknown", createRandomTemplate()).build();
|
||||
XContentBuilder jsonBuilder = jsonBuilder().value(action);
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
||||
XContentParser parser = createParser(jsonBuilder);
|
||||
parser.nextToken();
|
||||
expectThrows(IllegalArgumentException.class, () -> factory.parseExecutable("_w1", "_a1", parser));
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ public class SlackActionTests extends ESTestCase {
|
|||
|
||||
BytesReference bytes = builder.bytes();
|
||||
logger.info("slack action json [{}]", bytes.utf8ToString());
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
|
||||
SlackAction action = SlackAction.parse("_watch", "_action", parser);
|
||||
|
@ -179,7 +179,7 @@ public class SlackActionTests extends ESTestCase {
|
|||
action.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
BytesReference bytes = builder.bytes();
|
||||
logger.info("{}", bytes.utf8ToString());
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
|
||||
SlackAction parsedAction = SlackAction.parse("_watch", "_action", parser);
|
||||
|
@ -191,7 +191,7 @@ public class SlackActionTests extends ESTestCase {
|
|||
|
||||
public void testParserInvalid() throws Exception {
|
||||
XContentBuilder builder = jsonBuilder().startObject().field("unknown_field", "value").endObject();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
parser.nextToken();
|
||||
try {
|
||||
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.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.http.MockResponse;
|
||||
|
@ -46,10 +45,11 @@ import org.hamcrest.Matchers;
|
|||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
|
||||
import javax.mail.internet.AddressException;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.mail.internet.AddressException;
|
||||
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
|
@ -137,7 +137,7 @@ public class WebhookActionTests extends ESTestCase {
|
|||
|
||||
WebhookActionFactory actionParser = webhookFactory(ExecuteScenario.Success.client());
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
parser.nextToken();
|
||||
|
||||
ExecutableWebhookAction executable = actionParser.parseExecutable(randomAsciiOfLength(5), randomAsciiOfLength(5), parser);
|
||||
|
@ -163,7 +163,7 @@ public class WebhookActionTests extends ESTestCase {
|
|||
|
||||
WebhookActionFactory actionParser = webhookFactory(ExecuteScenario.Success.client());
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
parser.nextToken();
|
||||
|
||||
ExecutableWebhookAction parsedExecutable = actionParser.parseExecutable(watchId, actionId, parser);
|
||||
|
@ -189,7 +189,7 @@ public class WebhookActionTests extends ESTestCase {
|
|||
|
||||
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));
|
||||
ExecutableWebhookAction parsedAction = actionParser.parseExecutable(watchId, actionId, parser);
|
||||
assertThat(parsedAction.action(), is(action));
|
||||
|
@ -204,7 +204,7 @@ public class WebhookActionTests extends ESTestCase {
|
|||
}
|
||||
builder.endObject();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
parser.nextToken();
|
||||
|
||||
WebhookActionFactory actionParser = webhookFactory(ExecuteScenario.Success.client());
|
||||
|
|
|
@ -180,7 +180,7 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||
parser.nextToken();
|
||||
|
||||
ArrayCompareCondition condition = (ArrayCompareCondition) ArrayCompareCondition.parse(ClockMock.frozen(), "_id", parser);
|
||||
|
@ -214,7 +214,7 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||
parser.nextToken();
|
||||
|
||||
expectedException.expect(ElasticsearchParseException.class);
|
||||
|
@ -237,7 +237,7 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||
parser.nextToken();
|
||||
|
||||
expectedException.expect(ElasticsearchParseException.class);
|
||||
|
@ -264,7 +264,7 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||
parser.nextToken();
|
||||
|
||||
expectedException.expect(ElasticsearchParseException.class);
|
||||
|
@ -291,7 +291,7 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||
parser.nextToken();
|
||||
|
||||
expectedException.expect(ElasticsearchParseException.class);
|
||||
|
@ -314,7 +314,7 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||
parser.nextToken();
|
||||
|
||||
expectedException.expect(ElasticsearchParseException.class);
|
||||
|
@ -339,7 +339,7 @@ public class ArrayCompareConditionTests extends ESTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||
parser.nextToken();
|
||||
|
||||
expectedException.expect(ElasticsearchParseException.class);
|
||||
|
|
|
@ -168,7 +168,7 @@ public class CompareConditionTests extends ESTestCase {
|
|||
builder.endObject();
|
||||
builder.endObject();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||
parser.nextToken();
|
||||
|
||||
CompareCondition condition = (CompareCondition) CompareCondition.parse(ClockMock.frozen(), "_id", parser);
|
||||
|
@ -186,7 +186,7 @@ public class CompareConditionTests extends ESTestCase {
|
|||
builder.endObject();
|
||||
builder.endObject();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||
try {
|
||||
CompareCondition.parse(ClockMock.frozen(), "_id", parser);
|
||||
fail("Expected ElasticsearchParseException");
|
||||
|
@ -204,7 +204,7 @@ public class CompareConditionTests extends ESTestCase {
|
|||
builder.endObject();
|
||||
builder.endObject();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||
parser.nextToken();
|
||||
try {
|
||||
CompareCondition.parse(ClockMock.frozen(), "_id", parser);
|
||||
|
@ -224,7 +224,7 @@ public class CompareConditionTests extends ESTestCase {
|
|||
builder.endObject();
|
||||
builder.endObject();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||
parser.nextToken();
|
||||
try {
|
||||
CompareCondition.parse(ClockMock.frozen(), "_id", parser);
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.elasticsearch.xpack.watcher.input;
|
|||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
|
@ -19,8 +18,7 @@ public class InputRegistryTests extends ESTestCase {
|
|||
|
||||
public void testParseEmptyInput() throws Exception {
|
||||
InputRegistry registry = new InputRegistry(Settings.EMPTY, emptyMap());
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(
|
||||
jsonBuilder().startObject().endObject().bytes());
|
||||
XContentParser parser = createParser(jsonBuilder().startObject().endObject());
|
||||
parser.nextToken();
|
||||
try {
|
||||
registry.parse("_id", parser);
|
||||
|
@ -32,8 +30,7 @@ public class InputRegistryTests extends ESTestCase {
|
|||
|
||||
public void testParseArrayInput() throws Exception {
|
||||
InputRegistry registry = new InputRegistry(Settings.EMPTY, emptyMap());
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(
|
||||
jsonBuilder().startArray().endArray().bytes());
|
||||
XContentParser parser = createParser(jsonBuilder().startArray().endArray());
|
||||
parser.nextToken();
|
||||
try {
|
||||
registry.parse("_id", parser);
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.elasticsearch.ElasticsearchParseException;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.watcher.input.ExecutableInput;
|
||||
import org.elasticsearch.xpack.watcher.input.Input;
|
||||
|
@ -44,7 +43,7 @@ public class SimpleInputTests extends ESTestCase {
|
|||
|
||||
XContentBuilder jsonBuilder = jsonBuilder().map(data);
|
||||
InputFactory parser = new SimpleInputFactory(Settings.builder().build());
|
||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
||||
XContentParser xContentParser = createParser(jsonBuilder);
|
||||
xContentParser.nextToken();
|
||||
ExecutableInput input = parser.parseExecutable("_id", xContentParser);
|
||||
assertEquals(input.type(), SimpleInput.TYPE);
|
||||
|
@ -60,7 +59,7 @@ public class SimpleInputTests extends ESTestCase {
|
|||
XContentBuilder jsonBuilder = jsonBuilder().value("just a string");
|
||||
|
||||
InputFactory parser = new SimpleInputFactory(Settings.builder().build());
|
||||
XContentParser xContentParser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
||||
XContentParser xContentParser = createParser(jsonBuilder);
|
||||
xContentParser.nextToken();
|
||||
try {
|
||||
parser.parseInput("_id", xContentParser);
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
package org.elasticsearch.xpack.watcher.test;
|
||||
|
||||
import io.netty.util.internal.SystemPropertyUtil;
|
||||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.admin.indices.alias.Alias;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
|
||||
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.SearchResponse;
|
||||
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.WatcherState;
|
||||
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.TriggeredWatchStore;
|
||||
import org.elasticsearch.xpack.watcher.history.HistoryStore;
|
||||
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.trigger.ScheduleTriggerEngineMock;
|
||||
import org.elasticsearch.xpack.watcher.watch.Watch;
|
||||
|
@ -91,7 +89,6 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
@ -322,7 +319,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase
|
|||
if (rarely()) {
|
||||
String newIndex = ".watches-alias-index";
|
||||
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> allMappings = (Map<String, Object>) parserMap.get("mappings");
|
||||
|
||||
|
@ -340,7 +337,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase
|
|||
if (rarely()) {
|
||||
String newIndex = ".triggered-watches-alias-index";
|
||||
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> 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.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
||||
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
|
@ -142,7 +141,7 @@ public class SearchInputTests extends ESIntegTestCase {
|
|||
TimeValue timeout = randomBoolean() ? TimeValue.timeValueSeconds(randomInt(10)) : null;
|
||||
XContentBuilder builder = jsonBuilder().value(
|
||||
new SearchInput(WatcherTestUtils.templateRequest(source), null, timeout, null));
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
parser.nextToken();
|
||||
|
||||
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.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
|
@ -212,7 +211,7 @@ public class SearchTransformTests extends ESIntegTestCase {
|
|||
}
|
||||
builder.endObject();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
parser.nextToken();
|
||||
|
||||
SearchRequestParsers searchRequestParsers = internalCluster().getInstance(SearchRequestParsers.class);
|
||||
|
|
|
@ -69,7 +69,7 @@ public class WatcherSettingsFilterTests extends AbstractWatcherIntegrationTestCa
|
|||
headers = new Header[0];
|
||||
}
|
||||
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");
|
||||
for (Object node : nodes.values()) {
|
||||
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()
|
||||
.endArray();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes());
|
||||
parser.nextToken();
|
||||
ExecutableChainTransform executable = transformParser.parseExecutable("_id", parser);
|
||||
assertThat(executable, notNullValue());
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.script.CompiledScript;
|
||||
import org.elasticsearch.script.ExecutableScript;
|
||||
import org.elasticsearch.script.Script;
|
||||
|
@ -147,7 +146,7 @@ public class ScriptTransformTests extends ESTestCase {
|
|||
builder.startObject("params").field("key", "value").endObject();
|
||||
builder.endObject();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
parser.nextToken();
|
||||
ExecutableScriptTransform transform = new ScriptTransformFactory(Settings.EMPTY, service).parseExecutable("_id", parser);
|
||||
Script script = new Script(type, "_lang", "_script", singletonMap("key", "value"));
|
||||
|
@ -158,7 +157,7 @@ public class ScriptTransformTests extends ESTestCase {
|
|||
ScriptService service = mock(ScriptService.class);
|
||||
XContentBuilder builder = jsonBuilder().value("_script");
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
|
||||
XContentParser parser = createParser(builder);
|
||||
parser.nextToken();
|
||||
ExecutableScriptTransform transform = new ScriptTransformFactory(Settings.EMPTY, service).parseExecutable("_id", parser);
|
||||
assertThat(transform.transform().getScript(), equalTo(new Script("_script")));
|
||||
|
|
|
@ -30,7 +30,7 @@ public class CronScheduleTests extends ScheduleTestCase {
|
|||
public void testParseSingle() throws Exception {
|
||||
XContentBuilder builder = jsonBuilder().value("0 0/5 * * * ?");
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
CronSchedule schedule = new CronSchedule.Parser().parse(parser);
|
||||
assertThat(schedule.crons(), arrayWithSize(1));
|
||||
|
@ -44,7 +44,7 @@ public class CronScheduleTests extends ScheduleTestCase {
|
|||
"0 0/3 * * * ?"
|
||||
});
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
CronSchedule schedule = new CronSchedule.Parser().parse(parser);
|
||||
String[] crons = expressions(schedule);
|
||||
|
@ -57,7 +57,7 @@ public class CronScheduleTests extends ScheduleTestCase {
|
|||
public void testParseInvalidBadExpression() throws Exception {
|
||||
XContentBuilder builder = jsonBuilder().value("0 0/5 * * ?");
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
try {
|
||||
new CronSchedule.Parser().parse(parser);
|
||||
|
@ -71,7 +71,7 @@ public class CronScheduleTests extends ScheduleTestCase {
|
|||
public void testParseInvalidEmpty() throws Exception {
|
||||
XContentBuilder builder = jsonBuilder();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
try {
|
||||
new CronSchedule.Parser().parse(parser);
|
||||
|
@ -85,7 +85,7 @@ public class CronScheduleTests extends ScheduleTestCase {
|
|||
public void testParseInvalidObject() throws Exception {
|
||||
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
try {
|
||||
new CronSchedule.Parser().parse(parser);
|
||||
|
@ -99,7 +99,7 @@ public class CronScheduleTests extends ScheduleTestCase {
|
|||
public void testParseInvalidEmptyArray() throws Exception {
|
||||
XContentBuilder builder = jsonBuilder().value(new String[0]);
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
try {
|
||||
new CronSchedule.Parser().parse(parser);
|
||||
|
|
|
@ -62,7 +62,7 @@ public class DailyScheduleTests extends ScheduleTestCase {
|
|||
public void testParserEmpty() throws Exception {
|
||||
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
DailySchedule schedule = new DailySchedule.Parser().parse(parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -80,7 +80,7 @@ public class DailyScheduleTests extends ScheduleTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
DailySchedule schedule = new DailySchedule.Parser().parse(parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -98,7 +98,7 @@ public class DailyScheduleTests extends ScheduleTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
try {
|
||||
new DailySchedule.Parser().parse(parser);
|
||||
|
@ -115,7 +115,7 @@ public class DailyScheduleTests extends ScheduleTestCase {
|
|||
.field("at", timeStr)
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
DailySchedule schedule = new DailySchedule.Parser().parse(parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -129,7 +129,7 @@ public class DailyScheduleTests extends ScheduleTestCase {
|
|||
.field("at", invalidDayTimeStr())
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
try {
|
||||
new DailySchedule.Parser().parse(parser);
|
||||
|
@ -146,7 +146,7 @@ public class DailyScheduleTests extends ScheduleTestCase {
|
|||
.array("at", (Object[]) times)
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
DailySchedule schedule = new DailySchedule.Parser().parse(parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -163,7 +163,7 @@ public class DailyScheduleTests extends ScheduleTestCase {
|
|||
.array("at", (Object[]) times)
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
try {
|
||||
new DailySchedule.Parser().parse(parser);
|
||||
|
@ -180,7 +180,7 @@ public class DailyScheduleTests extends ScheduleTestCase {
|
|||
.array("at", (Object[]) times)
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
DailySchedule schedule = new DailySchedule.Parser().parse(parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -197,7 +197,7 @@ public class DailyScheduleTests extends ScheduleTestCase {
|
|||
.array("at", times)
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
try {
|
||||
new DailySchedule.Parser().parse(parser);
|
||||
|
|
|
@ -73,7 +73,7 @@ public class HourlyScheduleTests extends ScheduleTestCase {
|
|||
public void testParserEmpty() throws Exception {
|
||||
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
HourlySchedule schedule = new HourlySchedule.Parser().parse(parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -88,7 +88,7 @@ public class HourlyScheduleTests extends ScheduleTestCase {
|
|||
.field("minute", minute)
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
HourlySchedule schedule = new HourlySchedule.Parser().parse(parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -102,7 +102,7 @@ public class HourlyScheduleTests extends ScheduleTestCase {
|
|||
.field("minute", invalidMinute())
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
try {
|
||||
new HourlySchedule.Parser().parse(parser);
|
||||
|
@ -119,7 +119,7 @@ public class HourlyScheduleTests extends ScheduleTestCase {
|
|||
.field("minute", String.valueOf(minute))
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
HourlySchedule schedule = new HourlySchedule.Parser().parse(parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -133,7 +133,7 @@ public class HourlyScheduleTests extends ScheduleTestCase {
|
|||
.field("minute", String.valueOf(invalidMinute()))
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
try {
|
||||
new HourlySchedule.Parser().parse(parser);
|
||||
|
@ -150,7 +150,7 @@ public class HourlyScheduleTests extends ScheduleTestCase {
|
|||
.field("minute", asIterable(minutes))
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
HourlySchedule schedule = new HourlySchedule.Parser().parse(parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -167,7 +167,7 @@ public class HourlyScheduleTests extends ScheduleTestCase {
|
|||
.field("minute", asIterable(minutes))
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
try {
|
||||
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()))
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
HourlySchedule schedule = new HourlySchedule.Parser().parse(parser);
|
||||
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()))
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
try {
|
||||
new HourlySchedule.Parser().parse(parser);
|
||||
|
|
|
@ -23,7 +23,7 @@ public class IntervalScheduleTests extends ESTestCase {
|
|||
long value = randomIntBetween(0, Integer.MAX_VALUE);
|
||||
XContentBuilder builder = jsonBuilder().value(value);
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
IntervalSchedule schedule = new IntervalSchedule.Parser().parse(parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -34,7 +34,7 @@ public class IntervalScheduleTests extends ESTestCase {
|
|||
long value = randomIntBetween(Integer.MIN_VALUE, 0);
|
||||
XContentBuilder builder = jsonBuilder().value(value);
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
try {
|
||||
new IntervalSchedule.Parser().parse(parser);
|
||||
|
@ -49,7 +49,7 @@ public class IntervalScheduleTests extends ESTestCase {
|
|||
IntervalSchedule.Interval value = randomTimeInterval();
|
||||
XContentBuilder builder = jsonBuilder().value(value);
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
IntervalSchedule schedule = new IntervalSchedule.Parser().parse(parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -59,7 +59,7 @@ public class IntervalScheduleTests extends ESTestCase {
|
|||
public void testParseInvalidString() throws Exception {
|
||||
XContentBuilder builder = jsonBuilder().value("43S");
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
try {
|
||||
new IntervalSchedule.Parser().parse(parser);
|
||||
|
@ -72,7 +72,7 @@ public class IntervalScheduleTests extends ESTestCase {
|
|||
public void testParseInvalidObject() throws Exception {
|
||||
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
try {
|
||||
new IntervalSchedule.Parser().parse(parser);
|
||||
|
|
|
@ -66,7 +66,7 @@ public class MonthlyScheduleTests extends ScheduleTestCase {
|
|||
public void testParserEmpty() throws Exception {
|
||||
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
MonthlySchedule schedule = new MonthlySchedule.Parser().parse(parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -86,7 +86,7 @@ public class MonthlyScheduleTests extends ScheduleTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
MonthlySchedule schedule = new MonthlySchedule.Parser().parse(parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -108,7 +108,7 @@ public class MonthlyScheduleTests extends ScheduleTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
try {
|
||||
new MonthlySchedule.Parser().parse(parser);
|
||||
|
@ -122,7 +122,7 @@ public class MonthlyScheduleTests extends ScheduleTestCase {
|
|||
MonthTimes[] times = validMonthTimes();
|
||||
XContentBuilder builder = jsonBuilder().value(times);
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
MonthlySchedule schedule = new MonthlySchedule.Parser().parse(parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -140,7 +140,7 @@ public class MonthlyScheduleTests extends ScheduleTestCase {
|
|||
.array("at", (Object[]) times)
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
try {
|
||||
new MonthlySchedule.Parser().parse(parser);
|
||||
|
|
|
@ -43,7 +43,7 @@ public class ScheduleRegistryTests extends ScheduleTestCase {
|
|||
.field(IntervalSchedule.TYPE, interval)
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
Schedule schedule = registry.parse("ctx", parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -60,7 +60,7 @@ public class ScheduleRegistryTests extends ScheduleTestCase {
|
|||
.field(CronSchedule.TYPE, cron)
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
Schedule schedule = registry.parse("ctx", parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -75,7 +75,7 @@ public class ScheduleRegistryTests extends ScheduleTestCase {
|
|||
.field(HourlySchedule.TYPE, hourly)
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
Schedule schedule = registry.parse("ctx", parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -90,7 +90,7 @@ public class ScheduleRegistryTests extends ScheduleTestCase {
|
|||
.field(DailySchedule.TYPE, daily)
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
Schedule schedule = registry.parse("ctx", parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -105,7 +105,7 @@ public class ScheduleRegistryTests extends ScheduleTestCase {
|
|||
.field(WeeklySchedule.TYPE, weekly)
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
Schedule schedule = registry.parse("ctx", parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -120,7 +120,7 @@ public class ScheduleRegistryTests extends ScheduleTestCase {
|
|||
.field(MonthlySchedule.TYPE, monthly)
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken();
|
||||
Schedule schedule = registry.parse("ctx", parser);
|
||||
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.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
import java.time.Clock;
|
||||
|
@ -26,7 +25,7 @@ public class ScheduleTriggerEventTests extends ESTestCase {
|
|||
jsonBuilder.field(ScheduleTriggerEvent.Field.TRIGGERED_TIME.getPreferredName(), triggeredTime);
|
||||
jsonBuilder.endObject();
|
||||
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(jsonBuilder.bytes());
|
||||
XContentParser parser = createParser(jsonBuilder);
|
||||
parser.nextToken();
|
||||
|
||||
ScheduleTriggerEvent scheduleTriggerEvent = ScheduleTriggerEvent.parse(parser, "_id", "_context", Clock.systemUTC());
|
||||
|
|
|
@ -65,7 +65,7 @@ public class WeeklyScheduleTests extends ScheduleTestCase {
|
|||
public void testParserEmpty() throws Exception {
|
||||
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
WeeklySchedule schedule = new WeeklySchedule.Parser().parse(parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -84,7 +84,7 @@ public class WeeklyScheduleTests extends ScheduleTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
WeeklySchedule schedule = new WeeklySchedule.Parser().parse(parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -106,7 +106,7 @@ public class WeeklyScheduleTests extends ScheduleTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
try {
|
||||
new WeeklySchedule.Parser().parse(parser);
|
||||
|
@ -120,7 +120,7 @@ public class WeeklyScheduleTests extends ScheduleTestCase {
|
|||
WeekTimes[] times = validWeekTimes();
|
||||
XContentBuilder builder = jsonBuilder().value(times);
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
WeeklySchedule schedule = new WeeklySchedule.Parser().parse(parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -138,7 +138,7 @@ public class WeeklyScheduleTests extends ScheduleTestCase {
|
|||
.array("at", (Object[]) times)
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
try {
|
||||
new WeeklySchedule.Parser().parse(parser);
|
||||
|
|
|
@ -72,7 +72,7 @@ public class YearlyScheduleTests extends ScheduleTestCase {
|
|||
public void testParserEmpty() throws Exception {
|
||||
XContentBuilder builder = jsonBuilder().startObject().endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
YearlySchedule schedule = new YearlySchedule.Parser().parse(parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -94,7 +94,7 @@ public class YearlyScheduleTests extends ScheduleTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
YearlySchedule schedule = new YearlySchedule.Parser().parse(parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -117,7 +117,7 @@ public class YearlyScheduleTests extends ScheduleTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
try {
|
||||
new MonthlySchedule.Parser().parse(parser);
|
||||
|
@ -131,7 +131,7 @@ public class YearlyScheduleTests extends ScheduleTestCase {
|
|||
YearTimes[] times = validYearTimes();
|
||||
XContentBuilder builder = jsonBuilder().value(times);
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
YearlySchedule schedule = new YearlySchedule.Parser().parse(parser);
|
||||
assertThat(schedule, notNullValue());
|
||||
|
@ -150,7 +150,7 @@ public class YearlyScheduleTests extends ScheduleTestCase {
|
|||
.array("at", (Object[]) times)
|
||||
.endObject();
|
||||
BytesReference bytes = builder.bytes();
|
||||
XContentParser parser = JsonXContent.jsonXContent.createParser(bytes);
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
|
||||
parser.nextToken(); // advancing to the start object
|
||||
try {
|
||||
new YearlySchedule.Parser().parse(parser);
|
||||
|
|
Loading…
Reference in New Issue