Skip to content

Commit

Permalink
Reset tests
Browse files Browse the repository at this point in the history
  • Loading branch information
romseygeek committed May 24, 2019
1 parent 4c839b9 commit 68d9ff1
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public ConstructingObjectParser(String name, boolean ignoreUnknownFields, Functi
public ConstructingObjectParser(String name, boolean ignoreUnknownFields, BiFunction<Object[], Context, Value> builder) {
objectParser = new ObjectParser<>(name, ignoreUnknownFields, null);
this.builder = builder;

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public void testUnknownFieldParsing() throws Exception {
.endObject());

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

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

public void testFetchSourceParsing() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public void testUnknownArrayNameExpection() throws IOException {
XContentParseException e = expectParseThrows(XContentParseException.class, "{\n" +
" \"bad_fieldname\" : [ \"field1\" 1 \"field2\" ]\n" +
"}\n");
assertEquals("[2:23] [highlight] unknown field [bad_fieldname], parser not found", e.getMessage());
assertEquals("[2:5] [highlight] unknown field [bad_fieldname], parser not found", e.getMessage());
}

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

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

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public void testUnknownFieldsExpection() throws IOException {
"}\n";
try (XContentParser parser = createParser(rescoreElement)) {
XContentParseException e = expectThrows(XContentParseException.class, () -> RescorerBuilder.parseFromXContent(parser));
assertEquals("[3:35] [query] unknown field [bad_fieldname], parser not found", e.getMessage());
assertEquals("[3:17] [query] unknown field [bad_fieldname], parser not found", e.getMessage());
}

rescoreElement = "{\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public void testUnknownOptionFails() throws IOException {
parser.nextToken();

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public void testParseBadFieldNameExceptions() throws IOException {
parser.nextToken();

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

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

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

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

public void testPastQueryConfigParse() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void testFutureConfigParse() throws IOException {
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, FUTURE_JOB);
XContentParseException e = expectThrows(XContentParseException.class,
() -> Job.STRICT_PARSER.apply(parser, null).build());
assertEquals("[4:35] [job_details] unknown field [tomorrows_technology_today], parser not found", e.getMessage());
assertEquals("[4:5] [job_details] unknown field [tomorrows_technology_today], parser not found", e.getMessage());
}

public void testFutureMetadataParse() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public void testParse_GivenUnknownObject() throws ElasticsearchParseException, I
XContentParseException e = expectThrows(XContentParseException.class,
() -> parser.parseResults(inputStream).forEachRemaining(a -> {
}));
assertEquals("[1:13] [autodetect_result] unknown field [unknown], parser not found", e.getMessage());
assertEquals("[1:3] [autodetect_result] unknown field [unknown], parser not found", e.getMessage());
}
}

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

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

public void testNullObject() throws Exception {
Expand Down

0 comments on commit 68d9ff1

Please sign in to comment.