Use Java 15 text blocks for JSON and multiline strings (#80751)

The ES code base is quite JSON heavy. It uses a lot of multi-line JSON requests in tests which need to be escaped and concatenated which in turn makes them hard to read. Let's try to leverage Java 15 text blocks for representing them.
This commit is contained in:
Artem Prigoda 2021-12-15 18:01:28 +01:00 committed by GitHub
parent ca01b5fe49
commit 763d6d510f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
730 changed files with 28591 additions and 25000 deletions

View file

@ -178,13 +178,23 @@ public class CCSDuelIT extends ESRestTestCase {
int numShards = randomIntBetween(1, 5);
CreateIndexRequest createIndexRequest = new CreateIndexRequest(INDEX_NAME);
createIndexRequest.settings(Settings.builder().put("index.number_of_shards", numShards).put("index.number_of_replicas", 0));
createIndexRequest.mapping(
"{\"properties\":{"
+ "\"id\":{\"type\":\"keyword\"},"
+ "\"suggest\":{\"type\":\"completion\"},"
+ "\"join\":{\"type\":\"join\", \"relations\": {\"question\":\"answer\"}}}}",
XContentType.JSON
);
createIndexRequest.mapping("""
{
"properties": {
"id": {
"type": "keyword"
},
"suggest": {
"type": "completion"
},
"join": {
"type": "join",
"relations": {
"question": "answer"
}
}
}
}""", XContentType.JSON);
CreateIndexResponse createIndexResponse = restHighLevelClient.indices().create(createIndexRequest, RequestOptions.DEFAULT);
assertTrue(createIndexResponse.isAcknowledged());