From 2d82bea04096c7c0e5a4dbc459dea1b21646ed57 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Mon, 29 Aug 2016 13:27:34 +0200 Subject: [PATCH] fix test bug --- .../index/query/InnerHitBuilderTests.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/index/query/InnerHitBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/InnerHitBuilderTests.java index 4d313baecc1..5f8c847e41e 100644 --- a/core/src/test/java/org/elasticsearch/index/query/InnerHitBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/InnerHitBuilderTests.java @@ -350,8 +350,9 @@ public class InnerHitBuilderTests extends ESTestCase { if (instance.getStoredFieldsContext() == null || randomBoolean()) { List previous = instance.getStoredFieldsContext() == null ? Collections.emptyList() : instance.getStoredFieldsContext().fieldNames(); - instance.setStoredFieldNames(randomValueOtherThan(previous, - () -> randomListStuff(16, () -> randomAsciiOfLengthBetween(1, 16)))); + List newValues = randomValueOtherThan(previous, + () -> randomListStuff(1, 16, () -> randomAsciiOfLengthBetween(1, 16))); + instance.setStoredFieldNames(newValues); } else { instance.getStoredFieldsContext().addFieldName(randomAsciiOfLengthBetween(1, 16)); } @@ -377,7 +378,11 @@ public class InnerHitBuilderTests extends ESTestCase { } static List randomListStuff(int maxSize, Supplier valueSupplier) { - int size = randomIntBetween(0, maxSize); + return randomListStuff(0, maxSize, valueSupplier); + } + + static List randomListStuff(int minSize, int maxSize, Supplier valueSupplier) { + int size = randomIntBetween(minSize, maxSize); List list = new ArrayList<>(size); for (int i = 0; i < size; i++) { list.add(valueSupplier.get());