use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class SearchResponseFormat method formatIssues.
private List<Issues.Issue> formatIssues(Set<SearchAdditionalField> fields, SearchResponseData data) {
List<Issues.Issue> result = new ArrayList<>();
Issues.Issue.Builder issueBuilder = Issues.Issue.newBuilder();
for (IssueDto dto : data.getIssues()) {
issueBuilder.clear();
formatIssue(issueBuilder, dto, data);
if (fields.contains(SearchAdditionalField.ACTIONS)) {
formatIssueActions(data, issueBuilder, dto);
}
if (fields.contains(SearchAdditionalField.TRANSITIONS)) {
formatIssueTransitions(data, issueBuilder, dto);
}
if (fields.contains(SearchAdditionalField.COMMENTS)) {
formatIssueComments(data, issueBuilder, dto);
}
result.add(issueBuilder.build());
}
return result;
}
use of org.sonar.db.issue.IssueDto 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.db.issue.IssueDto in project sonarqube by SonarSource.
the class IntegrateIssuesVisitorTest method addBaseIssue.
private void addBaseIssue(RuleKey ruleKey) {
ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert(), PROJECT_UUID).setKey(PROJECT_KEY);
ComponentDto file = ComponentTesting.newFileDto(project, null, FILE_UUID).setKey(FILE_KEY);
dbTester.getDbClient().componentDao().insert(dbTester.getSession(), project, file);
RuleDto ruleDto = RuleTesting.newDto(ruleKey);
dbTester.getDbClient().ruleDao().insert(dbTester.getSession(), ruleDto);
ruleRepositoryRule.add(ruleKey);
IssueDto issue = IssueTesting.newDto(ruleDto, file, project).setKee("ISSUE").setStatus(Issue.STATUS_OPEN).setSeverity(Severity.MAJOR);
dbTester.getDbClient().issueDao().insert(dbTester.getSession(), issue);
dbTester.getSession().commit();
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class UpdateConflictResolverTest method should_keep_changes_made_by_user.
@Test
public void should_keep_changes_made_by_user() {
DefaultIssue issue = new DefaultIssue().setKey("ABCDE").setRuleKey(RuleKey.of("squid", "AvoidCycles")).setComponentKey("struts:org.apache.struts.Action").setNew(false);
// Before starting scan
issue.setAssignee(null);
issue.setCreationDate(DateUtils.parseDate("2012-01-01"));
issue.setUpdateDate(DateUtils.parseDate("2012-02-02"));
// Changed by scan
issue.setLine(200);
issue.setSeverity(Severity.BLOCKER);
issue.setManualSeverity(false);
issue.setAuthorLogin("simon");
issue.setChecksum("CHECKSUM-ABCDE");
issue.setResolution(null);
issue.setStatus(Issue.STATUS_REOPENED);
// Issue as seen and changed by end-user
IssueDto dbIssue = new IssueDto().setKee("ABCDE").setRuleId(10).setRuleKey("squid", "AvoidCycles").setComponentUuid("100").setComponentKey("struts:org.apache.struts.Action").setLine(10).setResolution(Issue.RESOLUTION_FALSE_POSITIVE).setStatus(Issue.STATUS_RESOLVED).setAssignee("arthur").setSeverity(Severity.MAJOR).setManualSeverity(false);
new UpdateConflictResolver().mergeFields(dbIssue, issue);
assertThat(issue.key()).isEqualTo("ABCDE");
assertThat(issue.componentKey()).isEqualTo("struts:org.apache.struts.Action");
// Scan wins on :
assertThat(issue.line()).isEqualTo(200);
assertThat(issue.severity()).isEqualTo(Severity.BLOCKER);
assertThat(issue.manualSeverity()).isFalse();
// User wins on :
assertThat(issue.assignee()).isEqualTo("arthur");
assertThat(issue.resolution()).isEqualTo(Issue.RESOLUTION_FALSE_POSITIVE);
assertThat(issue.status()).isEqualTo(Issue.STATUS_RESOLVED);
}
use of org.sonar.db.issue.IssueDto 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());
}
Aggregations