|
@@ -22,6 +22,7 @@ package org.elasticsearch.common.xcontent;
|
|
|
import com.fasterxml.jackson.core.JsonGenerationException;
|
|
|
import com.fasterxml.jackson.core.JsonGenerator;
|
|
|
import com.fasterxml.jackson.core.JsonParseException;
|
|
|
+
|
|
|
import org.apache.lucene.util.BytesRef;
|
|
|
import org.apache.lucene.util.Constants;
|
|
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
|
@@ -78,6 +79,7 @@ import java.util.concurrent.TimeUnit;
|
|
|
import static java.util.Collections.emptyMap;
|
|
|
import static java.util.Collections.singletonMap;
|
|
|
import static org.hamcrest.Matchers.allOf;
|
|
|
+import static org.hamcrest.Matchers.containsInAnyOrder;
|
|
|
import static org.hamcrest.Matchers.containsString;
|
|
|
import static org.hamcrest.Matchers.endsWith;
|
|
|
import static org.hamcrest.Matchers.equalTo;
|
|
@@ -1169,16 +1171,17 @@ public abstract class BaseXContentTestCase extends ESTestCase {
|
|
|
{
|
|
|
NamedObjectNotFoundException e = expectThrows(NamedObjectNotFoundException.class,
|
|
|
() -> p.namedObject(Object.class, "unknown", null));
|
|
|
- assertThat(e.getMessage(), endsWith("unable to parse Object with name [unknown]: parser not found"));
|
|
|
+ assertThat(e.getMessage(), endsWith("unknown field [unknown]"));
|
|
|
+ assertThat(e.getCandidates(), containsInAnyOrder("test1", "test2", "deprecated", "str"));
|
|
|
}
|
|
|
{
|
|
|
- Exception e = expectThrows(NamedObjectNotFoundException.class, () -> p.namedObject(String.class, "doesn't matter", null));
|
|
|
+ Exception e = expectThrows(XContentParseException.class, () -> p.namedObject(String.class, "doesn't matter", null));
|
|
|
assertEquals("unknown named object category [java.lang.String]", e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
try (XContentParser emptyRegistryParser = xcontentType().xContent()
|
|
|
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, new byte[] {})) {
|
|
|
- Exception e = expectThrows(NamedObjectNotFoundException.class,
|
|
|
+ Exception e = expectThrows(XContentParseException.class,
|
|
|
() -> emptyRegistryParser.namedObject(String.class, "doesn't matter", null));
|
|
|
assertEquals("named objects are not supported for this parser", e.getMessage());
|
|
|
}
|