Search in sources :

Example 1 with PomElementOrderCheck

use of org.sonar.java.checks.xml.maven.PomElementOrderCheck in project sonar-java by SonarSource.

the class XmlFileSensorTest method createSonarComponentsMock.

private static SonarComponents createSonarComponentsMock(DefaultFileSystem fs, @Nullable File file) throws IOException {
    SonarComponents sonarComponents = mock(SonarComponents.class);
    when(sonarComponents.checkClasses()).thenReturn(new JavaCheck[] { new PomElementOrderCheck() });
    when(sonarComponents.getFileSystem()).thenReturn(fs);
    if (file != null) {
        when(sonarComponents.fileLines(any(File.class))).thenReturn(Files.readLines(file, StandardCharsets.UTF_8));
    }
    Checks<JavaCheck> checks = mock(Checks.class);
    when(checks.ruleKey(any(JavaCheck.class))).thenReturn(RuleKey.of("squid", RuleAnnotationUtils.getRuleKey(PomElementOrderCheck.class)));
    when(sonarComponents.checks()).thenReturn(Lists.<Checks<JavaCheck>>newArrayList(checks));
    return sonarComponents;
}
Also used : SonarComponents(org.sonar.java.SonarComponents) JavaCheck(org.sonar.plugins.java.api.JavaCheck) PomElementOrderCheck(org.sonar.java.checks.xml.maven.PomElementOrderCheck) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) File(java.io.File)

Aggregations

File (java.io.File)1 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)1 SonarComponents (org.sonar.java.SonarComponents)1 PomElementOrderCheck (org.sonar.java.checks.xml.maven.PomElementOrderCheck)1 JavaCheck (org.sonar.plugins.java.api.JavaCheck)1