mirror of https://github.com/apache/lucene.git
Harden Up TestDiversifiedTopDocsCollector (#858)
TestDiversifiedTopDocsCollector.testInvalidArguments should check for exceptions and corresponding messages, post LUCENE-8905
This commit is contained in:
parent
13addb4d5e
commit
321dc80927
|
@ -94,7 +94,11 @@ public class TestDiversifiedTopDocsCollector extends LuceneTestCase {
|
||||||
DiversifiedTopDocsCollector tdc = doDiversifiedSearch(numResults, 15);
|
DiversifiedTopDocsCollector tdc = doDiversifiedSearch(numResults, 15);
|
||||||
|
|
||||||
// start < 0
|
// 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()
|
// start > pq.size()
|
||||||
assertEquals(0, tdc.topDocs(numResults + 1).scoreDocs.length);
|
assertEquals(0, tdc.topDocs(numResults + 1).scoreDocs.length);
|
||||||
|
@ -103,7 +107,11 @@ public class TestDiversifiedTopDocsCollector extends LuceneTestCase {
|
||||||
assertEquals(0, tdc.topDocs(numResults).scoreDocs.length);
|
assertEquals(0, tdc.topDocs(numResults).scoreDocs.length);
|
||||||
|
|
||||||
// howMany < 0
|
// 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
|
// howMany == 0
|
||||||
assertEquals(0, tdc.topDocs(0, 0).scoreDocs.length);
|
assertEquals(0, tdc.topDocs(0, 0).scoreDocs.length);
|
||||||
|
|
Loading…
Reference in New Issue