use of org.sonar.server.es.SearchIdResult in project sonarqube by SonarSource.
the class RuleIndexTest method search_by_any_of_severities.
@Test
public void search_by_any_of_severities() {
indexRules(newDoc(RuleKey.of("java", "S001")).setSeverity(BLOCKER), newDoc(RuleKey.of("java", "S002")).setSeverity(INFO));
RuleQuery query = new RuleQuery().setSeverities(asList(INFO, MINOR));
SearchIdResult results = index.search(query, new SearchOptions());
assertThat(results.getIds()).containsOnly(RuleKey.of("java", "S002"));
// no results
query = new RuleQuery().setSeverities(singletonList(MINOR));
assertThat(index.search(query, new SearchOptions()).getIds()).isEmpty();
// empty list => no filter
query = new RuleQuery().setSeverities(Collections.emptyList());
assertThat(index.search(query, new SearchOptions()).getIds()).hasSize(2);
// null list => no filter
query = new RuleQuery().setSeverities();
assertThat(index.search(query, new SearchOptions()).getIds()).hasSize(2);
}
Aggregations