use of org.opensearch.OpenSearchParseException in project OpenSearch by opensearch-project.
the class GrokProcessorFactoryTests method testBuildEmptyPatternsList.
public void testBuildEmptyPatternsList() throws Exception {
GrokProcessor.Factory factory = new GrokProcessor.Factory(Collections.emptyMap(), MatcherWatchdog.noop());
Map<String, Object> config = new HashMap<>();
config.put("field", "foo");
config.put("patterns", Collections.emptyList());
OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config));
assertThat(e.getMessage(), equalTo("[patterns] List of patterns must not be empty"));
}
use of org.opensearch.OpenSearchParseException in project OpenSearch by opensearch-project.
the class GrokProcessorFactoryTests method testCreateWithInvalidPattern.
public void testCreateWithInvalidPattern() throws Exception {
GrokProcessor.Factory factory = new GrokProcessor.Factory(Collections.emptyMap(), MatcherWatchdog.noop());
Map<String, Object> config = new HashMap<>();
config.put("field", "_field");
config.put("patterns", Collections.singletonList("["));
OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config));
assertThat(e.getMessage(), equalTo("[patterns] Invalid regex pattern found in: [[]. premature end of char-class"));
}
use of org.opensearch.OpenSearchParseException in project OpenSearch by opensearch-project.
the class GrokProcessorFactoryTests method testBuildMissingPatterns.
public void testBuildMissingPatterns() throws Exception {
GrokProcessor.Factory factory = new GrokProcessor.Factory(Collections.emptyMap(), MatcherWatchdog.noop());
Map<String, Object> config = new HashMap<>();
config.put("field", "foo");
OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config));
assertThat(e.getMessage(), equalTo("[patterns] required property is missing"));
}
use of org.opensearch.OpenSearchParseException in project OpenSearch by opensearch-project.
the class GrokProcessorFactoryTests method testCreateWithInvalidPatternDefinition.
public void testCreateWithInvalidPatternDefinition() throws Exception {
GrokProcessor.Factory factory = new GrokProcessor.Factory(Collections.emptyMap(), MatcherWatchdog.noop());
Map<String, Object> config = new HashMap<>();
config.put("field", "_field");
config.put("patterns", Collections.singletonList("%{MY_PATTERN:name}!"));
config.put("pattern_definitions", Collections.singletonMap("MY_PATTERN", "["));
OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> factory.create(null, null, null, config));
assertThat(e.getMessage(), equalTo("[patterns] Invalid regex pattern found in: [%{MY_PATTERN:name}!]. premature end of char-class"));
}
use of org.opensearch.OpenSearchParseException in project OpenSearch by opensearch-project.
the class DateProcessorFactoryTests method testMatchFieldIsMandatory.
public void testMatchFieldIsMandatory() throws Exception {
Map<String, Object> config = new HashMap<>();
String targetField = randomAlphaOfLengthBetween(1, 10);
config.put("target_field", targetField);
config.put("formats", Collections.singletonList("dd/MM/yyyyy"));
try {
factory.create(null, null, null, config);
fail("processor creation should have failed");
} catch (OpenSearchParseException e) {
assertThat(e.getMessage(), containsString("[field] required property is missing"));
}
}
Aggregations