use of org.elasticsearch.ingest.useragent.UserAgentProcessor in project elasticsearch by elastic.
the class UserAgentProcessorTests method testNullValueWithIgnoreMissing.
public void testNullValueWithIgnoreMissing() throws Exception {
UserAgentProcessor processor = new UserAgentProcessor(randomAsciiOfLength(10), "source_field", "target_field", null, EnumSet.allOf(UserAgentProcessor.Property.class), true);
IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("source_field", null));
IngestDocument ingestDocument = new IngestDocument(originalIngestDocument);
processor.execute(ingestDocument);
assertIngestDocument(originalIngestDocument, ingestDocument);
}
use of org.elasticsearch.ingest.useragent.UserAgentProcessor in project elasticsearch by elastic.
the class UserAgentProcessorTests method setupProcessor.
@BeforeClass
public static void setupProcessor() throws IOException {
InputStream regexStream = UserAgentProcessor.class.getResourceAsStream("/regexes.yaml");
assertNotNull(regexStream);
UserAgentParser parser = new UserAgentParser(randomAsciiOfLength(10), regexStream, new UserAgentCache(1000));
processor = new UserAgentProcessor(randomAsciiOfLength(10), "source_field", "target_field", parser, EnumSet.allOf(UserAgentProcessor.Property.class), false);
}
use of org.elasticsearch.ingest.useragent.UserAgentProcessor in project elasticsearch by elastic.
the class UserAgentProcessorTests method testNonExistentWithoutIgnoreMissing.
public void testNonExistentWithoutIgnoreMissing() throws Exception {
UserAgentProcessor processor = new UserAgentProcessor(randomAsciiOfLength(10), "source_field", "target_field", null, EnumSet.allOf(UserAgentProcessor.Property.class), false);
IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap());
IngestDocument ingestDocument = new IngestDocument(originalIngestDocument);
Exception exception = expectThrows(Exception.class, () -> processor.execute(ingestDocument));
assertThat(exception.getMessage(), equalTo("field [source_field] not present as part of path [source_field]"));
}
use of org.elasticsearch.ingest.useragent.UserAgentProcessor in project elasticsearch by elastic.
the class UserAgentProcessorTests method testNonExistentWithIgnoreMissing.
public void testNonExistentWithIgnoreMissing() throws Exception {
UserAgentProcessor processor = new UserAgentProcessor(randomAsciiOfLength(10), "source_field", "target_field", null, EnumSet.allOf(UserAgentProcessor.Property.class), true);
IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap());
IngestDocument ingestDocument = new IngestDocument(originalIngestDocument);
processor.execute(ingestDocument);
assertIngestDocument(originalIngestDocument, ingestDocument);
}
use of org.elasticsearch.ingest.useragent.UserAgentProcessor in project elasticsearch by elastic.
the class UserAgentProcessorTests method testNullWithoutIgnoreMissing.
public void testNullWithoutIgnoreMissing() throws Exception {
UserAgentProcessor processor = new UserAgentProcessor(randomAsciiOfLength(10), "source_field", "target_field", null, EnumSet.allOf(UserAgentProcessor.Property.class), false);
IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("source_field", null));
IngestDocument ingestDocument = new IngestDocument(originalIngestDocument);
Exception exception = expectThrows(Exception.class, () -> processor.execute(ingestDocument));
assertThat(exception.getMessage(), equalTo("field [source_field] is null, cannot parse user-agent."));
}
Aggregations