Search in sources :

Example 11 with ServerIssue

use of org.sonar.scanner.protocol.input.ScannerInput.ServerIssue in project sonarlint-core by SonarSource.

the class PartialUpdaterTest method update_file_issues_by_module.

@Test
public void update_file_issues_by_module() throws IOException {
    ServerIssue issue = ServerIssue.newBuilder().setKey("issue1").build();
    List<ServerIssue> issues = Collections.singletonList(issue);
    String moduleKey = "dummy";
    when(storagePaths.getServerIssuesPath(moduleKey)).thenReturn(temp.newFolder().toPath());
    when(downloader.apply(moduleKey)).thenReturn(issues);
    updater.updateFileIssues(moduleKey, new DefaultTempFolder(temp.newFolder()));
    verify(issueStore).save(issues);
}
Also used : DefaultTempFolder(org.sonar.api.utils.internal.DefaultTempFolder) ServerIssue(org.sonar.scanner.protocol.input.ScannerInput.ServerIssue) Test(org.junit.Test)

Example 12 with ServerIssue

use of org.sonar.scanner.protocol.input.ScannerInput.ServerIssue in project sonarlint-core by SonarSource.

the class PartialUpdaterTest method update_file_issues.

@Test
public void update_file_issues() {
    ServerIssue issue = ServerIssue.newBuilder().setKey("issue1").build();
    List<ServerIssue> issues = Collections.singletonList(issue);
    when(storagePaths.getServerIssuesPath("module")).thenReturn(temp.getRoot().toPath());
    when(issueStoreReader.getFileKey("module", "file")).thenReturn("module:file");
    when(downloader.apply("module:file")).thenReturn(issues);
    updater.updateFileIssues("module", "file");
    verify(issueStore).save(issues);
}
Also used : ServerIssue(org.sonar.scanner.protocol.input.ScannerInput.ServerIssue) Test(org.junit.Test)

Example 13 with ServerIssue

use of org.sonar.scanner.protocol.input.ScannerInput.ServerIssue in project sonarlint-core by SonarSource.

the class ServerIssueStoreTest method should_read_object_replaced.

@Test
public void should_read_object_replaced() throws IOException {
    ServerIssueStore store = new ServerIssueStore(temporaryFolder.getRoot().toPath());
    String path = "myfile";
    String moduleKey = "module";
    ServerIssue issue1 = ServerIssue.newBuilder().setPath(path).setModuleKey(moduleKey).setLine(11).build();
    ServerIssue issue2 = ServerIssue.newBuilder().setPath(path).setModuleKey(moduleKey).setLine(22).build();
    store.save(Collections.singletonList(issue1));
    assertThat(store.load("module:myfile")).containsOnly(issue1);
    store.save(Collections.singletonList(issue2));
    assertThat(store.load("module:myfile")).containsOnly(issue2);
}
Also used : 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