Trimmed down HighlighterSearchTests
Used common assertHighlight and concise mapping whenever possible More indexRandom too
This commit is contained in:
parent
06938e6fb0
commit
2071fb26c2
File diff suppressed because it is too large
Load Diff
|
@ -200,15 +200,27 @@ public class ElasticsearchAssertions {
|
|||
assertHighlight(resp, hit, field, fragment, equalTo(totalFragments), matcher);
|
||||
}
|
||||
|
||||
public static void assertHighlight(SearchHit hit, String field, int fragment, Matcher<String> matcher) {
|
||||
assertHighlight(hit, field, fragment, greaterThan(fragment), matcher);
|
||||
}
|
||||
|
||||
public static void assertHighlight(SearchHit hit, String field, int fragment, int totalFragments, Matcher<String> matcher) {
|
||||
assertHighlight(hit, field, fragment, equalTo(totalFragments), matcher);
|
||||
}
|
||||
|
||||
private static void assertHighlight(SearchResponse resp, int hit, String field, int fragment, Matcher<Integer> fragmentsMatcher, Matcher<String> matcher) {
|
||||
assertNoFailures(resp);
|
||||
assertThat("not enough hits", resp.getHits().hits().length, greaterThan(hit));
|
||||
assertThat(resp.getHits().hits()[hit].getHighlightFields(), hasKey(field));
|
||||
assertThat(resp.getHits().hits()[hit].getHighlightFields().get(field).fragments().length, fragmentsMatcher);
|
||||
assertThat(resp.getHits().hits()[hit].highlightFields().get(field).fragments()[fragment].string(), matcher);
|
||||
assertHighlight(resp.getHits().hits()[hit], field, fragment, fragmentsMatcher, matcher);
|
||||
assertVersionSerializable(resp);
|
||||
}
|
||||
|
||||
private static void assertHighlight(SearchHit hit, String field, int fragment, Matcher<Integer> fragmentsMatcher, Matcher<String> matcher) {
|
||||
assertThat(hit.getHighlightFields(), hasKey(field));
|
||||
assertThat(hit.getHighlightFields().get(field).fragments().length, fragmentsMatcher);
|
||||
assertThat(hit.highlightFields().get(field).fragments()[fragment].string(), matcher);
|
||||
}
|
||||
|
||||
public static void assertNotHighlighted(SearchResponse resp, int hit, String field) {
|
||||
assertNoFailures(resp);
|
||||
assertThat("not enough hits", resp.getHits().hits().length, greaterThan(hit));
|
||||
|
|
Loading…
Reference in New Issue