use of org.sonar.java.JavaTestClasspath in project sonar-java by SonarSource.
the class JavaSquidSensorTest method createSonarComponentsMock.
private static SonarComponents createSonarComponentsMock(SensorContextTester contextTester) {
Configuration settings = new MapSettings().asConfig();
DefaultFileSystem fs = contextTester.fileSystem();
JavaTestClasspath javaTestClasspath = new JavaTestClasspath(settings, fs);
JavaClasspath javaClasspath = new JavaClasspath(settings, fs);
FileLinesContext fileLinesContext = mock(FileLinesContext.class);
FileLinesContextFactory fileLinesContextFactory = mock(FileLinesContextFactory.class);
when(fileLinesContextFactory.createFor(any(InputFile.class))).thenReturn(fileLinesContext);
SonarComponents sonarComponents = spy(new SonarComponents(fileLinesContextFactory, fs, javaClasspath, javaTestClasspath, checkFactory));
sonarComponents.setSensorContext(contextTester);
BadMethodNameCheck check = new BadMethodNameCheck();
when(sonarComponents.checkClasses()).thenReturn(new JavaCheck[] { check });
return sonarComponents;
}
use of org.sonar.java.JavaTestClasspath 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