From 437d2d6d9f68ab87805a4f52b17ad42725310d6c Mon Sep 17 00:00:00 2001 From: Henning Andersen <33268011+henningandersen@users.noreply.github.com> Date: Mon, 10 Jun 2019 19:22:21 +0200 Subject: [PATCH] Rename processor test fix (#43035) If the source field name is a prefix of the target field name, the source field still exists after rename processor has run. Adjusted test case to handle that case. --- .../elasticsearch/ingest/common/RenameProcessorTests.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RenameProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RenameProcessorTests.java index 5b3d88879ba..5c3b0b0e7f3 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RenameProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RenameProcessorTests.java @@ -132,7 +132,11 @@ public class RenameProcessorTests extends ESTestCase { String newFieldName = randomValueOtherThanMany(ingestDocument::hasField, () -> RandomDocumentPicks.randomFieldName(random())); Processor processor = createRenameProcessor(fieldName, newFieldName, false); processor.execute(ingestDocument); - assertThat(ingestDocument.hasField(fieldName), equalTo(false)); + if (newFieldName.startsWith(fieldName + '.')) { + assertThat(ingestDocument.getFieldValue(fieldName, Object.class), instanceOf(Map.class)); + } else { + assertThat(ingestDocument.hasField(fieldName), equalTo(false)); + } assertThat(ingestDocument.hasField(newFieldName), equalTo(true)); assertThat(ingestDocument.getFieldValue(newFieldName, Object.class), nullValue()); }