From 0c7e58de93c33d4d64073abd583978cd82a8e451 Mon Sep 17 00:00:00 2001 From: Isabel Drost-Fromm Date: Thu, 28 Apr 2016 15:14:15 +0200 Subject: [PATCH] Get rid of duplicate random sort order generation --- .../search/sort/FieldSortBuilderTests.java | 4 ++-- .../search/sort/GeoDistanceSortBuilderTests.java | 4 ++-- .../search/sort/RandomSortDataGenerator.java | 15 --------------- .../search/sort/ScoreSortBuilderTests.java | 3 ++- .../search/sort/ScriptSortBuilderTests.java | 2 +- 5 files changed, 7 insertions(+), 21 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 c557c714d0f..ebfa3bbb76f 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/FieldSortBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/sort/FieldSortBuilderTests.java @@ -40,7 +40,7 @@ public class FieldSortBuilderTests extends AbstractSortTestCase randomFrom(SortOrder.values()))); break; default: throw new IllegalStateException("Unsupported mutation."); diff --git a/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderTests.java b/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderTests.java index a43f9c54bb3..723e569bdb5 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderTests.java @@ -83,7 +83,7 @@ public class GeoDistanceSortBuilderTests extends AbstractSortTestCase randomFrom(SortOrder.values()))); break; case 5: result.sortMode(mode(original.sortMode())); 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 86a12f7ad84..bad5ff83f76 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/RandomSortDataGenerator.java +++ b/core/src/test/java/org/elasticsearch/search/sort/RandomSortDataGenerator.java @@ -84,19 +84,4 @@ public class RandomSortDataGenerator { } return missing; } - - /** - * return a random {@link SortOrder} settings, except the one provided by parameter if set - */ - public static SortOrder order(@Nullable SortOrder original) { - if (original == null) { - return ESTestCase.randomBoolean() ? SortOrder.ASC : SortOrder.DESC; - } - if (original.equals(SortOrder.ASC)) { - return SortOrder.DESC; - } else { - return SortOrder.ASC; - } - } - } diff --git a/core/src/test/java/org/elasticsearch/search/sort/ScoreSortBuilderTests.java b/core/src/test/java/org/elasticsearch/search/sort/ScoreSortBuilderTests.java index 142a88c4036..222240a9ac4 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/ScoreSortBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/sort/ScoreSortBuilderTests.java @@ -26,6 +26,7 @@ import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.query.QueryParseContext; +import org.elasticsearch.test.ESTestCase; import org.junit.Rule; import org.junit.rules.ExpectedException; @@ -45,7 +46,7 @@ public class ScoreSortBuilderTests extends AbstractSortTestCase randomFrom(SortOrder.values()))); return result; } diff --git a/core/src/test/java/org/elasticsearch/search/sort/ScriptSortBuilderTests.java b/core/src/test/java/org/elasticsearch/search/sort/ScriptSortBuilderTests.java index b14b82aa092..9637df30772 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/ScriptSortBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/sort/ScriptSortBuilderTests.java @@ -49,7 +49,7 @@ public class ScriptSortBuilderTests extends AbstractSortTestCase