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.
This commit is contained in:
Henning Andersen 2019-06-10 19:22:21 +02:00 committed by Henning Andersen
parent 76a92b49a8
commit 437d2d6d9f
1 changed files with 5 additions and 1 deletions

View File

@ -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);
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());
}