use of org.sonar.java.DefaultJavaResourceLocator in project sonar-java by SonarSource.
the class JavaSquidSensorTest method testIssueCreation.
private void testIssueCreation(InputFile.Type onType, int expectedIssues) throws IOException {
MapSettings settings = new MapSettings();
NoSonarFilter noSonarFilter = mock(NoSonarFilter.class);
SensorContextTester context = createContext(onType).setRuntime(SonarRuntimeImpl.forSonarLint(Version.create(6, 7)));
DefaultFileSystem fs = context.fileSystem();
SonarComponents sonarComponents = createSonarComponentsMock(context);
DefaultJavaResourceLocator javaResourceLocator = new DefaultJavaResourceLocator(fs, new JavaClasspath(settings.asConfig(), fs));
PostAnalysisIssueFilter postAnalysisIssueFilter = new PostAnalysisIssueFilter(fs);
JavaSquidSensor jss = new JavaSquidSensor(sonarComponents, fs, javaResourceLocator, settings.asConfig(), noSonarFilter, postAnalysisIssueFilter);
jss.execute(context);
verify(noSonarFilter, times(1)).noSonarInFile(fs.inputFiles().iterator().next(), Sets.newHashSet(96));
verify(sonarComponents, times(expectedIssues)).reportIssue(any(AnalyzerMessage.class));
settings.setProperty(Java.SOURCE_VERSION, "wrongFormat");
jss.execute(context);
settings.setProperty(Java.SOURCE_VERSION, "1.7");
jss.execute(context);
}
use of org.sonar.java.DefaultJavaResourceLocator in project sonar-java by SonarSource.
the class JavaSquidSensorTest method executeJavaSquidSensor.
private void executeJavaSquidSensor(SensorContextTester context) {
context.setRuntime(SonarRuntimeImpl.forSonarQube(Version.create(6, 7), SonarQubeSide.SCANNER));
// Mock visitor for metrics.
FileLinesContext fileLinesContext = mock(FileLinesContext.class);
FileLinesContextFactory fileLinesContextFactory = mock(FileLinesContextFactory.class);
when(fileLinesContextFactory.createFor(any(InputFile.class))).thenReturn(fileLinesContext);
DefaultFileSystem fs = context.fileSystem().setWorkDir(tmp.getRoot().toPath());
JavaClasspath javaClasspath = mock(JavaClasspath.class);
JavaTestClasspath javaTestClasspath = mock(JavaTestClasspath.class);
SonarComponents sonarComponents = new SonarComponents(fileLinesContextFactory, fs, javaClasspath, javaTestClasspath, checkFactory);
DefaultJavaResourceLocator javaResourceLocator = mock(DefaultJavaResourceLocator.class);
NoSonarFilter noSonarFilter = mock(NoSonarFilter.class);
PostAnalysisIssueFilter postAnalysisIssueFilter = new PostAnalysisIssueFilter(fs);
JavaSquidSensor jss = new JavaSquidSensor(sonarComponents, fs, javaResourceLocator, new MapSettings().asConfig(), noSonarFilter, postAnalysisIssueFilter);
jss.execute(context);
}
Aggregations