From 512272b01ccbc087adfe8ef9a1eabbca314f94e4 Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Thu, 22 Jun 2017 08:34:20 -0700 Subject: [PATCH] fix sort and string processor tests around targetField Tests were randomly assigning `targetField` to an existing field that was an array, causing path resolution issues. This PR fixes those tests Closes #25346 & #25348 --- .../ingest/common/AbstractStringProcessorTestCase.java | 4 ++-- .../ingest/common/SortProcessorTests.java | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AbstractStringProcessorTestCase.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AbstractStringProcessorTestCase.java index d48c795c5b26a..9d37f27bb33e5 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AbstractStringProcessorTestCase.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AbstractStringProcessorTestCase.java @@ -103,10 +103,10 @@ public void testNonStringValueWithIgnoreMissing() throws Exception { } public void testTargetField() throws Exception { - IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); + IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap()); String fieldValue = RandomDocumentPicks.randomString(random()); String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, modifyInput(fieldValue)); - String targetFieldName = RandomDocumentPicks.randomFieldName(random()); + String targetFieldName = fieldName + "foo"; Processor processor = newProcessor(fieldName, randomBoolean(), targetFieldName); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue(targetFieldName, String.class), equalTo(expectedResult(fieldValue))); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SortProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SortProcessorTests.java index 8fa3f90d6ae74..5eca68f35de21 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SortProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SortProcessorTests.java @@ -276,7 +276,7 @@ public void testSortNullValue() throws Exception { } public void testDescendingSortWithTargetField() throws Exception { - IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); + IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap()); int numItems = randomIntBetween(1, 10); List fieldValue = new ArrayList<>(numItems); List expectedResult = new ArrayList<>(numItems); @@ -289,7 +289,7 @@ public void testDescendingSortWithTargetField() throws Exception { Collections.sort(expectedResult, Collections.reverseOrder()); String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValue); - String targetFieldName = RandomDocumentPicks.randomFieldName(random()); + String targetFieldName = fieldName + "foo"; Processor processor = new SortProcessor(randomAlphaOfLength(10), fieldName, SortOrder.DESCENDING, targetFieldName); processor.execute(ingestDocument); @@ -297,7 +297,7 @@ public void testDescendingSortWithTargetField() throws Exception { } public void testAscendingSortWithTargetField() throws Exception { - IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); + IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap()); int numItems = randomIntBetween(1, 10); List fieldValue = new ArrayList<>(numItems); List expectedResult = new ArrayList<>(numItems); @@ -310,7 +310,7 @@ public void testAscendingSortWithTargetField() throws Exception { Collections.sort(expectedResult); String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValue); - String targetFieldName = RandomDocumentPicks.randomFieldName(random()); + String targetFieldName = fieldName + "foo"; Processor processor = new SortProcessor(randomAlphaOfLength(10), fieldName, SortOrder.ASCENDING, targetFieldName); processor.execute(ingestDocument); @@ -318,7 +318,7 @@ public void testAscendingSortWithTargetField() throws Exception { } public void testSortWithTargetFieldLeavesOriginalUntouched() throws Exception { - IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); + IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap()); List fieldValue = Arrays.asList(1, 5, 4); List expectedResult = new ArrayList<>(fieldValue); Collections.sort(expectedResult);