use of org.sonar.db.rule.RuleMetadataDto in project sonarqube by SonarSource.
the class ShowActionTest method show_rule_tags.
@Test
public void show_rule_tags() {
RuleDefinitionDto rule = db.rules().insert();
RuleMetadataDto metadata = db.rules().insertOrUpdateMetadata(rule, setTags("tag1", "tag2"), m -> m.setNoteData(null).setNoteUserUuid(null));
ShowResponse result = ws.newRequest().setParam(PARAM_KEY, rule.getKey().toString()).executeProtobuf(ShowResponse.class);
assertThat(result.getRule().getTags().getTagsList()).containsExactly(metadata.getTags().toArray(new String[0]));
}
use of org.sonar.db.rule.RuleMetadataDto in project sonarqube by SonarSource.
the class SearchActionTest method issue_on_external_adhoc_rule_with_metadata.
@Test
public void issue_on_external_adhoc_rule_with_metadata() {
ComponentDto project = db.components().insertPublicProject();
indexPermissions();
ComponentDto file = db.components().insertComponent(newFileDto(project));
RuleDefinitionDto rule = db.rules().insertIssueRule(RuleTesting.EXTERNAL_XOO, r -> r.setIsExternal(true).setLanguage("xoo").setIsAdHoc(true));
RuleMetadataDto ruleMetadata = db.rules().insertOrUpdateMetadata(rule, m -> m.setAdHocName("different_rule_name"));
IssueDto issue = db.issues().insertIssue(rule, project, file);
indexIssues();
SearchWsResponse response = ws.newRequest().setParam("additionalFields", "rules").executeProtobuf(SearchWsResponse.class);
assertThat(response.getIssuesList()).extracting(Issue::getKey, Issue::getRule, Issue::getExternalRuleEngine).containsExactlyInAnyOrder(tuple(issue.getKey(), rule.getKey().toString(), "xoo"));
assertThat(response.getRules().getRulesList()).extracting(Common.Rule::getKey, Common.Rule::getName).containsExactlyInAnyOrder(tuple(rule.getKey().toString(), ruleMetadata.getAdHocName()));
}
Aggregations