Harden Up TestDiversifiedTopDocsCollector (#858)

TestDiversifiedTopDocsCollector.testInvalidArguments should check for
exceptions and corresponding messages, post LUCENE-8905
This commit is contained in:
Atri Sharma 2019-09-05 23:01:10 +05:30 committed by Adrien Grand
parent 13addb4d5e
commit 321dc80927
1 changed files with 10 additions and 2 deletions

View File

@ -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);