use of org.sonar.scanner.protocol.input.ScannerInput.ServerIssue in project sonarqube by SonarSource.
the class IssuesActionTest method project_issues_attached_file_on_removed_module.
@Test
public void project_issues_attached_file_on_removed_module() throws Exception {
ComponentDto project = ComponentTesting.newProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY);
// File and module are removed
ComponentDto module = ComponentTesting.newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY).setEnabled(false);
ComponentDto file = ComponentTesting.newFileDto(module, null, FILE_UUID).setKey(FILE_KEY).setPath("src/org/struts/Action.java").setEnabled(false);
db.getDbClient().componentDao().insert(db.getSession(), project, module, file);
db.getSession().commit();
indexIssues(IssueDocTesting.newDoc("EFGH", file).setRuleKey("squid:AvoidCycle").setSeverity("BLOCKER").setStatus("RESOLVED").setResolution("FALSE-POSITIVE").setManualSeverity(false).setMessage("Do not use this method").setLine(200).setChecksum("123456").setAssignee("john"));
addBrowsePermissionOnComponent(project);
WsTester.TestRequest request = tester.newGetRequest("batch", "issues").setParam("key", PROJECT_KEY);
ServerIssue serverIssue = ServerIssue.parseDelimitedFrom(new ByteArrayInputStream(request.execute().output()));
assertThat(serverIssue.getKey()).isEqualTo("EFGH");
// Module key of removed file should be returned
assertThat(serverIssue.getModuleKey()).isEqualTo(MODULE_KEY);
}
use of org.sonar.scanner.protocol.input.ScannerInput.ServerIssue in project sonarlint-core by SonarSource.
the class PartialUpdater method updateFileIssues.
public void updateFileIssues(String moduleKey, String filePath) {
Path serverIssuesPath = storagePaths.getServerIssuesPath(moduleKey);
IssueStore issueStore = issueStoreFactory.apply(serverIssuesPath);
String fileKey = issueStoreReader.getFileKey(moduleKey, filePath);
List<ServerIssue> issues;
try {
issues = downloader.apply(fileKey);
} catch (Exception e) {
// null as cause so that it doesn't get wrapped
throw new DownloadException("Failed to update file issues: " + e.getMessage(), null);
}
issueStore.save(issues);
}
use of org.sonar.scanner.protocol.input.ScannerInput.ServerIssue in project sonarqube by SonarSource.
the class IssuesActionTest method issues_from_project.
@Test
public void issues_from_project() throws Exception {
OrganizationDto organizationDto = db.organizations().insert();
ComponentDto project = ComponentTesting.newProjectDto(organizationDto, PROJECT_UUID).setKey(PROJECT_KEY);
ComponentDto module = ComponentTesting.newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY);
ComponentDto file = ComponentTesting.newFileDto(module, null, FILE_UUID).setKey(FILE_KEY).setPath("src/org/struts/Action.java");
db.getDbClient().componentDao().insert(db.getSession(), project, module, file);
db.getSession().commit();
indexIssues(IssueDocTesting.newDoc("EFGH", file).setRuleKey("squid:AvoidCycle").setSeverity("BLOCKER").setStatus("RESOLVED").setResolution("FALSE-POSITIVE").setManualSeverity(false).setMessage("Do not use this method").setLine(200).setChecksum("123456").setAssignee("john"));
addBrowsePermissionOnComponent(project);
WsTester.TestRequest request = tester.newGetRequest("batch", "issues").setParam("key", PROJECT_KEY);
ServerIssue serverIssue = ServerIssue.parseDelimitedFrom(new ByteArrayInputStream(request.execute().output()));
assertThat(serverIssue.getKey()).isEqualTo("EFGH");
assertThat(serverIssue.getModuleKey()).isEqualTo(MODULE_KEY);
assertThat(serverIssue.getPath()).isEqualTo("src/org/struts/Action.java");
assertThat(serverIssue.getRuleRepository()).isEqualTo("squid");
assertThat(serverIssue.getRuleKey()).isEqualTo("AvoidCycle");
assertThat(serverIssue.getLine()).isEqualTo(200);
assertThat(serverIssue.getMsg()).isEqualTo("Do not use this method");
assertThat(serverIssue.getResolution()).isEqualTo("FALSE-POSITIVE");
assertThat(serverIssue.getStatus()).isEqualTo("RESOLVED");
assertThat(serverIssue.getSeverity()).isEqualTo(Severity.BLOCKER);
assertThat(serverIssue.getManualSeverity()).isFalse();
assertThat(serverIssue.getChecksum()).isEqualTo("123456");
assertThat(serverIssue.getAssigneeLogin()).isEqualTo("john");
}
use of org.sonar.scanner.protocol.input.ScannerInput.ServerIssue in project sonarqube by SonarSource.
the class IssuesActionTest method issues_from_module.
@Test
public void issues_from_module() throws Exception {
ComponentDto project = ComponentTesting.newProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY);
ComponentDto module = ComponentTesting.newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY);
ComponentDto file = ComponentTesting.newFileDto(module, null, FILE_UUID).setKey(FILE_KEY).setPath("src/org/struts/Action.java");
db.getDbClient().componentDao().insert(db.getSession(), project, module, file);
db.getSession().commit();
indexIssues(IssueDocTesting.newDoc("EFGH", file).setRuleKey("squid:AvoidCycle").setSeverity("BLOCKER").setStatus("RESOLVED").setResolution("FALSE-POSITIVE").setManualSeverity(false).setMessage("Do not use this method").setLine(200).setChecksum("123456").setAssignee("john"));
addBrowsePermissionOnComponent(project);
WsTester.TestRequest request = tester.newGetRequest("batch", "issues").setParam("key", PROJECT_KEY);
ServerIssue serverIssue = ServerIssue.parseDelimitedFrom(new ByteArrayInputStream(request.execute().output()));
assertThat(serverIssue.getKey()).isEqualTo("EFGH");
assertThat(serverIssue.getModuleKey()).isEqualTo(MODULE_KEY);
assertThat(serverIssue.getPath()).isEqualTo("src/org/struts/Action.java");
assertThat(serverIssue.getRuleRepository()).isEqualTo("squid");
assertThat(serverIssue.getRuleKey()).isEqualTo("AvoidCycle");
assertThat(serverIssue.getLine()).isEqualTo(200);
assertThat(serverIssue.getMsg()).isEqualTo("Do not use this method");
assertThat(serverIssue.getResolution()).isEqualTo("FALSE-POSITIVE");
assertThat(serverIssue.getStatus()).isEqualTo("RESOLVED");
assertThat(serverIssue.getSeverity()).isEqualTo(Severity.BLOCKER);
assertThat(serverIssue.getManualSeverity()).isFalse();
assertThat(serverIssue.getChecksum()).isEqualTo("123456");
assertThat(serverIssue.getAssigneeLogin()).isEqualTo("john");
}
use of org.sonar.scanner.protocol.input.ScannerInput.ServerIssue in project sonarqube by SonarSource.
the class IssuesActionTest method issues_from_file.
@Test
public void issues_from_file() throws Exception {
ComponentDto project = ComponentTesting.newProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY);
ComponentDto module = ComponentTesting.newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY);
ComponentDto file = ComponentTesting.newFileDto(module, null, FILE_UUID).setKey(FILE_KEY).setPath("src/org/struts/Action.java");
db.getDbClient().componentDao().insert(db.getSession(), project, module, file);
db.getSession().commit();
indexIssues(IssueDocTesting.newDoc("EFGH", file).setRuleKey("squid:AvoidCycle").setSeverity("BLOCKER").setStatus("RESOLVED").setResolution("FALSE-POSITIVE").setManualSeverity(false).setMessage("Do not use this method").setLine(200).setChecksum("123456").setAssignee("john"));
addBrowsePermissionOnComponent(project);
WsTester.TestRequest request = tester.newGetRequest("batch", "issues").setParam("key", FILE_KEY);
ServerIssue serverIssue = ServerIssue.parseDelimitedFrom(new ByteArrayInputStream(request.execute().output()));
assertThat(serverIssue.getKey()).isEqualTo("EFGH");
assertThat(serverIssue.getModuleKey()).isEqualTo(MODULE_KEY);
assertThat(serverIssue.getPath()).isEqualTo("src/org/struts/Action.java");
assertThat(serverIssue.getRuleRepository()).isEqualTo("squid");
assertThat(serverIssue.getRuleKey()).isEqualTo("AvoidCycle");
assertThat(serverIssue.getLine()).isEqualTo(200);
assertThat(serverIssue.getMsg()).isEqualTo("Do not use this method");
assertThat(serverIssue.getResolution()).isEqualTo("FALSE-POSITIVE");
assertThat(serverIssue.getStatus()).isEqualTo("RESOLVED");
assertThat(serverIssue.getSeverity()).isEqualTo(Severity.BLOCKER);
assertThat(serverIssue.getManualSeverity()).isFalse();
assertThat(serverIssue.getChecksum()).isEqualTo("123456");
assertThat(serverIssue.getAssigneeLogin()).isEqualTo("john");
}
Aggregations