Skip to content

Commit 68d9ff1

Browse files
committed
Reset tests
1 parent 4c839b9 commit 68d9ff1

File tree

10 files changed

+18
-17
lines changed

10 files changed

+18
-17
lines changed

libs/x-content/src/main/java/org/elasticsearch/common/xcontent/ConstructingObjectParser.java

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ public ConstructingObjectParser(String name, boolean ignoreUnknownFields, Functi
149149
public ConstructingObjectParser(String name, boolean ignoreUnknownFields, BiFunction<Object[], Context, Value> builder) {
150150
objectParser = new ObjectParser<>(name, ignoreUnknownFields, null);
151151
this.builder = builder;
152+
152153
}
153154

154155
/**

server/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ public void testUnknownFieldParsing() throws Exception {
288288
.endObject());
289289

290290
XContentParseException ex = expectThrows(XContentParseException.class, () -> request.fromXContent(contentParser));
291-
assertEquals("[1:18] [UpdateRequest] unknown field [unknown_field], parser not found", ex.getMessage());
291+
assertEquals("[1:2] [UpdateRequest] unknown field [unknown_field], parser not found", ex.getMessage());
292292

293293
UpdateRequest request2 = new UpdateRequest("test", "type", "1");
294294
XContentParser unknownObject = createParser(XContentFactory.jsonBuilder()
@@ -299,7 +299,7 @@ public void testUnknownFieldParsing() throws Exception {
299299
.endObject()
300300
.endObject());
301301
ex = expectThrows(XContentParseException.class, () -> request2.fromXContent(unknownObject));
302-
assertEquals("[1:85] [UpdateRequest] unknown field [params], parser not found", ex.getMessage());
302+
assertEquals("[1:76] [UpdateRequest] unknown field [params], parser not found", ex.getMessage());
303303
}
304304

305305
public void testFetchSourceParsing() throws Exception {

server/src/test/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightBuilderTests.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public void testUnknownArrayNameExpection() throws IOException {
162162
XContentParseException e = expectParseThrows(XContentParseException.class, "{\n" +
163163
" \"bad_fieldname\" : [ \"field1\" 1 \"field2\" ]\n" +
164164
"}\n");
165-
assertEquals("[2:23] [highlight] unknown field [bad_fieldname], parser not found", e.getMessage());
165+
assertEquals("[2:5] [highlight] unknown field [bad_fieldname], parser not found", e.getMessage());
166166
}
167167

168168
{
@@ -175,7 +175,7 @@ public void testUnknownArrayNameExpection() throws IOException {
175175
"}\n");
176176
assertThat(e.getMessage(), containsString("[highlight] failed to parse field [fields]"));
177177
assertThat(e.getCause().getMessage(), containsString("[fields] failed to parse field [body]"));
178-
assertEquals("[4:27] [highlight_field] unknown field [bad_fieldname], parser not found", e.getCause().getCause().getMessage());
178+
assertEquals("[4:9] [highlight_field] unknown field [bad_fieldname], parser not found", e.getCause().getCause().getMessage());
179179
}
180180
}
181181

@@ -193,7 +193,7 @@ public void testUnknownFieldnameExpection() throws IOException {
193193
XContentParseException e = expectParseThrows(XContentParseException.class, "{\n" +
194194
" \"bad_fieldname\" : \"value\"\n" +
195195
"}\n");
196-
assertEquals("[2:23] [highlight] unknown field [bad_fieldname], parser not found", e.getMessage());
196+
assertEquals("[2:5] [highlight] unknown field [bad_fieldname], parser not found", e.getMessage());
197197
}
198198

199199
{
@@ -206,7 +206,7 @@ public void testUnknownFieldnameExpection() throws IOException {
206206
"}\n");
207207
assertThat(e.getMessage(), containsString("[highlight] failed to parse field [fields]"));
208208
assertThat(e.getCause().getMessage(), containsString("[fields] failed to parse field [body]"));
209-
assertEquals("[4:27] [highlight_field] unknown field [bad_fieldname], parser not found", e.getCause().getCause().getMessage());
209+
assertEquals("[4:9] [highlight_field] unknown field [bad_fieldname], parser not found", e.getCause().getCause().getMessage());
210210
}
211211
}
212212

@@ -218,7 +218,7 @@ public void testUnknownObjectFieldnameExpection() throws IOException {
218218
XContentParseException e = expectParseThrows(XContentParseException.class, "{\n" +
219219
" \"bad_fieldname\" : { \"field\" : \"value\" }\n \n" +
220220
"}\n");
221-
assertEquals("[2:24] [highlight] unknown field [bad_fieldname], parser not found", e.getMessage());
221+
assertEquals("[2:5] [highlight] unknown field [bad_fieldname], parser not found", e.getMessage());
222222
}
223223

224224
{
@@ -231,7 +231,7 @@ public void testUnknownObjectFieldnameExpection() throws IOException {
231231
"}\n");
232232
assertThat(e.getMessage(), containsString("[highlight] failed to parse field [fields]"));
233233
assertThat(e.getCause().getMessage(), containsString("[fields] failed to parse field [body]"));
234-
assertEquals("[4:27] [highlight_field] unknown field [bad_fieldname], parser not found", e.getCause().getCause().getMessage());
234+
assertEquals("[4:9] [highlight_field] unknown field [bad_fieldname], parser not found", e.getCause().getCause().getMessage());
235235
}
236236
}
237237

server/src/test/java/org/elasticsearch/search/rescore/QueryRescorerBuilderTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public void testUnknownFieldsExpection() throws IOException {
251251
"}\n";
252252
try (XContentParser parser = createParser(rescoreElement)) {
253253
XContentParseException e = expectThrows(XContentParseException.class, () -> RescorerBuilder.parseFromXContent(parser));
254-
assertEquals("[3:35] [query] unknown field [bad_fieldname], parser not found", e.getMessage());
254+
assertEquals("[3:17] [query] unknown field [bad_fieldname], parser not found", e.getMessage());
255255
}
256256

257257
rescoreElement = "{\n" +

server/src/test/java/org/elasticsearch/search/sort/FieldSortBuilderTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public void testUnknownOptionFails() throws IOException {
318318
parser.nextToken();
319319

320320
XContentParseException e = expectThrows(XContentParseException.class, () -> FieldSortBuilder.fromXContent(parser, ""));
321-
assertEquals("[1:30] [field_sort] unknown field [reverse], parser not found", e.getMessage());
321+
assertEquals("[1:18] [field_sort] unknown field [reverse], parser not found", e.getMessage());
322322
}
323323
}
324324

server/src/test/java/org/elasticsearch/search/sort/ScriptSortBuilderTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public void testParseBadFieldNameExceptions() throws IOException {
227227
parser.nextToken();
228228

229229
XContentParseException e = expectThrows(XContentParseException.class, () -> ScriptSortBuilder.fromXContent(parser, null));
230-
assertEquals("[1:29] [_script] unknown field [bad_field], parser not found", e.getMessage());
230+
assertEquals("[1:15] [_script] unknown field [bad_field], parser not found", e.getMessage());
231231
}
232232
}
233233

@@ -240,7 +240,7 @@ public void testParseBadFieldNameExceptionsOnStartObject() throws IOException {
240240
parser.nextToken();
241241

242242
XContentParseException e = expectThrows(XContentParseException.class, () -> ScriptSortBuilder.fromXContent(parser, null));
243-
assertEquals("[1:29] [_script] unknown field [bad_field], parser not found", e.getMessage());
243+
assertEquals("[1:15] [_script] unknown field [bad_field], parser not found", e.getMessage());
244244
}
245245
}
246246

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfigTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public void testFutureConfigParse() throws IOException {
268268
.createParser(xContentRegistry(), DeprecationHandler.THROW_UNSUPPORTED_OPERATION, FUTURE_DATAFEED);
269269
XContentParseException e = expectThrows(XContentParseException.class,
270270
() -> DatafeedConfig.STRICT_PARSER.apply(parser, null).build());
271-
assertEquals("[6:35] [datafeed_config] unknown field [tomorrows_technology_today], parser not found", e.getMessage());
271+
assertEquals("[6:5] [datafeed_config] unknown field [tomorrows_technology_today], parser not found", e.getMessage());
272272
}
273273

274274
public void testPastQueryConfigParse() throws IOException {

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/config/JobTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void testFutureConfigParse() throws IOException {
8181
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, FUTURE_JOB);
8282
XContentParseException e = expectThrows(XContentParseException.class,
8383
() -> Job.STRICT_PARSER.apply(parser, null).build());
84-
assertEquals("[4:35] [job_details] unknown field [tomorrows_technology_today], parser not found", e.getMessage());
84+
assertEquals("[4:5] [job_details] unknown field [tomorrows_technology_today], parser not found", e.getMessage());
8585
}
8686

8787
public void testFutureMetadataParse() throws IOException {

x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultsParserTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ public void testParse_GivenUnknownObject() throws ElasticsearchParseException, I
390390
XContentParseException e = expectThrows(XContentParseException.class,
391391
() -> parser.parseResults(inputStream).forEachRemaining(a -> {
392392
}));
393-
assertEquals("[1:13] [autodetect_result] unknown field [unknown], parser not found", e.getMessage());
393+
assertEquals("[1:3] [autodetect_result] unknown field [unknown], parser not found", e.getMessage());
394394
}
395395
}
396396

x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/common/text/TextTemplateTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public void testParserInvalidUnknownScriptType() throws Exception {
210210
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
211211
parser.nextToken();
212212
XContentParseException ex = expectThrows(XContentParseException.class, () -> TextTemplate.parse(parser));
213-
assertEquals("[1:13] [script] unknown field [template], parser not found", ex.getMessage());
213+
assertEquals("[1:2] [script] unknown field [template], parser not found", ex.getMessage());
214214
}
215215

216216
public void testParserInvalidMissingText() throws Exception {
@@ -222,7 +222,7 @@ public void testParserInvalidMissingText() throws Exception {
222222
XContentParser parser = createParser(JsonXContent.jsonXContent, bytes);
223223
parser.nextToken();
224224
XContentParseException ex = expectThrows(XContentParseException.class, () -> TextTemplate.parse(parser));
225-
assertEquals("[1:9] [script] unknown field [type], parser not found", ex.getMessage());
225+
assertEquals("[1:2] [script] unknown field [type], parser not found", ex.getMessage());
226226
}
227227

228228
public void testNullObject() throws Exception {

0 commit comments

Comments
 (0)