use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class WebIssueStorage method doInsert.
private IssueDto doInsert(DbSession session, long now, DefaultIssue issue) {
ComponentDto component = component(session, issue);
ComponentDto project = project(session, issue);
String ruleUuid = getRuleUuid(issue).orElseThrow(() -> new IllegalStateException("Rule not found: " + issue.ruleKey()));
IssueDto dto = IssueDto.toDtoForServerInsert(issue, component, project, ruleUuid, now);
getDbClient().issueDao().insert(session, dto);
return dto;
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class WebIssueStorage method insert.
/**
* @return the keys of the inserted issues
*/
private Collection<IssueDto> insert(DbSession session, Iterable<DefaultIssue> issuesToInsert, long now) {
List<IssueDto> inserted = newArrayList();
int count = 0;
IssueChangeMapper issueChangeMapper = session.getMapper(IssueChangeMapper.class);
for (DefaultIssue issue : issuesToInsert) {
IssueDto issueDto = doInsert(session, now, issue);
inserted.add(issueDto);
insertChanges(issueChangeMapper, issue, uuidFactory);
if (count > BatchSession.MAX_BATCH_SIZE) {
session.commit();
count = 0;
}
count++;
}
session.commit();
return inserted;
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class WebIssueStorage method doUpdate.
private IssueDto doUpdate(DbSession session, long now, DefaultIssue issue) {
IssueDto dto = IssueDto.toDtoForUpdate(issue, now);
getDbClient().issueDao().update(session, dto);
// Rule id does not exist in DefaultIssue
getRuleUuid(issue).ifPresent(dto::setRuleUuid);
return dto;
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class IssuesActionTest method return_issues_by_project_and_branch.
@Test
public void return_issues_by_project_and_branch() {
RuleDefinitionDto rule = db.rules().insert();
ComponentDto project = db.components().insertPrivateProject();
addPermissionTo(project);
ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("my_branch"));
ComponentDto file = db.components().insertComponent(newFileDto(branch));
IssueDto issueOnFile = db.issues().insert(rule, branch, file, i -> i.setType(randomRuleTypeExceptHotspot()));
IssueDto issueOnBranch = db.issues().insert(rule, branch, branch, i -> i.setType(randomRuleTypeExceptHotspot()));
assertResult(project.getKey(), "my_branch", tuple(issueOnFile.getKey(), branch.getKey()), tuple(issueOnBranch.getKey(), branch.getKey()));
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class IssuesActionTest method test_fields_with_non_null_values.
@Test
public void test_fields_with_non_null_values() throws Exception {
UserDto user = db.users().insertUser(u -> u.setLogin("simon").setName("Simon").setEmail("simon@email.com"));
RuleDefinitionDto rule = db.rules().insert();
ComponentDto project = db.components().insertPrivateProject();
ComponentDto module = db.components().insertComponent(newModuleDto(project));
ComponentDto file = db.components().insertComponent(newFileDto(module, null));
IssueDto issue = db.issues().insert(rule, project, file, i -> i.setSeverity("BLOCKER").setStatus("OPEN").setType(BUG).setManualSeverity(true).setResolution("FIXED").setMessage("the message").setLine(10).setChecksum("ABC").setAssigneeUuid(user.getUuid()));
addPermissionTo(project);
ServerIssue serverIssue = call(project.getKey());
assertThat(serverIssue.getKey()).isEqualTo(issue.getKey());
assertThat(serverIssue.getModuleKey()).isEqualTo(module.getKey());
assertThat(serverIssue.getRuleRepository()).isEqualTo(rule.getRepositoryKey());
assertThat(serverIssue.getRuleKey()).isEqualTo(rule.getRuleKey());
assertThat(serverIssue.getStatus()).isEqualTo("OPEN");
assertThat(serverIssue.getSeverity()).isEqualTo(Severity.BLOCKER);
assertThat(serverIssue.getType()).isEqualTo(BUG.name());
assertThat(serverIssue.getManualSeverity()).isTrue();
assertThat(serverIssue.getPath()).isEqualTo(file.path());
assertThat(serverIssue.getLine()).isEqualTo(issue.getLine());
assertThat(serverIssue.getMsg()).isEqualTo(issue.getMessage());
assertThat(serverIssue.getResolution()).isEqualTo(issue.getResolution());
assertThat(serverIssue.getChecksum()).isEqualTo(issue.getChecksum());
assertThat(serverIssue.getAssigneeLogin()).isEqualTo(user.getLogin());
}
Aggregations