Search in sources :

Example 1 with ServerIssue

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);
}
Also used : WsTester(org.sonar.server.ws.WsTester) ByteArrayInputStream(java.io.ByteArrayInputStream) ComponentDto(org.sonar.db.component.ComponentDto) ServerIssue(org.sonar.scanner.protocol.input.ScannerInput.ServerIssue) Test(org.junit.Test)

Example 2 with ServerIssue

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);
}
Also used : Path(java.nio.file.Path) DownloadException(org.sonarsource.sonarlint.core.client.api.exceptions.DownloadException) IssueStore(org.sonarsource.sonarlint.core.container.connected.IssueStore) ServerIssue(org.sonar.scanner.protocol.input.ScannerInput.ServerIssue) DownloadException(org.sonarsource.sonarlint.core.client.api.exceptions.DownloadException)

Example 3 with ServerIssue

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");
}
Also used : WsTester(org.sonar.server.ws.WsTester) ByteArrayInputStream(java.io.ByteArrayInputStream) ComponentDto(org.sonar.db.component.ComponentDto) ServerIssue(org.sonar.scanner.protocol.input.ScannerInput.ServerIssue) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 4 with ServerIssue

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");
}
Also used : WsTester(org.sonar.server.ws.WsTester) ByteArrayInputStream(java.io.ByteArrayInputStream) ComponentDto(org.sonar.db.component.ComponentDto) ServerIssue(org.sonar.scanner.protocol.input.ScannerInput.ServerIssue) Test(org.junit.Test)

Example 5 with ServerIssue

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");
}
Also used : WsTester(org.sonar.server.ws.WsTester) ByteArrayInputStream(java.io.ByteArrayInputStream) ComponentDto(org.sonar.db.component.ComponentDto) ServerIssue(org.sonar.scanner.protocol.input.ScannerInput.ServerIssue) Test(org.junit.Test)

Aggregations

ServerIssue (org.sonar.scanner.protocol.input.ScannerInput.ServerIssue)13 Test (org.junit.Test)10 ByteArrayInputStream (java.io.ByteArrayInputStream)7 ComponentDto (org.sonar.db.component.ComponentDto)6 WsTester (org.sonar.server.ws.WsTester)6 OrganizationDto (org.sonar.db.organization.OrganizationDto)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 DefaultTempFolder (org.sonar.api.utils.internal.DefaultTempFolder)1 DownloadException (org.sonarsource.sonarlint.core.client.api.exceptions.DownloadException)1 IssueStore (org.sonarsource.sonarlint.core.container.connected.IssueStore)1