import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
+import org.assertj.core.groups.Tuple;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.issue.Issue;
-import org.sonar.db.component.ComponentQualifiers;
+import org.sonar.api.issue.impact.Severity;
+import org.sonar.api.issue.impact.SoftwareQuality;
import org.sonar.api.utils.System2;
import org.sonar.db.DbTester;
import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentQualifiers;
import org.sonar.db.component.ProjectData;
-import org.sonar.server.component.ComponentTypesRule;
+import org.sonar.db.issue.ImpactDto;
import org.sonar.db.issue.IssueDbTester;
import org.sonar.db.issue.IssueDto;
import org.sonar.db.project.ProjectDto;
import org.sonar.db.rule.RuleDto;
import org.sonar.db.user.UserDto;
import org.sonar.server.component.ComponentFinder;
+import org.sonar.server.component.ComponentTypesRule;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.issue.TaintChecker;
.setIssueCreationTime(NOW)
.setStatus(Issue.STATUS_RESOLVED)
.setLocations(mainLocation.build())
- .setType(Common.RuleType.BUG.getNumber()));
+ .setType(Common.RuleType.BUG.getNumber())
+ .replaceAllImpacts(List.of(new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.MEDIUM))));
loginWithBrowsePermission(issueDto);
TestRequest request = tester.newRequest()
assertThat(issueLite.getResolved()).isTrue();
assertThat(issueLite.getRuleKey()).isEqualTo("java:S1000");
assertThat(issueLite.getType()).isEqualTo(Common.RuleType.forNumber(issueDto.getType()));
+ assertThat(issueLite.getImpactsList()).extracting(Common.Impact::getSoftwareQuality, Common.Impact::getSeverity)
+ .containsExactly(Tuple.tuple(Common.SoftwareQuality.MAINTAINABILITY, Common.ImpactSeverity.MEDIUM));
Issues.Location location = issueLite.getMainLocation();
assertThat(location.getMessage()).isEqualTo(issueDto.getMessage());
.setComponent(correctFile)
.setType(2));
- //this one should not be returned - it is a different rule repository
+ // this one should not be returned - it is a different rule repository
issueDbTester.insertIssue(p -> p.setSeverity("MINOR")
.setManualSeverity(true)
.setMessage("openIssue")
package org.sonar.server.issue.ws.pull;
import org.sonar.api.server.ServerSide;
+import org.sonar.core.rule.ImpactFormatter;
import org.sonar.db.issue.IssueDto;
import org.sonar.db.protobuf.DbIssues;
import org.sonar.db.rule.RuleDto;
issueBuilder.setType(Common.RuleType.forNumber(issueDto.getType()));
issueBuilder.setClosed(false);
issueBuilder.setMainLocation(location);
+ issueBuilder.addAllImpacts(issueDto.getEffectiveImpacts().entrySet()
+ .stream().map(entry -> Common.Impact.newBuilder()
+ .setSoftwareQuality(Common.SoftwareQuality.valueOf(entry.getKey().name()))
+ .setSeverity(ImpactFormatter.mapImpactSeverity(entry.getValue()))
+ .build())
+ .toList());
return issueBuilder.build();
}
// Response of GET api/issues/search
message SearchWsResponse {
reserved 5;
- optional int64 total = 1 [deprecated=true];
- optional int64 p = 2 [deprecated=true];
- optional int32 ps = 3 [deprecated=true];
+ optional int64 total = 1 [deprecated = true];
+ optional int64 p = 2 [deprecated = true];
+ optional int32 ps = 3 [deprecated = true];
optional sonarqube.ws.commons.Paging paging = 4;
// Total amount of effort, only when the facet "total" is enabled
optional sonarqube.ws.commons.RuleType type = 6;
optional Location mainLocation = 7;
optional bool closed = 8;
+ repeated sonarqube.ws.commons.Impact impacts = 9;
}