Search in sources :

Example 96 with InputFile

use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.

the class ModuleInputComponentStoreTest method should_cache_files_by_filename.

@Test
public void should_cache_files_by_filename() throws IOException {
    ModuleInputComponentStore store = newModuleInputComponentStore();
    String filename = "some name";
    InputFile inputFile1 = new TestInputFileBuilder(moduleKey, "some/path/" + filename).build();
    store.doAdd(inputFile1);
    InputFile inputFile2 = new TestInputFileBuilder(moduleKey, "other/path/" + filename).build();
    store.doAdd(inputFile2);
    InputFile dummyInputFile = new TestInputFileBuilder(moduleKey, "some/path/Dummy.java").build();
    store.doAdd(dummyInputFile);
    assertThat(store.getFilesByName(filename)).containsExactlyInAnyOrder(inputFile1, inputFile2);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) InputFile(org.sonar.api.batch.fs.InputFile) Test(org.junit.Test)

Example 97 with InputFile

use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.

the class ModuleInputComponentStoreTest method should_not_cache_duplicates.

@Test
public void should_not_cache_duplicates() throws IOException {
    ModuleInputComponentStore store = newModuleInputComponentStore();
    String ext = "java";
    String filename = "Program." + ext;
    InputFile inputFile = new TestInputFileBuilder(moduleKey, "some/path/" + filename).build();
    store.doAdd(inputFile);
    store.doAdd(inputFile);
    store.doAdd(inputFile);
    assertThat(store.getFilesByName(filename)).containsExactly(inputFile);
    assertThat(store.getFilesByExtension(ext)).containsExactly(inputFile);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) InputFile(org.sonar.api.batch.fs.InputFile) Test(org.junit.Test)

Example 98 with InputFile

use of org.sonar.api.batch.fs.InputFile in project sonarqube by SonarSource.

the class ModuleInputComponentStoreTest method should_cache_files_by_extension.

@Test
public void should_cache_files_by_extension() throws IOException {
    ModuleInputComponentStore store = newModuleInputComponentStore();
    InputFile inputFile1 = new TestInputFileBuilder(moduleKey, "some/path/Program.java").build();
    store.doAdd(inputFile1);
    InputFile inputFile2 = new TestInputFileBuilder(moduleKey, "other/path/Utils.java").build();
    store.doAdd(inputFile2);
    InputFile dummyInputFile = new TestInputFileBuilder(moduleKey, "some/path/NotJava.cpp").build();
    store.doAdd(dummyInputFile);
    assertThat(store.getFilesByExtension("java")).containsExactlyInAnyOrder(inputFile1, inputFile2);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) InputFile(org.sonar.api.batch.fs.InputFile) Test(org.junit.Test)

Aggregations

InputFile (org.sonar.api.batch.fs.InputFile)98 Test (org.junit.Test)60 File (java.io.File)44 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)39 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)19 TaskResult (org.sonar.scanner.mediumtest.TaskResult)19 IOException (java.io.IOException)10 FilePredicates (org.sonar.api.batch.fs.FilePredicates)7 ScannerReport (org.sonar.scanner.protocol.output.ScannerReport)7 List (java.util.List)6 BlameLine (org.sonar.api.batch.scm.BlameLine)6 FileSystem (org.sonar.api.batch.fs.FileSystem)5 ArrayList (java.util.ArrayList)4 PathResolver (org.sonar.api.scan.filesystem.PathResolver)4 DefaultBlameOutput (org.sonar.scanner.scm.DefaultBlameOutput)4 FilePredicate (org.sonar.api.batch.fs.FilePredicate)3 DefaultInputModule (org.sonar.api.batch.fs.internal.DefaultInputModule)3 DefaultMeasure (org.sonar.api.batch.sensor.measure.internal.DefaultMeasure)3 MutableTestPlan (org.sonar.api.test.MutableTestPlan)3 Block (org.sonar.duplications.block.Block)3