35
35
import org .junit .Test ;
36
36
import org .junit .rules .TemporaryFolder ;
37
37
import org .sonarsource .sonarlint .core .StandaloneSonarLintEngineImpl ;
38
- import org .sonarsource .sonarlint .core .client .api .common . Language ;
39
- import org .sonarsource .sonarlint .core .client .api .common . analysis . ClientInputFile ;
38
+ import org .sonarsource .sonarlint .core .analysis .api .ClientInputFile ;
39
+ import org .sonarsource .sonarlint .core .analysis .api .WithTextRange ;
40
40
import org .sonarsource .sonarlint .core .client .api .common .analysis .Issue ;
41
41
import org .sonarsource .sonarlint .core .client .api .standalone .StandaloneAnalysisConfiguration ;
42
42
import org .sonarsource .sonarlint .core .client .api .standalone .StandaloneGlobalConfiguration ;
43
43
import org .sonarsource .sonarlint .core .client .api .standalone .StandaloneSonarLintEngine ;
44
+ import org .sonarsource .sonarlint .core .commons .Language ;
44
45
45
46
import static org .assertj .core .api .Assertions .assertThat ;
46
47
import static org .assertj .core .api .Assertions .tuple ;
48
+ import static org .sonarsource .sonarlint .core .commons .IssueSeverity .MAJOR ;
47
49
48
50
public class SonarLintTest {
49
51
@@ -57,7 +59,7 @@ public class SonarLintTest {
57
59
@ BeforeClass
58
60
public static void prepare () throws Exception {
59
61
StandaloneGlobalConfiguration sonarLintConfig = StandaloneGlobalConfiguration .builder ()
60
- .addPlugin (FileLocation .byWildcardMavenFilename (new File ("../../sonar-html-plugin/target" ), "sonar-html-plugin-*.jar" ).getFile ().toURI (). toURL ())
62
+ .addPlugin (FileLocation .byWildcardMavenFilename (new File ("../../sonar-html-plugin/target" ), "sonar-html-plugin-*.jar" ).getFile ().toPath ())
61
63
.setSonarLintUserHome (temp .newFolder ().toPath ())
62
64
.addEnabledLanguage (Language .HTML )
63
65
.setLogOutput ((formattedMessage , level ) -> { /* Don't pollute logs */ })
@@ -88,11 +90,12 @@ public void should_raise_four_issues() throws IOException {
88
90
.build ();
89
91
sonarlintEngine .analyze (config , issues ::add , (s , level ) -> System .out .println (s ), null );
90
92
91
- assertThat (issues ).extracting ("ruleKey" , "startLine" , "inputFile.path" , "severity" ).containsOnly (
92
- tuple ("Web:DoctypePresenceCheck" , 1 , inputFile .getPath (), "MAJOR" ),
93
- tuple ("Web:S5254" , 1 , inputFile .getPath (), "MAJOR" ),
94
- tuple ("Web:LinkToImageCheck" , 3 , inputFile .getPath (), "MAJOR" ),
95
- tuple ("Web:PageWithoutTitleCheck" , 1 , inputFile .getPath (), "MAJOR" ));
93
+ assertThat (issues )
94
+ .extracting (Issue ::getRuleKey , WithTextRange ::getStartLine , i -> i .getInputFile ().getPath (), Issue ::getSeverity ).containsOnly (
95
+ tuple ("Web:DoctypePresenceCheck" , 1 , inputFile .getPath (), MAJOR ),
96
+ tuple ("Web:S5254" , 1 , inputFile .getPath (), MAJOR ),
97
+ tuple ("Web:LinkToImageCheck" , 3 , inputFile .getPath (), MAJOR ),
98
+ tuple ("Web:PageWithoutTitleCheck" , 1 , inputFile .getPath (), MAJOR ));
96
99
}
97
100
98
101
private ClientInputFile prepareInputFile (String relativePath , String content , final boolean isTest ) throws IOException {
0 commit comments