Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions its/plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,38 @@
<maven.test.redirectTestOutputToFile>false</maven.test.redirectTestOutputToFile>
</properties>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.sonarsource.sonarlint.core</groupId>
<artifactId>sonarlint-core-test-utils</artifactId>
<version>${sonarlint.plugin.api.version}</version>
<scope>test</scope>
</dependency>
<!-- sonarlint-core requires slf4j 2.x at runtime; override the parent's 1.7 management for this module. -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.test.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.3.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>it-plugin</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
Struts139Test.class,
JavaClasspathTest.class,
SuppressWarningTest.class,
SonarLintTest.class,
SonarLintIntegrationTest.class,
ExternalReportTest.class,
DuplicationTest.class,
MultiModuleTelemetryTest.class
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* SonarQube Java
* Copyright (C) SonarSource Sàrl
* mailto:info AT sonarsource DOT com
*
* You can redistribute and/or modify this program under the terms of
* the Sonar Source-Available License Version 1, as published by SonarSource Sàrl.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Sonar Source-Available License for more details.
*
* You should have received a copy of the Sonar Source-Available License
* along with this program; if not, see https://sonarsource.com/license/ssal/
*/
package com.sonar.it.java.suite;

import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.analysis.AnalyzeFilesAndTrackParams;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.analysis.AnalyzeFilesResponse;
import org.sonarsource.sonarlint.core.rpc.protocol.client.issue.RaisedIssueDto;
import org.sonarsource.sonarlint.core.rpc.protocol.common.ClientFileDto;
import org.sonarsource.sonarlint.core.rpc.protocol.common.Language;
import org.sonarsource.sonarlint.core.test.utils.SonarLintBackendFixture;
import org.sonarsource.sonarlint.core.test.utils.SonarLintTestRpcServer;
import org.sonarsource.sonarlint.core.test.utils.junit5.SonarLintTest;
import org.sonarsource.sonarlint.core.test.utils.junit5.SonarLintTestHarness;
import org.sonarsource.sonarlint.core.test.utils.plugins.Plugin;

import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.junit.Assert.fail;

public class SonarLintIntegrationTest {
private static final String CONFIG_SCOPE_ID = "CONFIG_SCOPE_ID";

private static Path pluginPath;

private SonarLintBackendFixture.FakeSonarLintRpcClient client;
private SonarLintTestRpcServer backend;

@SonarLintTest
void test() {
fail("fail () in SLIT");
}

private List<RaisedIssueDto> analyzeFileAndGetIssues(URI fileUri) {

Check warning on line 56 in its/plugin/tests/src/test/java/com/sonar/it/java/suite/SonarLintIntegrationTest.java

View check run for this annotation

SonarQube-Next / SonarQube Code Analysis

Remove this unused private "analyzeFileAndGetIssues" method.

[S1144] Unused "private" methods should be removed See more on https://next.sonarqube.com/sonarqube/project/issues?id=org.sonarsource.java%3Ajava&pullRequest=5621&issues=4b3ccc76-bb61-4b59-9d96-ebe51e7594b4&open=4b3ccc76-bb61-4b59-9d96-ebe51e7594b4
UUID analysisId = UUID.randomUUID();
AnalyzeFilesAndTrackParams params = new AnalyzeFilesAndTrackParams(CONFIG_SCOPE_ID, analysisId, List.of(fileUri), Map.of(), false);
AnalyzeFilesResponse analysisResult =
backend
.getAnalysisService()
.analyzeFilesAndTrack(params)
.join();
assertThat(analysisResult.getFailedAnalysisFiles()).isEmpty();
await()
.atMost(15, TimeUnit.SECONDS)
.untilAsserted(() -> assertThat(client.getRaisedIssuesForScopeIdAsList(CONFIG_SCOPE_ID)).isNotEmpty());
return client.getRaisedIssuesForScopeId(CONFIG_SCOPE_ID).get(fileUri);
}

private void initWithFiles(SonarLintTestHarness harness, Path baseDir, ClientFileDto fileDTOs) {

Check warning on line 71 in its/plugin/tests/src/test/java/com/sonar/it/java/suite/SonarLintIntegrationTest.java

View check run for this annotation

SonarQube-Next / SonarQube Code Analysis

Remove this unused private "initWithFiles" method.

[S1144] Unused "private" methods should be removed See more on https://next.sonarqube.com/sonarqube/project/issues?id=org.sonarsource.java%3Ajava&pullRequest=5621&issues=4bc4fe1d-2a66-4ba1-b7ae-d61a04254192&open=4bc4fe1d-2a66-4ba1-b7ae-d61a04254192
client = harness
.newFakeClient()
.withInitialFs(CONFIG_SCOPE_ID, baseDir, List.of(fileDTOs))
.build();

backend = harness
.newBackend()
.withStandaloneEmbeddedPluginAndEnabledLanguage(new Plugin(Set.of(Language.RUBY), pluginPath, "", ""))
.withUnboundConfigScope(CONFIG_SCOPE_ID)
.start(client);
}

private static ClientFileDto createFile(Path folderPath, String fileName, String content) throws IOException {

Check warning on line 84 in its/plugin/tests/src/test/java/com/sonar/it/java/suite/SonarLintIntegrationTest.java

View check run for this annotation

SonarQube-Next / SonarQube Code Analysis

Remove this unused private "createFile" method.

[S1144] Unused "private" methods should be removed See more on https://next.sonarqube.com/sonarqube/project/issues?id=org.sonarsource.java%3Ajava&pullRequest=5621&issues=d41f69fd-6309-40b8-8207-6cd5ffc5cf2d&open=d41f69fd-6309-40b8-8207-6cd5ffc5cf2d
Path filePath = folderPath.resolve(fileName);
Files.writeString(filePath, content);
return new ClientFileDto(
filePath.toUri(), folderPath.relativize(filePath), CONFIG_SCOPE_ID, false, null, filePath, null, Language.RUBY, true);
}
}
Loading
Loading