Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Rename] ElasticsearchParseException class in server module #169

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.elasticsearch.client.indices;

import org.elasticsearch.OpenSearchGenerationException;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.OpenSearchParseException;
import org.elasticsearch.action.admin.indices.alias.Alias;
import org.elasticsearch.action.support.ActiveShardCount;
import org.elasticsearch.client.TimedRequest;
Expand Down Expand Up @@ -239,7 +239,7 @@ public CreateIndexRequest aliases(BytesReference source, XContentType contentTyp
}
return this;
} catch(IOException e) {
throw new ElasticsearchParseException("Failed to parse aliases", e);
throw new OpenSearchParseException("Failed to parse aliases", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package org.elasticsearch.client.indices;

import org.elasticsearch.OpenSearchGenerationException;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.OpenSearchParseException;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.action.admin.indices.alias.Alias;
Expand Down Expand Up @@ -320,7 +320,7 @@ public PutIndexTemplateRequest source(Map<String, Object> templateSource) {
} else if (name.equals("aliases")) {
aliases((Map<String, Object>) entry.getValue());
} else {
throw new ElasticsearchParseException("unknown key [{}] in the template ", name);
throw new OpenSearchParseException("unknown key [{}] in the template ", name);
}
}
return this;
Expand Down Expand Up @@ -400,7 +400,7 @@ public PutIndexTemplateRequest aliases(BytesReference source) {
}
return this;
} catch(IOException e) {
throw new ElasticsearchParseException("Failed to parse aliases", e);
throw new OpenSearchParseException("Failed to parse aliases", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private String randomTimeUnit() {
public void testFailOnUnknownUnits() {
try {
TimeValue.parseTimeValue("23tw", null, "test");
fail("Expected ElasticsearchParseException");
fail("Expected OpenSearchParseException");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), containsString("failed to parse"));
}
Expand All @@ -181,7 +181,7 @@ public void testFailOnUnknownUnits() {
public void testFailOnMissingUnits() {
try {
TimeValue.parseTimeValue("42", null, "test");
fail("Expected ElasticsearchParseException");
fail("Expected OpenSearchParseException");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), containsString("failed to parse"));
}
Expand All @@ -190,7 +190,7 @@ public void testFailOnMissingUnits() {
public void testNoDotsAllowed() {
try {
TimeValue.parseTimeValue("42ms.", null, "test");
fail("Expected ElasticsearchParseException");
fail("Expected OpenSearchParseException");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), containsString("failed to parse"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ public Settings onNodeStopped(String nodeName) {
.get());
assertThat(exception.getMessage(),
equalTo("pipeline with id [" + pipelineIdWithScript + "] could not be loaded, caused by " +
"[ElasticsearchParseException[Error updating pipeline with id [" + pipelineIdWithScript + "]]; " +
"nested: OpenSearchException[java.lang.IllegalArgumentException: cannot execute [inline] scripts]; " +
"[OpenSearchParseException[Error updating pipeline with id [" + pipelineIdWithScript + "]]; " +
"nested: ElasticsearchException[java.lang.IllegalArgumentException: cannot execute [inline] scripts]; " +
nknize marked this conversation as resolved.
Show resolved Hide resolved
"nested: IllegalArgumentException[cannot execute [inline] scripts];; " +
"OpenSearchException[java.lang.IllegalArgumentException: cannot execute [inline] scripts]; " +
"nested: IllegalArgumentException[cannot execute [inline] scripts];; java.lang.IllegalArgumentException: " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.elasticsearch.ingest.common;

import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.OpenSearchParseException;
import org.elasticsearch.ingest.RandomDocumentPicks;
import org.elasticsearch.test.ESTestCase;

Expand Down Expand Up @@ -96,7 +96,7 @@ public void testCreateMissingField() throws Exception {
try {
factory.create(null, null, null, config);
fail("factory create should have failed");
} catch(ElasticsearchParseException e) {
} catch(OpenSearchParseException e) {
assertThat(e.getMessage(), equalTo("[field] required property is missing"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.elasticsearch.ingest.common;

import org.elasticsearch.OpenSearchException;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.OpenSearchParseException;
import org.elasticsearch.ingest.TestTemplateService;
import org.elasticsearch.test.ESTestCase;
import org.junit.Before;
Expand Down Expand Up @@ -64,7 +64,7 @@ public void testCreateNoFieldPresent() throws Exception {
try {
factory.create(null, null, null, config);
fail("factory create should have failed");
} catch(ElasticsearchParseException e) {
} catch(OpenSearchParseException e) {
assertThat(e.getMessage(), equalTo("[field] required property is missing"));
}
}
Expand All @@ -75,7 +75,7 @@ public void testCreateNoValuePresent() throws Exception {
try {
factory.create(null, null, null, config);
fail("factory create should have failed");
} catch(ElasticsearchParseException e) {
} catch(OpenSearchParseException e) {
assertThat(e.getMessage(), equalTo("[value] required property is missing"));
}
}
Expand All @@ -87,7 +87,7 @@ public void testCreateNullValue() throws Exception {
try {
factory.create(null, null, null, config);
fail("factory create should have failed");
} catch(ElasticsearchParseException e) {
} catch(OpenSearchParseException e) {
assertThat(e.getMessage(), equalTo("[value] required property is missing"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.elasticsearch.ingest.common;

import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.OpenSearchParseException;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;

Expand Down Expand Up @@ -56,7 +56,7 @@ public void testCreateUnsupportedType() throws Exception {
try {
factory.create(null, null, null, config);
fail("factory create should have failed");
} catch (ElasticsearchParseException e) {
} catch (OpenSearchParseException e) {
assertThat(e.getMessage(), Matchers.equalTo("[type] type [" + type + "] not supported, cannot convert field."));
assertThat(e.getMetadata("es.processor_type").get(0), equalTo(ConvertProcessor.TYPE));
assertThat(e.getMetadata("es.property_name").get(0), equalTo("type"));
Expand All @@ -72,7 +72,7 @@ public void testCreateNoFieldPresent() throws Exception {
try {
factory.create(null, null, null, config);
fail("factory create should have failed");
} catch (ElasticsearchParseException e) {
} catch (OpenSearchParseException e) {
assertThat(e.getMessage(), Matchers.equalTo("[field] required property is missing"));
}
}
Expand All @@ -84,7 +84,7 @@ public void testCreateNoTypePresent() throws Exception {
try {
factory.create(null, null, null, config);
fail("factory create should have failed");
} catch (ElasticsearchParseException e) {
} catch (OpenSearchParseException e) {
assertThat(e.getMessage(), Matchers.equalTo("[type] required property is missing"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.elasticsearch.ingest.common;

import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.OpenSearchParseException;
import org.elasticsearch.ingest.TestTemplateService;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;
Expand Down Expand Up @@ -89,12 +89,12 @@ public void testRequiredFields() throws Exception {
DateIndexNameProcessor.Factory factory = new DateIndexNameProcessor.Factory(TestTemplateService.instance());
Map<String, Object> config = new HashMap<>();
config.put("date_rounding", "y");
ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, null, config));
OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config));
assertThat(e.getMessage(), Matchers.equalTo("[field] required property is missing"));

config.clear();
config.put("field", "_field");
e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, null, config));
e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config));
assertThat(e.getMessage(), Matchers.equalTo("[date_rounding] required property is missing"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.elasticsearch.ingest.common;

import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.OpenSearchParseException;
import org.elasticsearch.ingest.TestTemplateService;
import org.elasticsearch.test.ESTestCase;
import org.junit.Before;
Expand Down Expand Up @@ -67,7 +67,7 @@ public void testMatchFieldIsMandatory() throws Exception {
try {
factory.create(null, null, null, config);
fail("processor creation should have failed");
} catch(ElasticsearchParseException e) {
} catch(OpenSearchParseException e) {
assertThat(e.getMessage(), containsString("[field] required property is missing"));
}
}
Expand All @@ -82,7 +82,7 @@ public void testMatchFormatsIsMandatory() throws Exception {
try {
factory.create(null, null, null, config);
fail("processor creation should have failed");
} catch(ElasticsearchParseException e) {
} catch(OpenSearchParseException e) {
assertThat(e.getMessage(), containsString("[formats] required property is missing"));
}
}
Expand Down Expand Up @@ -130,7 +130,7 @@ public void testParseMatchFormatsFailure() throws Exception {
try {
factory.create(null, null, null, config);
fail("processor creation should have failed");
} catch(ElasticsearchParseException e) {
} catch(OpenSearchParseException e) {
assertThat(e.getMessage(), containsString("[formats] property isn't a list, but of type [java.lang.String]"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.elasticsearch.ingest.common;

import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.OpenSearchParseException;
import org.elasticsearch.dissect.DissectException;
import org.elasticsearch.ingest.RandomDocumentPicks;
import org.elasticsearch.test.ESTestCase;
Expand Down Expand Up @@ -60,15 +60,15 @@ public void testCreateMissingField() {
DissectProcessor.Factory factory = new DissectProcessor.Factory();
Map<String, Object> config = new HashMap<>();
config.put("pattern", "%{a},%{b},%{c}");
Exception e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, "_tag", null, config));
Exception e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, "_tag", null, config));
assertThat(e.getMessage(), Matchers.equalTo("[field] required property is missing"));
}

public void testCreateMissingPattern() {
DissectProcessor.Factory factory = new DissectProcessor.Factory();
Map<String, Object> config = new HashMap<>();
config.put("field", randomAlphaOfLength(10));
Exception e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, "_tag", null, config));
Exception e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, "_tag", null, config));
assertThat(e.getMessage(), Matchers.equalTo("[pattern] required property is missing"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.elasticsearch.ingest.common;

import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.OpenSearchParseException;
import org.elasticsearch.test.ESTestCase;

import java.util.HashMap;
Expand Down Expand Up @@ -66,7 +66,7 @@ public void testCreate_fieldMissing() throws Exception {

Map<String, Object> config = new HashMap<>();
config.put("path", "_path");
Exception e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, "_tag", null, config));
Exception e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, "_tag", null, config));
assertThat(e.getMessage(), equalTo("[field] required property is missing"));
}

Expand All @@ -76,23 +76,23 @@ public void testCreate_invalidFields() throws Exception {
for (String field : fields) {
Map<String, Object> config = new HashMap<>();
config.put("field", field);
Exception e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, "_tag", null, config));
Exception e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, "_tag", null, config));
assertThat(e.getMessage(), equalTo("[field] field does not contain a dot"));
}

fields = new String[] {".a", "a.", "."};
for (String field : fields) {
Map<String, Object> config = new HashMap<>();
config.put("field", field);
Exception e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, "_tag", null, config));
Exception e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, "_tag", null, config));
assertThat(e.getMessage(), equalTo("[field] Field can't start or end with a dot"));
}

fields = new String[] {"a..b", "a...b", "a.b..c", "abc.def..hij"};
for (String field : fields) {
Map<String, Object> config = new HashMap<>();
config.put("field", field);
Exception e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, "_tag", null, config));
Exception e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, "_tag", null, config));
assertThat(e.getMessage(), equalTo("[field] No space between dots"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.elasticsearch.ingest.common;

import org.elasticsearch.OpenSearchException;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.OpenSearchParseException;
import org.elasticsearch.ingest.TestTemplateService;
import org.elasticsearch.test.ESTestCase;
import org.junit.Before;
Expand Down Expand Up @@ -54,7 +54,7 @@ public void testCreateMissingMessageField() throws Exception {
try {
factory.create(null, null, null, config);
fail("factory create should have failed");
} catch(ElasticsearchParseException e) {
} catch(OpenSearchParseException e) {
assertThat(e.getMessage(), equalTo("[message] required property is missing"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.elasticsearch.ingest.common;

import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.OpenSearchParseException;
import org.elasticsearch.ingest.Processor;
import org.elasticsearch.ingest.TestProcessor;
import org.elasticsearch.script.ScriptService;
Expand Down Expand Up @@ -85,7 +85,7 @@ public void testCreateWithTooManyProcessorTypes() throws Exception {
processorTypes.put("_first", Collections.emptyMap());
processorTypes.put("_second", Collections.emptyMap());
config.put("processor", processorTypes);
Exception exception = expectThrows(ElasticsearchParseException.class, () -> forEachFactory.create(registry, null, null, config));
Exception exception = expectThrows(OpenSearchParseException.class, () -> forEachFactory.create(registry, null, null, config));
assertThat(exception.getMessage(), equalTo("[processor] Must specify exactly one processor type"));
}

Expand All @@ -94,7 +94,7 @@ public void testCreateWithNonExistingProcessorType() throws Exception {
Map<String, Object> config = new HashMap<>();
config.put("field", "_field");
config.put("processor", Collections.singletonMap("_name", Collections.emptyMap()));
Exception expectedException = expectThrows(ElasticsearchParseException.class,
Exception expectedException = expectThrows(OpenSearchParseException.class,
() -> forEachFactory.create(Collections.emptyMap(), null, null, config));
assertThat(expectedException.getMessage(), equalTo("No processor type exists with name [_name]"));
}
Expand Down
Loading