|
31 | 31 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasId; |
32 | 32 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasRank; |
33 | 33 | import static org.hamcrest.Matchers.arrayWithSize; |
| 34 | +import static org.hamcrest.Matchers.emptyArray; |
34 | 35 | import static org.hamcrest.Matchers.equalTo; |
| 36 | +import static org.hamcrest.Matchers.greaterThan; |
35 | 37 |
|
36 | 38 | /** |
37 | 39 | * this base class acts as a wrapper for testing different rerankers, and their behavior when exceptions are thrown |
@@ -191,7 +193,7 @@ public void testRerankerPaginationOutsideOfBounds() throws Exception { |
191 | 193 | .setFrom(10), |
192 | 194 | response -> { |
193 | 195 | assertHitCount(response, 5L); |
194 | | - assertEquals(0, response.getHits().getHits().length); |
| 196 | + assertThat(response.getHits().getHits(), emptyArray()); |
195 | 197 | } |
196 | 198 | ); |
197 | 199 | assertNoOpenContext(indexName); |
@@ -227,7 +229,7 @@ public void testNotAllShardsArePresentInFetchPhase() throws Exception { |
227 | 229 | .setSize(2), |
228 | 230 | response -> { |
229 | 231 | assertHitCount(response, 4L); |
230 | | - assertEquals(2, response.getHits().getHits().length); |
| 232 | + assertThat(response.getHits().getHits(), arrayWithSize(2)); |
231 | 233 | int rank = 1; |
232 | 234 | for (SearchHit searchHit : response.getHits().getHits()) { |
233 | 235 | assertThat(searchHit, hasId(String.valueOf(5 - (rank - 1)))); |
@@ -398,13 +400,13 @@ public void testRankFeaturePhaseShardThrowingPartialFailures() throws Exception |
398 | 400 | .setAllowPartialSearchResults(true) |
399 | 401 | .setSize(10), |
400 | 402 | response -> { |
401 | | - assertTrue(response.getFailedShards() > 0); |
| 403 | + assertThat(response.getFailedShards(), greaterThan(0)); |
402 | 404 | assertTrue( |
403 | 405 | Arrays.stream(response.getShardFailures()) |
404 | 406 | .allMatch(failure -> failure.getCause().getMessage().contains("rfs - simulated failure")) |
405 | 407 | ); |
406 | 408 | assertHitCount(response, 5); |
407 | | - assertThat(response.getHits().getHits(), arrayWithSize(5)); |
| 409 | + assertThat(response.getHits().getHits(), emptyArray()); |
408 | 410 | } |
409 | 411 | ); |
410 | 412 | assertNoOpenContext(indexName); |
|
0 commit comments