Search in sources :

Example 6 with DefaultIssue

use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.

the class IssueStorage method update.

/**
   * @return the keys of the updated issues
   */
private Collection<String> update(List<DefaultIssue> issuesToUpdate, long now) {
    Collection<String> updated = new ArrayList<>();
    if (!issuesToUpdate.isEmpty()) {
        try (DbSession dbSession = dbClient.openSession(false)) {
            IssueChangeMapper issueChangeMapper = dbSession.getMapper(IssueChangeMapper.class);
            for (DefaultIssue issue : issuesToUpdate) {
                String key = doUpdate(dbSession, now, issue);
                updated.add(key);
                insertChanges(issueChangeMapper, issue);
            }
            dbSession.commit();
        }
    }
    return updated;
}
Also used : DbSession(org.sonar.db.DbSession) ArrayList(java.util.ArrayList) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) DefaultIssue(org.sonar.core.issue.DefaultIssue) IssueChangeMapper(org.sonar.db.issue.IssueChangeMapper)

Example 7 with DefaultIssue

use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.

the class SearchResponseLoader method loadActionsAndTransitions.

private void loadActionsAndTransitions(Collector collector, SearchResponseData result) {
    if (collector.contains(ACTIONS) || collector.contains(TRANSITIONS)) {
        for (IssueDto dto : result.getIssues()) {
            // so that IssueDto can be used.
            if (collector.contains(ACTIONS)) {
                result.addActions(dto.getKey(), actionService.listAvailableActions(dto));
            }
            if (collector.contains(TRANSITIONS)) {
                // TODO workflow and action engines must not depend on org.sonar.api.issue.Issue but on a generic interface
                DefaultIssue issue = dto.toDefaultIssue();
                result.addTransitions(issue.key(), transitionService.listTransitions(issue));
            }
        }
    }
}
Also used : IssueDto(org.sonar.db.issue.IssueDto) DefaultIssue(org.sonar.core.issue.DefaultIssue)

Example 8 with DefaultIssue

use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.

the class MeasureComputerContextImplTest method get_issues.

@Test
public void get_issues() throws Exception {
    DefaultIssue issue = new DefaultIssue().setKey("KEY").setRuleKey(RuleKey.of("xoo", "S01")).setSeverity("MAJOR").setStatus("CLOSED").setResolution("FIXED").setEffort(Duration.create(10l));
    MeasureComputerContextImpl underTest = newContext(PROJECT_REF, Arrays.asList(issue));
    assertThat(underTest.getIssues()).hasSize(1);
    org.sonar.api.ce.measure.Issue result = underTest.getIssues().get(0);
    assertThat(result.key()).isEqualTo("KEY");
    assertThat(result.ruleKey()).isEqualTo(RuleKey.of("xoo", "S01"));
    assertThat(result.severity()).isEqualTo("MAJOR");
    assertThat(result.status()).isEqualTo("CLOSED");
    assertThat(result.resolution()).isEqualTo("FIXED");
    assertThat(result.debt()).isEqualTo(Duration.create(10l));
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 9 with DefaultIssue

use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.

the class DebtCalculatorTest method no_debt_if_function_is_not_defined.

@Test
public void no_debt_if_function_is_not_defined() {
    DefaultIssue issue = new DefaultIssue().setRuleKey(rule.getKey());
    assertThat(underTest.calculate(issue)).isNull();
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 10 with DefaultIssue

use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.

the class DebtCalculatorTest method no_debt_if_no_sqale_characteristic.

@Test
public void no_debt_if_no_sqale_characteristic() {
    rule.setFunction(null);
    DefaultIssue issue = new DefaultIssue().setRuleKey(rule.getKey());
    assertThat(underTest.calculate(issue)).isNull();
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Aggregations

DefaultIssue (org.sonar.core.issue.DefaultIssue)140 Test (org.junit.Test)120 Date (java.util.Date)27 ActiveRule (org.sonar.server.computation.task.projectanalysis.qualityprofile.ActiveRule)15 IssueChangeContext (org.sonar.core.issue.IssueChangeContext)14 DefaultIssueComment (org.sonar.core.issue.DefaultIssueComment)8 IssueDto (org.sonar.db.issue.IssueDto)8 DbSession (org.sonar.db.DbSession)6 ComponentDto (org.sonar.db.component.ComponentDto)5 Issue (org.sonar.api.issue.Issue)4 FieldDiffs (org.sonar.core.issue.FieldDiffs)4 ArrayList (java.util.ArrayList)3 RuleKey (org.sonar.api.rule.RuleKey)3 User (org.sonar.api.user.User)3 IssueChangeMapper (org.sonar.db.issue.IssueChangeMapper)3 IssueMapper (org.sonar.db.issue.IssueMapper)3 RuleDto (org.sonar.db.rule.RuleDto)3 IssueChangeNotification (org.sonar.server.issue.notification.IssueChangeNotification)3 DefaultUser (org.sonar.core.user.DefaultUser)2 RuleTesting.newRuleDto (org.sonar.db.rule.RuleTesting.newRuleDto)2