use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class IssuesActionTest method return_issues_of_file.
@Test
public void return_issues_of_file() {
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 issueOnFile = db.issues().insert(rule, project, file, i -> i.setType(randomRuleTypeExceptHotspot()));
IssueDto issueOnModule = db.issues().insert(rule, project, module, i -> i.setType(randomRuleTypeExceptHotspot()));
IssueDto issueOnProject = db.issues().insert(rule, project, project, i -> i.setType(randomRuleTypeExceptHotspot()));
addPermissionTo(project);
try (CloseableIterator<ServerIssue> result = callStream(file.getKey(), null)) {
assertThat(result).toIterable().extracting(ServerIssue::getKey, ServerIssue::getModuleKey).containsExactlyInAnyOrder(tuple(issueOnFile.getKey(), module.getKey()));
}
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class IssuesActionTest method does_not_return_issues_from_external_rules.
@Test
public void does_not_return_issues_from_external_rules() {
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 issueOnProject = db.issues().insert(rule, project, project, i -> i.setKee("ON_PROJECT").setType(randomRuleTypeExceptHotspot()));
IssueDto issueOnModule = db.issues().insert(rule, project, module, i -> i.setKee("ON_MODULE").setType(randomRuleTypeExceptHotspot()));
IssueDto issueOnFile = db.issues().insert(rule, project, file, i -> i.setKee("ON_FILE").setType(randomRuleTypeExceptHotspot()));
RuleDefinitionDto external = db.rules().insert(ruleDefinitionDto -> ruleDefinitionDto.setIsExternal(true));
IssueDto issueFromExteralruleOnFile = db.issues().insert(external, project, file, i -> i.setKee("ON_FILE_FROM_EXTERNAL").setType(randomRuleTypeExceptHotspot()));
RuleDefinitionDto migrated = db.rules().insert();
db.executeUpdateSql("update rules set is_external=? where rules.uuid = ?", false, migrated.getUuid());
IssueDto issueFromMigratedRule = db.issues().insert(migrated, project, file, i -> i.setKee("MIGRATED").setType(randomRuleTypeExceptHotspot()));
addPermissionTo(project);
try (CloseableIterator<ServerIssue> result = callStream(project.getKey(), null)) {
assertThat(result).toIterable().extracting(ServerIssue::getKey, ServerIssue::getModuleKey).containsExactlyInAnyOrder(tuple(issueOnFile.getKey(), module.getKey()), tuple(issueOnModule.getKey(), module.getKey()), tuple(issueOnProject.getKey(), project.getKey()), tuple(issueFromMigratedRule.getKey(), module.getKey()));
}
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class IssuesActionTest method return_issues_by_module_and_branch.
@Test
public void return_issues_by_module_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 module = db.components().insertComponent(newModuleDto(branch));
ComponentDto subModule = db.components().insertComponent(newModuleDto(module));
ComponentDto file = db.components().insertComponent(newFileDto(subModule));
IssueDto issueOnFile = db.issues().insert(rule, branch, file, i -> i.setType(randomRuleTypeExceptHotspot()));
IssueDto issueOnSubModule = db.issues().insert(rule, branch, subModule, i -> i.setType(randomRuleTypeExceptHotspot()));
IssueDto issueOnModule = db.issues().insert(rule, branch, module, i -> i.setType(randomRuleTypeExceptHotspot()));
assertResult(module.getKey(), "my_branch", tuple(issueOnFile.getKey(), subModule.getKey()), tuple(issueOnSubModule.getKey(), subModule.getKey()), tuple(issueOnModule.getKey(), module.getKey()));
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class IssuesActionTest method test_nullable_fields.
@Test
public void test_nullable_fields() throws Exception {
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).setPath(null));
IssueDto issue = db.issues().insert(rule, project, file, i -> i.setSeverity("BLOCKER").setStatus("OPEN").setType(BUG).setManualSeverity(true).setResolution(null).setMessage(null).setLine(null).setChecksum(null).setAssigneeUuid(null));
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.hasPath()).isFalse();
assertThat(serverIssue.hasLine()).isFalse();
assertThat(serverIssue.hasMsg()).isFalse();
assertThat(serverIssue.hasResolution()).isFalse();
assertThat(serverIssue.hasChecksum()).isFalse();
assertThat(serverIssue.hasAssigneeLogin()).isFalse();
}
use of org.sonar.db.issue.IssueDto in project sonarqube by SonarSource.
the class IssuesActionTest method return_issues_of_project.
@Test
public void return_issues_of_project() {
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 issueOnFile = db.issues().insert(rule, project, file, i -> i.setKee("ON_FILE").setType(randomRuleTypeExceptHotspot()));
IssueDto issueOnModule = db.issues().insert(rule, project, module, i -> i.setKee("ON_MODULE").setType(randomRuleTypeExceptHotspot()));
IssueDto issueOnProject = db.issues().insert(rule, project, project, i -> i.setKee("ON_PROJECT").setType(randomRuleTypeExceptHotspot()));
addPermissionTo(project);
try (CloseableIterator<ServerIssue> result = callStream(project.getKey(), null)) {
assertThat(result).toIterable().extracting(ServerIssue::getKey, ServerIssue::getModuleKey).containsExactlyInAnyOrder(tuple(issueOnFile.getKey(), module.getKey()), tuple(issueOnModule.getKey(), module.getKey()), tuple(issueOnProject.getKey(), project.getKey()));
}
}
Aggregations