Skip to content

Apache Lucene open-source search software

Use TestUtil.nextInt() instead of random().nextInt()

Shai Ereraef486ea11add
diff --git a/lucene/facet/src/test/org/apache/lucene/facet/facetset/TestExactFacetSetMatcher.java b/lucene/facet/src/test/org/apache/lucene/facet/facetset/TestExactFacetSetMatcher.java
index 9a370b78be1..9751822273a 100644
--- a/lucene/facet/src/test/org/apache/lucene/facet/facetset/TestExactFacetSetMatcher.java
+++ b/lucene/facet/src/test/org/apache/lucene/facet/facetset/TestExactFacetSetMatcher.java
@@ -26,6 +26,7 @@ import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.tests.index.RandomIndexWriter;
+import org.apache.lucene.tests.util.TestUtil;
public class TestExactFacetSetMatcher extends FacetTestCase {
@@ -98,7 +99,7 @@ public class TestExactFacetSetMatcher extends FacetTestCase {
int numMatchingDocs = 0;
for (int i = 0; i < 100; i++) {
Document doc = new Document();
- int numSets = random().nextInt(1, 4);
+ int numSets = TestUtil.nextInt(random(), 1, 4);
Collections.shuffle(allSets, random());
LongFacetSet[] facetSets = allSets.subList(0, numSets).toArray(LongFacetSet[]::new);
boolean matchingDoc = false;
@@ -160,7 +161,7 @@ public class TestExactFacetSetMatcher extends FacetTestCase {
int numMatchingDocs = 0;
for (int i = 0; i < 100; i++) {
Document doc = new Document();
- int numSets = random().nextInt(1, 4);
+ int numSets = TestUtil.nextInt(random(), 1, 4);
Collections.shuffle(allSets, random());
IntFacetSet[] facetSets = allSets.subList(0, numSets).toArray(IntFacetSet[]::new);
boolean matchingDoc = false;
@@ -222,7 +223,7 @@ public class TestExactFacetSetMatcher extends FacetTestCase {
int numMatchingDocs = 0;
for (int i = 0; i < 100; i++) {
Document doc = new Document();
- int numSets = random().nextInt(1, 4);
+ int numSets = TestUtil.nextInt(random(), 1, 4);
Collections.shuffle(allSets, random());
DoubleFacetSet[] facetSets = allSets.subList(0, numSets).toArray(DoubleFacetSet[]::new);
boolean matchingDoc = false;
@@ -284,7 +285,7 @@ public class TestExactFacetSetMatcher extends FacetTestCase {
int numMatchingDocs = 0;
for (int i = 0; i < 100; i++) {
Document doc = new Document();
- int numSets = random().nextInt(1, 4);
+ int numSets = TestUtil.nextInt(random(), 1, 4);
Collections.shuffle(allSets, random());
FloatFacetSet[] facetSets = allSets.subList(0, numSets).toArray(FloatFacetSet[]::new);
boolean matchingDoc = false;
diff --git a/lucene/facet/src/test/org/apache/lucene/facet/facetset/TestRangeFacetSetMatcher.java b/lucene/facet/src/test/org/apache/lucene/facet/facetset/TestRangeFacetSetMatcher.java
index d0626579abc..ec055d900df 100644
--- a/lucene/facet/src/test/org/apache/lucene/facet/facetset/TestRangeFacetSetMatcher.java
+++ b/lucene/facet/src/test/org/apache/lucene/facet/facetset/TestRangeFacetSetMatcher.java
@@ -26,6 +26,7 @@ import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.tests.index.RandomIndexWriter;
+import org.apache.lucene.tests.util.TestUtil;
public class TestRangeFacetSetMatcher extends FacetTestCase {
@@ -54,7 +55,7 @@ public class TestRangeFacetSetMatcher extends FacetTestCase {
int numMatchingDocs = 0;
for (int i = 0; i < 100; i++) {
Document doc = new Document();
- int numSets = random().nextInt(1, 4);
+ int numSets = TestUtil.nextInt(random(), 1, 4);
Collections.shuffle(allSets, random());
LongFacetSet[] facetSets = allSets.subList(0, numSets).toArray(LongFacetSet[]::new);
boolean matchingDoc = false;
@@ -138,7 +139,7 @@ public class TestRangeFacetSetMatcher extends FacetTestCase {
int numMatchingDocs = 0;
for (int i = 0; i < 100; i++) {
Document doc = new Document();
- int numSets = random().nextInt(1, 4);
+ int numSets = TestUtil.nextInt(random(), 1, 4);
Collections.shuffle(allSets, random());
IntFacetSet[] facetSets = allSets.subList(0, numSets).toArray(IntFacetSet[]::new);
boolean matchingDoc = false;
@@ -222,7 +223,7 @@ public class TestRangeFacetSetMatcher extends FacetTestCase {
int numMatchingDocs = 0;
for (int i = 0; i < 100; i++) {
Document doc = new Document();
- int numSets = random().nextInt(1, 4);
+ int numSets = TestUtil.nextInt(random(), 1, 4);
Collections.shuffle(allSets, random());
DoubleFacetSet[] facetSets = allSets.subList(0, numSets).toArray(DoubleFacetSet[]::new);
boolean matchingDoc = false;
@@ -314,7 +315,7 @@ public class TestRangeFacetSetMatcher extends FacetTestCase {
int numMatchingDocs = 0;
for (int i = 0; i < 100; i++) {
Document doc = new Document();
- int numSets = random().nextInt(1, 4);
+ int numSets = TestUtil.nextInt(random(), 1, 4);
Collections.shuffle(allSets, random());
FloatFacetSet[] facetSets = allSets.subList(0, numSets).toArray(FloatFacetSet[]::new);
boolean matchingDoc = false;