Search in sources :

Example 16 with PathResolver

use of org.sonar.api.scan.filesystem.PathResolver in project sonarqube by SonarSource.

the class ModuleIndexerTest method setUp.

@Before
public void setUp() {
    reactor = mock(ImmutableProjectReactor.class);
    componentStore = new InputComponentStore(new PathResolver());
    tree = new DefaultComponentTree();
    moduleHierarchy = new DefaultInputModuleHierarchy();
    indexer = new ModuleIndexer(reactor, tree, componentStore, new BatchIdGenerator(), moduleHierarchy);
}
Also used : InputComponentStore(org.sonar.scanner.scan.filesystem.InputComponentStore) BatchIdGenerator(org.sonar.scanner.scan.filesystem.BatchIdGenerator) PathResolver(org.sonar.api.scan.filesystem.PathResolver) Before(org.junit.Before)

Example 17 with PathResolver

use of org.sonar.api.scan.filesystem.PathResolver in project sonar-java by SonarSource.

the class SurefireUtilsTest method should_get_reports_path_from_deprecated_property.

@Test
public void should_get_reports_path_from_deprecated_property() {
    MapSettings settings = new MapSettings();
    settings.setProperty("sonar.junit.reportsPath", "target/surefire");
    DefaultFileSystem fs = new DefaultFileSystem(new File("src/test/resources/org/sonar/plugins/surefire/api/SurefireUtilsTest/shouldGetReportsPathFromDeprecatedProperty"));
    PathResolver pathResolver = new PathResolver();
    assertThat(logTester.logs(LoggerLevel.INFO)).isEmpty();
    List<File> directories = SurefireUtils.getReportsDirectories(settings.asConfig(), fs, pathResolver);
    assertThat(directories).hasSize(1);
    File directory = directories.get(0);
    assertThat(directory.exists()).isTrue();
    assertThat(directory.isDirectory()).isTrue();
    assertThat(logTester.logs(LoggerLevel.INFO)).contains("Property 'sonar.junit.reportsPath' is deprecated. Use property 'sonar.junit.reportPaths' instead.");
}
Also used : MapSettings(org.sonar.api.config.internal.MapSettings) PathResolver(org.sonar.api.scan.filesystem.PathResolver) File(java.io.File) DefaultFileSystem(org.sonar.api.batch.fs.internal.DefaultFileSystem) Test(org.junit.Test)

Example 18 with PathResolver

use of org.sonar.api.scan.filesystem.PathResolver in project sonarqube by SonarSource.

the class GitScmProviderTest method returnImplem.

@Test
public void returnImplem() {
    JGitBlameCommand jblameCommand = new JGitBlameCommand(new PathResolver(), analysisWarnings);
    GitScmProvider gitScmProvider = new GitScmProvider(jblameCommand, analysisWarnings, gitIgnoreCommand, system2);
    assertThat(gitScmProvider.blameCommand()).isEqualTo(jblameCommand);
}
Also used : PathResolver(org.sonar.api.scan.filesystem.PathResolver) Test(org.junit.Test)

Example 19 with PathResolver

use of org.sonar.api.scan.filesystem.PathResolver in project sonarqube by SonarSource.

the class JGitBlameCommandTest method return_early_when_shallow_clone_detected.

@Test
public void return_early_when_shallow_clone_detected() throws IOException {
    File projectDir = temp.newFolder();
    javaUnzip("shallow-git.zip", projectDir);
    File baseDir = new File(projectDir, "shallow-git");
    DefaultFileSystem fs = new DefaultFileSystem(baseDir);
    when(input.fileSystem()).thenReturn(fs);
    DefaultInputFile inputFile = new TestInputFileBuilder("foo", DUMMY_JAVA).build();
    when(input.filesToBlame()).thenReturn(Collections.singleton(inputFile));
    // register warning with default wrapper
    AnalysisWarnings analysisWarnings = mock(AnalysisWarnings.class);
    JGitBlameCommand jGitBlameCommand = new JGitBlameCommand(new PathResolver(), analysisWarnings);
    BlameOutput output = mock(BlameOutput.class);
    jGitBlameCommand.blame(input, output);
    assertThat(logTester.logs()).first().matches(s -> s.contains("Shallow clone detected, no blame information will be provided."));
    verifyZeroInteractions(output);
    verify(analysisWarnings).addUnique(startsWith("Shallow clone detected"));
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) PathResolver(org.sonar.api.scan.filesystem.PathResolver) BlameOutput(org.sonar.api.batch.scm.BlameCommand.BlameOutput) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) File(java.io.File) DefaultFileSystem(org.sonar.api.batch.fs.internal.DefaultFileSystem) AnalysisWarnings(org.sonar.api.notifications.AnalysisWarnings) Test(org.junit.Test)

Aggregations

PathResolver (org.sonar.api.scan.filesystem.PathResolver)19 File (java.io.File)12 Test (org.junit.Test)7 DefaultFileSystem (org.sonar.api.batch.fs.internal.DefaultFileSystem)7 Before (org.junit.Before)6 InputFile (org.sonar.api.batch.fs.InputFile)5 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)5 InputComponentStore (org.sonar.scanner.scan.filesystem.InputComponentStore)5 MapSettings (org.sonar.api.config.internal.MapSettings)4 Path (java.nio.file.Path)3 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)3 Matchers.anyString (org.mockito.Matchers.anyString)2 DefaultInputDir (org.sonar.api.batch.fs.internal.DefaultInputDir)2 DefaultInputModule (org.sonar.api.batch.fs.internal.DefaultInputModule)2 MapSettings (org.sonar.api.config.MapSettings)2 AnalysisWarnings (org.sonar.api.notifications.AnalysisWarnings)2 MeasureCache (org.sonar.scanner.scan.measure.MeasureCache)2 ArrayList (java.util.ArrayList)1 CheckForNull (javax.annotation.CheckForNull)1 AnalysisMode (org.sonar.api.batch.AnalysisMode)1