fix test bug

This commit is contained in:
Martijn van Groningen 2016-08-29 13:27:34 +02:00
parent 2a00c9dc46
commit 2d82bea040
1 changed files with 8 additions and 3 deletions

View File

@ -350,8 +350,9 @@ public class InnerHitBuilderTests extends ESTestCase {
if (instance.getStoredFieldsContext() == null || randomBoolean()) {
List<String> previous = instance.getStoredFieldsContext() == null ?
Collections.emptyList() : instance.getStoredFieldsContext().fieldNames();
instance.setStoredFieldNames(randomValueOtherThan(previous,
() -> randomListStuff(16, () -> randomAsciiOfLengthBetween(1, 16))));
List<String> 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 <T> List<T> randomListStuff(int maxSize, Supplier<T> valueSupplier) {
int size = randomIntBetween(0, maxSize);
return randomListStuff(0, maxSize, valueSupplier);
}
static <T> List<T> randomListStuff(int minSize, int maxSize, Supplier<T> valueSupplier) {
int size = randomIntBetween(minSize, maxSize);
List<T> list = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
list.add(valueSupplier.get());