You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by gs...@apache.org on 2023/03/07 02:17:53 UTC

[lucene] branch branch_9x updated: Fixup TestLongValueFacetCounts after GITHUB#11744.

This is an automated email from the ASF dual-hosted git repository.

gsmiller pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 01cdc5a9da5 Fixup TestLongValueFacetCounts after GITHUB#11744.
01cdc5a9da5 is described below

commit 01cdc5a9da5eec40850010ed1656a41c7cb960a9
Author: Greg Miller <gs...@gmail.com>
AuthorDate: Mon Mar 6 17:52:02 2023 -0800

    Fixup TestLongValueFacetCounts after GITHUB#11744.
    
    GH#11744 deprecated LongValueFacetCounts#getTopChildrenSortByCount in favor
    of the standard Facets#getTopChildren. The issue is that #getTopChildrenSortByCount
    didn't do any input validation and allowed for topN == 0, while #getTopChildren
    does input validation. Randomized testing could produce topN values of 0, which
    resulted in falied tests. This addresses the tests.
---
 .../test/org/apache/lucene/facet/TestLongValueFacetCounts.java   | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lucene/facet/src/test/org/apache/lucene/facet/TestLongValueFacetCounts.java b/lucene/facet/src/test/org/apache/lucene/facet/TestLongValueFacetCounts.java
index 58c232c8c6e..531b868660e 100644
--- a/lucene/facet/src/test/org/apache/lucene/facet/TestLongValueFacetCounts.java
+++ b/lucene/facet/src/test/org/apache/lucene/facet/TestLongValueFacetCounts.java
@@ -17,6 +17,7 @@
 
 package org.apache.lucene.facet;
 
+import com.carrotsearch.randomizedtesting.generators.RandomNumbers;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Comparator;
@@ -394,7 +395,7 @@ public class TestLongValueFacetCounts extends FacetTestCase {
       if (random().nextBoolean()) {
         topN = docCount;
       } else {
-        topN = random().nextInt(docCount);
+        topN = RandomNumbers.randomIntBetween(random(), 1, docCount);
       }
       if (VERBOSE) {
         System.out.println("  topN=" + topN);
@@ -486,7 +487,7 @@ public class TestLongValueFacetCounts extends FacetTestCase {
       if (random().nextBoolean()) {
         topN = docCount;
       } else {
-        topN = random().nextInt(docCount);
+        topN = RandomNumbers.randomIntBetween(random(), 1, docCount);
       }
       actual = facetCounts.getTopChildren(topN, "field");
       assertSame(
@@ -657,7 +658,7 @@ public class TestLongValueFacetCounts extends FacetTestCase {
       if (random().nextBoolean()) {
         topN = docCount;
       } else {
-        topN = random().nextInt(docCount);
+        topN = RandomNumbers.randomIntBetween(random(), 1, docCount);
       }
       if (VERBOSE) {
         System.out.println("  topN=" + topN);
@@ -727,7 +728,7 @@ public class TestLongValueFacetCounts extends FacetTestCase {
       if (random().nextBoolean()) {
         topN = docCount;
       } else {
-        topN = random().nextInt(docCount);
+        topN = RandomNumbers.randomIntBetween(random(), 1, docCount);
       }
       actual = facetCounts.getTopChildren(topN, "field");
       assertSame(