use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.
the class PersistIssuesStepTest method insert_new_issue.
@Test
public void insert_new_issue() {
RuleDto rule = RuleTesting.newDto(RuleKey.of("xoo", "S01"));
dbClient.ruleDao().insert(session, rule);
OrganizationDto organizationDto = dbTester.organizations().insert();
ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
dbClient.componentDao().insert(session, project);
ComponentDto file = ComponentTesting.newFileDto(project, null);
dbClient.componentDao().insert(session, file);
session.commit();
issueCache.newAppender().append(new DefaultIssue().setKey("ISSUE").setType(RuleType.CODE_SMELL).setRuleKey(rule.getKey()).setComponentUuid(file.uuid()).setProjectUuid(project.uuid()).setSeverity(Severity.BLOCKER).setStatus(Issue.STATUS_OPEN).setNew(true).setType(RuleType.BUG)).close();
step.execute();
IssueDto result = dbClient.issueDao().selectOrFailByKey(session, "ISSUE");
assertThat(result.getKey()).isEqualTo("ISSUE");
assertThat(result.getRuleKey()).isEqualTo(rule.getKey());
assertThat(result.getComponentUuid()).isEqualTo(file.uuid());
assertThat(result.getProjectUuid()).isEqualTo(project.uuid());
assertThat(result.getSeverity()).isEqualTo(Severity.BLOCKER);
assertThat(result.getStatus()).isEqualTo(Issue.STATUS_OPEN);
assertThat(result.getType()).isEqualTo(RuleType.BUG.getDbConstant());
}
use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.
the class IssueUpdaterTest method newIssue.
private IssueDto newIssue() {
RuleDto rule = ruleDbTester.insertRule(newRuleDto());
ComponentDto project = componentDbTester.insertProject();
ComponentDto file = componentDbTester.insertComponent(newFileDto(project));
return newDto(rule, file, project);
}
use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.
the class IssueUpdaterTest method verify_notification_when_issue_is_linked_on_removed_rule.
@Test
public void verify_notification_when_issue_is_linked_on_removed_rule() throws Exception {
RuleDto rule = ruleDbTester.insertRule(newRuleDto().setStatus(RuleStatus.REMOVED));
ComponentDto project = componentDbTester.insertProject();
ComponentDto file = componentDbTester.insertComponent(newFileDto(project));
DefaultIssue issue = issueDbTester.insertIssue(newDto(rule, file, project)).setSeverity(MAJOR).toDefaultIssue();
IssueChangeContext context = IssueChangeContext.createUser(new Date(), "john");
issueFieldsSetter.setSeverity(issue, BLOCKER, context);
underTest.saveIssue(dbTester.getSession(), issue, context, null);
verify(notificationManager).scheduleForSending(notificationArgumentCaptor.capture());
assertThat(notificationArgumentCaptor.getValue().getFieldValue("ruleName")).isNull();
}
use of org.sonar.db.rule.RuleDto 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.db.rule.RuleDto in project sonarqube by SonarSource.
the class SetSeverityActionTest method newIssue.
private IssueDto newIssue() {
RuleDto rule = db.rules().insertRule(newRuleDto());
ComponentDto project = db.components().insertProject();
ComponentDto file = db.components().insertComponent(newFileDto(project));
return newDto(rule, file, project);
}
Aggregations