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;
}
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));
}
}
}
}
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));
}
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();
}
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();
}
Aggregations