|
22 | 22 | import com.fasterxml.jackson.core.JsonGenerationException;
|
23 | 23 | import com.fasterxml.jackson.core.JsonGenerator;
|
24 | 24 | import com.fasterxml.jackson.core.JsonParseException;
|
| 25 | + |
25 | 26 | import org.apache.lucene.util.BytesRef;
|
26 | 27 | import org.apache.lucene.util.Constants;
|
27 | 28 | import org.elasticsearch.cluster.metadata.IndexMetaData;
|
|
78 | 79 | import static java.util.Collections.emptyMap;
|
79 | 80 | import static java.util.Collections.singletonMap;
|
80 | 81 | import static org.hamcrest.Matchers.allOf;
|
| 82 | +import static org.hamcrest.Matchers.containsInAnyOrder; |
81 | 83 | import static org.hamcrest.Matchers.containsString;
|
82 | 84 | import static org.hamcrest.Matchers.endsWith;
|
83 | 85 | import static org.hamcrest.Matchers.equalTo;
|
@@ -1169,16 +1171,17 @@ public void testNamedObject() throws IOException {
|
1169 | 1171 | {
|
1170 | 1172 | NamedObjectNotFoundException e = expectThrows(NamedObjectNotFoundException.class,
|
1171 | 1173 | () -> p.namedObject(Object.class, "unknown", null));
|
1172 |
| - assertThat(e.getMessage(), endsWith("unable to parse Object with name [unknown]: parser not found")); |
| 1174 | + assertThat(e.getMessage(), endsWith("unknown field [unknown]")); |
| 1175 | + assertThat(e.getCandidates(), containsInAnyOrder("test1", "test2", "deprecated", "str")); |
1173 | 1176 | }
|
1174 | 1177 | {
|
1175 |
| - Exception e = expectThrows(NamedObjectNotFoundException.class, () -> p.namedObject(String.class, "doesn't matter", null)); |
| 1178 | + Exception e = expectThrows(XContentParseException.class, () -> p.namedObject(String.class, "doesn't matter", null)); |
1176 | 1179 | assertEquals("unknown named object category [java.lang.String]", e.getMessage());
|
1177 | 1180 | }
|
1178 | 1181 | }
|
1179 | 1182 | try (XContentParser emptyRegistryParser = xcontentType().xContent()
|
1180 | 1183 | .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, new byte[] {})) {
|
1181 |
| - Exception e = expectThrows(NamedObjectNotFoundException.class, |
| 1184 | + Exception e = expectThrows(XContentParseException.class, |
1182 | 1185 | () -> emptyRegistryParser.namedObject(String.class, "doesn't matter", null));
|
1183 | 1186 | assertEquals("named objects are not supported for this parser", e.getMessage());
|
1184 | 1187 | }
|
|
0 commit comments