From eaa6bebe54af8f6322a8fdc4a37b4bf02af16a16 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Thu, 25 Jul 2013 13:04:23 +0200 Subject: [PATCH] Fix CustomScoreSearchTest that assumed a certain order of doc IDs with equal score --- .../search/customscore/CustomScoreSearchTests.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/elasticsearch/test/integration/search/customscore/CustomScoreSearchTests.java b/src/test/java/org/elasticsearch/test/integration/search/customscore/CustomScoreSearchTests.java index b60a4445954..a6364795a19 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/customscore/CustomScoreSearchTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/customscore/CustomScoreSearchTests.java @@ -38,10 +38,9 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.FilterBuilders.termFilter; import static org.elasticsearch.index.query.QueryBuilders.*; import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHits; import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertNotNull; /** * @@ -306,8 +305,8 @@ public class CustomScoreSearchTests extends AbstractSharedClusterTest { assertThat(response.getHits().totalHits(), equalTo(2l)); logger.info("Hit[0] {} Explanation {}", response.getHits().getAt(0).id(), response.getHits().getAt(0).explanation()); logger.info("Hit[1] {} Explanation {}", response.getHits().getAt(1).id(), response.getHits().getAt(1).explanation()); - assertThat(response.getHits().getAt(0).id(), equalTo("1")); - assertThat(response.getHits().getAt(1).id(), equalTo("2")); + assertSearchHits(response, "1", "2"); + logger.info("running param1 * param2 * _score with filter instead of query"); response = client().search(searchRequest() @@ -318,7 +317,7 @@ public class CustomScoreSearchTests extends AbstractSharedClusterTest { assertThat(response.getHits().totalHits(), equalTo(2l)); logger.info("Hit[0] {} Explanation {}", response.getHits().getAt(0).id(), response.getHits().getAt(0).explanation()); logger.info("Hit[1] {} Explanation {}", response.getHits().getAt(1).id(), response.getHits().getAt(1).explanation()); - assertThat(response.getHits().getAt(0).id(), equalTo("1")); + assertSearchHits(response, "1", "2"); assertThat(response.getHits().getAt(0).score(), equalTo(4f)); // _score is always 1 assertThat(response.getHits().getAt(1).score(), equalTo(4f)); // _score is always 1 }