trimmed down SimpleQueryTests + more assertAcked
This commit is contained in:
parent
de206e72f1
commit
fe1d22af01
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -131,7 +131,7 @@ public class ElasticsearchAssertions {
|
|||
assertThat("Expected id: " + hit.getId() + " in the result but wasn't." + shardStatus, idsSet.remove(hit.getId()),
|
||||
equalTo(true));
|
||||
}
|
||||
assertThat("Expected ids: " + Arrays.toString(idsSet.toArray(new String[0])) + " in the result - result size differs."
|
||||
assertThat("Expected ids: " + Arrays.toString(idsSet.toArray(new String[idsSet.size()])) + " in the result - result size differs."
|
||||
+ shardStatus, idsSet.size(), equalTo(0));
|
||||
assertVersionSerializable(searchResponse);
|
||||
}
|
||||
|
@ -283,6 +283,10 @@ public class ElasticsearchAssertions {
|
|||
return new ElasticsearchMatchers.SearchHitHasIndexMatcher(index);
|
||||
}
|
||||
|
||||
public static Matcher<SearchHit> hasScore(final float score) {
|
||||
return new ElasticsearchMatchers.SearchHitHasScoreMatcher(score);
|
||||
}
|
||||
|
||||
public static <T extends Query> T assertBooleanSubQuery(Query query, Class<T> subqueryType, int i) {
|
||||
assertThat(query, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery q = (BooleanQuery) query;
|
||||
|
|
|
@ -93,4 +93,26 @@ public class ElasticsearchMatchers {
|
|||
}
|
||||
}
|
||||
|
||||
public static class SearchHitHasScoreMatcher extends TypeSafeMatcher<SearchHit> {
|
||||
private float score;
|
||||
|
||||
public SearchHitHasScoreMatcher(float score) {
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean matchesSafely(SearchHit searchHit) {
|
||||
return searchHit.getScore() == score;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeMismatchSafely(final SearchHit searchHit, final Description mismatchDescription) {
|
||||
mismatchDescription.appendText(" was ").appendValue(searchHit.getScore());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(final Description description) {
|
||||
description.appendText("searchHit score should be ").appendValue(score);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue