use of org.sonar.api.rule.RuleKey in project sonarqube by SonarSource.
the class RulesAggregationTest method count_rules.
@Test
public void count_rules() {
RulesAggregation rulesAggregation = new RulesAggregation();
RuleKey ruleKey = RuleKey.of("xoo", "S001");
RuleDto ruleDto = RuleTesting.newDto(ruleKey).setName("Rule name");
rulesAggregation.add(ruleDto);
rulesAggregation.add(ruleDto);
RulesAggregation.Rule rule = new RulesAggregation.Rule(ruleKey, "Rule name");
assertThat(rulesAggregation.rules()).hasSize(1);
assertThat(rulesAggregation.rules().iterator().next().name()).isEqualTo("Rule name");
assertThat(rulesAggregation.countRule(rule)).isEqualTo(2);
}
use of org.sonar.api.rule.RuleKey in project sonarqube by SonarSource.
the class IssueIndexDebtTest method facets_on_languages.
@Test
public void facets_on_languages() {
ComponentDto project = ComponentTesting.newProjectDto(newOrganizationDto());
ComponentDto file = ComponentTesting.newFileDto(project, null);
RuleKey ruleKey = RuleKey.of("repo", "X1");
indexIssues(IssueDocTesting.newDoc("ISSUE1", file).setRuleKey(ruleKey.toString()).setLanguage("xoo").setEffort(10L));
SearchResult<IssueDoc> result = index.search(newQueryBuilder().build(), new SearchOptions().addFacets(newArrayList("languages")));
assertThat(result.getFacets().getNames()).containsOnly("languages", FACET_MODE_EFFORT);
assertThat(result.getFacets().get("languages")).containsOnly(entry("xoo", 10L));
assertThat(result.getFacets().get(FACET_MODE_EFFORT)).containsOnly(entry("total", 10L));
}
use of org.sonar.api.rule.RuleKey in project sonarqube by SonarSource.
the class IssueIndexTest method filter_by_languages.
@Test
public void filter_by_languages() {
ComponentDto project = newProjectDto(newOrganizationDto());
ComponentDto file = newFileDto(project, null);
RuleKey ruleKey = RuleKey.of("repo", "X1");
indexIssues(IssueDocTesting.newDoc("ISSUE1", file).setRuleKey(ruleKey.toString()).setLanguage("xoo"));
assertThat(underTest.search(IssueQuery.builder().languages(newArrayList("xoo")).build(), new SearchOptions()).getDocs()).hasSize(1);
assertThat(underTest.search(IssueQuery.builder().languages(newArrayList("unknown")).build(), new SearchOptions()).getDocs()).isEmpty();
}
use of org.sonar.api.rule.RuleKey in project sonarqube by SonarSource.
the class IssueIndexTest method filter_by_rules.
@Test
public void filter_by_rules() {
ComponentDto project = newProjectDto(newOrganizationDto());
ComponentDto file = newFileDto(project, null);
RuleKey ruleKey = RuleKey.of("repo", "X1");
indexIssues(IssueDocTesting.newDoc("ISSUE1", file).setRuleKey(ruleKey.toString()));
assertThat(underTest.search(IssueQuery.builder().rules(newArrayList(ruleKey)).build(), new SearchOptions()).getDocs()).hasSize(1);
assertThat(underTest.search(IssueQuery.builder().rules(newArrayList(RuleKey.of("rule", "without issue"))).build(), new SearchOptions()).getDocs()).isEmpty();
}
use of org.sonar.api.rule.RuleKey in project sonarqube by SonarSource.
the class IssueIndexTest method facets_on_languages.
@Test
public void facets_on_languages() {
ComponentDto project = newProjectDto(newOrganizationDto());
ComponentDto file = newFileDto(project, null);
RuleKey ruleKey = RuleKey.of("repo", "X1");
indexIssues(IssueDocTesting.newDoc("ISSUE1", file).setRuleKey(ruleKey.toString()).setLanguage("xoo"));
SearchResult<IssueDoc> result = underTest.search(IssueQuery.builder().build(), new SearchOptions().addFacets(newArrayList("languages")));
assertThat(result.getFacets().getNames()).containsOnly("languages");
assertThat(result.getFacets().get("languages")).containsOnly(entry("xoo", 1L));
}
Aggregations