Package org.sonar.api.resources

Examples of org.sonar.api.resources.ProjectFileSystem


    List<File> testSourceFiles = scanForSourceFiles(testDirs);

    List<InputFile> mainFiles = fromSourceFiles(mainSourceFiles);
    List<InputFile> testFiles = fromSourceFiles(testSourceFiles);

    ProjectFileSystem fileSystem = mock(ProjectFileSystem.class);
    when(fileSystem.getBasedir()).thenReturn(baseDir);
    when(fileSystem.getSourceCharset()).thenReturn(Charset.defaultCharset());
    when(fileSystem.getSourceFiles(mockCxxLanguage())).thenReturn(mainSourceFiles);
    when(fileSystem.getTestFiles(mockCxxLanguage())).thenReturn(testSourceFiles);
    when(fileSystem.mainFiles(CxxLanguage.KEY)).thenReturn(mainFiles);
    when(fileSystem.testFiles(CxxLanguage.KEY)).thenReturn(testFiles);
    when(fileSystem.getSourceDirs()).thenReturn(sourceDirs);
    when(fileSystem.getTestDirs()).thenReturn(testDirs);

    Project project = mock(Project.class);
    when(project.getFileSystem()).thenReturn(fileSystem);
    CxxLanguage lang = mockCxxLanguage();
    when(project.getLanguage()).thenReturn(lang);
View Full Code Here


public class JavaScriptCpdMappingTest {

  @Test
  public void test() {
    JavaScript language = mock(JavaScript.class);
    ProjectFileSystem fs = mock(ProjectFileSystem.class);
    JavaScriptCpdMapping mapping = new JavaScriptCpdMapping(language, fs);
    assertThat(mapping.getLanguage()).isSameAs(language);
    assertThat(mapping.getTokenizer()).isInstanceOf(JavaScriptTokenizer.class);
  }
View Full Code Here

    FileLinesContextFactory fileLinesContextFactory = mock(FileLinesContextFactory.class);

    FileLinesContext fileLinesContext = mock(FileLinesContext.class);
    when(fileLinesContextFactory.createFor(any(Resource.class))).thenReturn(fileLinesContext);

    ProjectFileSystem fs = mock(ProjectFileSystem.class);
    when(fs.getSourceDirs()).thenReturn(ImmutableList.of(new File("src/test/resources/")));

    Project project = new Project("key");
    project.setFileSystem(fs);

    FileLinesVisitor visitor = new FileLinesVisitor(project, fileLinesContextFactory);
View Full Code Here

  public void test_toString() {
    assertThat(sensor.toString()).isEqualTo("CoverageSensor");
  }

  public static Project mockProject() {
    ProjectFileSystem pfs = mock(ProjectFileSystem.class);
    when(pfs.getSourceDirs()).thenReturn(ImmutableList.of(new File(baseDir, "main")));

    Project project = new Project("key");
    project.setFileSystem(pfs);

    return project;
View Full Code Here

    fileLinesContextFactory = mock(FileLinesContextFactory.class);
    FileLinesContext fileLinesContext = mock(FileLinesContext.class);
    when(fileLinesContextFactory.createFor(any(Resource.class))).thenReturn(fileLinesContext);

    project = new Project("key");
    ProjectFileSystem pfs = mock(ProjectFileSystem.class);
    when(pfs.getSourceDirs()).thenReturn(Arrays.asList(new File("src/test/resources/cpd/")));

    project.setFileSystem(pfs);
  }
View Full Code Here

  @Test
  public void shouldPersistMeasuresForKnownFiles() {
    final Project project = new Project("Test");
    final org.sonar.api.resources.File dummyFile = new org.sonar.api.resources.File("dummy/test");
    final SensorContext context = mock(SensorContext.class);
    final ProjectFileSystem fileSystem = mock(ProjectFileSystem.class);
    final List<File> sourceDirs = new ArrayList<File>();
    final Map<String, CoverageMeasuresBuilder> measures = new HashMap<String, CoverageMeasuresBuilder>();
    final CoverageMeasuresBuilder measureBuilder = CoverageMeasuresBuilder.create();

    sourceDirs.add(new File("/dummy"));
    measures.put("/dummy/test", measureBuilder);
    measureBuilder.setHits(99, 99);
    measureBuilder.setConditions(99, 99, 1);

    when(fileSystem.getSourceDirs()).thenReturn(sourceDirs);
    when(context.getResource(any(Resource.class))).thenReturn(dummyFile);

    project.setFileSystem(fileSystem);

    final CoverageMeasuresPersistor testedPersistor = new CoverageMeasuresPersistor(project, context);
View Full Code Here

  @Test
  public void parseReportShouldReturnACollectionOfViolationsWhenTheReportIsNotEmpty() {
    final Project project = new Project("Test");
    final org.sonar.api.resources.File dummyFile = new org.sonar.api.resources.File("dummy/test");
    final SensorContext context = mock(SensorContext.class);
    final ProjectFileSystem fileSystem = mock(ProjectFileSystem.class);
    final List<File> sourceDirs = new ArrayList<File>();

    final OCLintParser testedParser = new OCLintParser(project, context);

    sourceDirs.add(new File("/dummy"));
    when(fileSystem.getSourceDirs()).thenReturn(sourceDirs);
    when(context.getResource(any(Resource.class))).thenReturn(dummyFile);
    project.setFileSystem(fileSystem);

    final Collection<Violation> violations = testedParser.parseReport(new StringInputStream(VALID_REPORT));
    assertFalse(violations.isEmpty());
View Full Code Here

TOP

Related Classes of org.sonar.api.resources.ProjectFileSystem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.