diff --git a/lucene/misc/src/test/org/apache/lucene/search/TestDiversifiedTopDocsCollector.java b/lucene/misc/src/test/org/apache/lucene/search/TestDiversifiedTopDocsCollector.java index af2597da5ad..5abe613f6d8 100644 --- a/lucene/misc/src/test/org/apache/lucene/search/TestDiversifiedTopDocsCollector.java +++ b/lucene/misc/src/test/org/apache/lucene/search/TestDiversifiedTopDocsCollector.java @@ -94,7 +94,11 @@ public class TestDiversifiedTopDocsCollector extends LuceneTestCase { DiversifiedTopDocsCollector tdc = doDiversifiedSearch(numResults, 15); // start < 0 - assertEquals(0, tdc.topDocs(-1).scoreDocs.length); + IllegalArgumentException expected = expectThrows(IllegalArgumentException.class, () -> { + tdc.topDocs(-1); + }); + + assertEquals("Expected value of starting position is between 0 and 5, got -1", expected.getMessage()); // start > pq.size() assertEquals(0, tdc.topDocs(numResults + 1).scoreDocs.length); @@ -103,7 +107,11 @@ public class TestDiversifiedTopDocsCollector extends LuceneTestCase { assertEquals(0, tdc.topDocs(numResults).scoreDocs.length); // howMany < 0 - assertEquals(0, tdc.topDocs(0, -1).scoreDocs.length); + expected = expectThrows(IllegalArgumentException.class, () -> { + tdc.topDocs(0, -1); + }); + + assertEquals("Number of hits requested must be greater than 0 but value was -1", expected.getMessage()); // howMany == 0 assertEquals(0, tdc.topDocs(0, 0).scoreDocs.length);