From 3490daa7eaa501ea21de2b2beb21cbbe96ccf326 Mon Sep 17 00:00:00 2001 From: Isabel Drost-Fromm Date: Thu, 28 Apr 2016 15:27:36 +0200 Subject: [PATCH] Get rid of no longer needed missing generation method --- .../search/sort/FieldSortBuilderTests.java | 15 +++++++-- .../search/sort/RandomSortDataGenerator.java | 33 ------------------- 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/search/sort/FieldSortBuilderTests.java b/core/src/test/java/org/elasticsearch/search/sort/FieldSortBuilderTests.java index ebfa3bbb76f..27f87681777 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/FieldSortBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/sort/FieldSortBuilderTests.java @@ -28,6 +28,8 @@ import org.elasticsearch.index.query.QueryParseContext; import org.elasticsearch.test.ESTestCase; import java.io.IOException; +import java.util.Arrays; +import java.util.List; public class FieldSortBuilderTests extends AbstractSortTestCase { @@ -36,7 +38,14 @@ public class FieldSortBuilderTests extends AbstractSortTestCase missingContent = Arrays.asList( + "_last", + "_first", + ESTestCase.randomAsciiOfLength(10), ESTestCase.randomUnicodeOfCodepointLengthBetween(5, 15), + ESTestCase.randomInt()); + + + public FieldSortBuilder randomFieldSortBuilder() { String fieldName = rarely() ? FieldSortBuilder.DOC_FIELD_NAME : randomAsciiOfLengthBetween(1, 10); FieldSortBuilder builder = new FieldSortBuilder(fieldName); if (randomBoolean()) { @@ -44,7 +53,7 @@ public class FieldSortBuilderTests extends AbstractSortTestCase randomFrom(missingContent))); } if (randomBoolean()) { @@ -92,7 +101,7 @@ public class FieldSortBuilderTests extends AbstractSortTestCase ESTestCase.randomAsciiOfLengthBetween(1, 10))); break; case 4: - mutated.missing(RandomSortDataGenerator.missing(mutated.missing())); + mutated.missing(ESTestCase.randomValueOtherThan(mutated.missing(), () -> randomFrom(missingContent))); break; case 5: mutated.order(ESTestCase.randomValueOtherThan(mutated.order(), () -> randomFrom(SortOrder.values()))); diff --git a/core/src/test/java/org/elasticsearch/search/sort/RandomSortDataGenerator.java b/core/src/test/java/org/elasticsearch/search/sort/RandomSortDataGenerator.java index bad5ff83f76..43ff2428d81 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/RandomSortDataGenerator.java +++ b/core/src/test/java/org/elasticsearch/search/sort/RandomSortDataGenerator.java @@ -19,16 +19,12 @@ package org.elasticsearch.search.sort; -import org.elasticsearch.common.Nullable; import org.elasticsearch.index.query.IdsQueryBuilder; import org.elasticsearch.index.query.MatchAllQueryBuilder; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.TermQueryBuilder; import org.elasticsearch.test.ESTestCase; -import java.util.HashSet; -import java.util.Set; - public class RandomSortDataGenerator { private RandomSortDataGenerator() { // this is a helper class only, doesn't need a constructor @@ -55,33 +51,4 @@ public class RandomSortDataGenerator { return nested; } - public static Object missing(Object original) { - Object missing = null; - Object otherMissing = original; - - while (missing == null || missing.equals(otherMissing)) { - int missingId = ESTestCase.randomIntBetween(0, 4); - switch (missingId) { - case 0: - missing = ("_last"); - break; - case 1: - missing = ("_first"); - break; - case 2: - missing = ESTestCase.randomAsciiOfLength(10); - break; - case 3: - missing = ESTestCase.randomUnicodeOfCodepointLengthBetween(5, 15); - break; - case 4: - missing = ESTestCase.randomInt(); - break; - default: - throw new IllegalStateException("Unknown missing type."); - - } - } - return missing; - } }