Search in sources :

Example 1 with MeasureCache

use of org.sonar.scanner.scan.measure.MeasureCache in project sonarqube by SonarSource.

the class CoveragePublisherTest method prepare.

@Before
public void prepare() throws IOException {
    String moduleKey = "foo";
    inputFile = new TestInputFileBuilder(moduleKey, "src/Foo.php").setLines(5).build();
    InputComponentStore componentCache = new InputComponentStore(new PathResolver());
    componentCache.put(TestInputFileBuilder.newDefaultInputModule(moduleKey, temp.newFolder()));
    componentCache.put(inputFile);
    measureCache = mock(MeasureCache.class);
    when(measureCache.byMetric(anyString(), anyString())).thenReturn(null);
    publisher = new CoveragePublisher(componentCache, measureCache);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) InputComponentStore(org.sonar.scanner.scan.filesystem.InputComponentStore) MeasureCache(org.sonar.scanner.scan.measure.MeasureCache) PathResolver(org.sonar.api.scan.filesystem.PathResolver) Matchers.anyString(org.mockito.Matchers.anyString) Before(org.junit.Before)

Example 2 with MeasureCache

use of org.sonar.scanner.scan.measure.MeasureCache in project sonarqube by SonarSource.

the class MeasuresPublisherTest method prepare.

@Before
public void prepare() throws IOException {
    String moduleKey = "foo";
    inputModule = TestInputFileBuilder.newDefaultInputModule(moduleKey, temp.newFolder());
    inputFile = new TestInputFileBuilder(moduleKey, "src/Foo.php").setPublish(true).build();
    InputComponentStore componentCache = new InputComponentStore(new PathResolver());
    componentCache.put(inputModule);
    componentCache.put(inputFile);
    measureCache = mock(MeasureCache.class);
    when(measureCache.byComponentKey(anyString())).thenReturn(Collections.<DefaultMeasure<?>>emptyList());
    publisher = new MeasuresPublisher(componentCache, measureCache, mock(TestPlanBuilder.class));
    outputDir = temp.newFolder();
    writer = new ScannerReportWriter(outputDir);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) InputComponentStore(org.sonar.scanner.scan.filesystem.InputComponentStore) MeasureCache(org.sonar.scanner.scan.measure.MeasureCache) PathResolver(org.sonar.api.scan.filesystem.PathResolver) Matchers.anyString(org.mockito.Matchers.anyString) ScannerReportWriter(org.sonar.scanner.protocol.output.ScannerReportWriter) Before(org.junit.Before)

Example 3 with MeasureCache

use of org.sonar.scanner.scan.measure.MeasureCache in project sonarqube by SonarSource.

the class DefaultFileLinesContextTest method setUp.

@Before
public void setUp() throws Exception {
    sensorContextTester = SensorContextTester.create(temp.newFolder());
    MetricFinder metricFinder = mock(MetricFinder.class);
    org.sonar.api.batch.measure.Metric<String> hitsMetric = mock(org.sonar.api.batch.measure.Metric.class);
    when(hitsMetric.valueType()).thenReturn(String.class);
    when(hitsMetric.key()).thenReturn(HITS_METRIC_KEY);
    when(metricFinder.<String>findByKey(HITS_METRIC_KEY)).thenReturn(hitsMetric);
    org.sonar.api.batch.measure.Metric<String> authorMetric = mock(org.sonar.api.batch.measure.Metric.class);
    when(authorMetric.valueType()).thenReturn(String.class);
    when(authorMetric.key()).thenReturn(AUTHOR_METRIC_KEY);
    when(metricFinder.<String>findByKey(AUTHOR_METRIC_KEY)).thenReturn(authorMetric);
    org.sonar.api.batch.measure.Metric<String> branchesMetric = mock(org.sonar.api.batch.measure.Metric.class);
    when(branchesMetric.valueType()).thenReturn(String.class);
    when(branchesMetric.key()).thenReturn(BRANCHES_METRIC_KEY);
    when(metricFinder.<String>findByKey(BRANCHES_METRIC_KEY)).thenReturn(branchesMetric);
    when(metricFinder.<String>findByKey(CoreMetrics.NCLOC_DATA_KEY)).thenReturn(CoreMetrics.NCLOC_DATA);
    when(metricFinder.<String>findByKey(CoreMetrics.EXECUTABLE_LINES_DATA_KEY)).thenReturn(CoreMetrics.EXECUTABLE_LINES_DATA);
    when(metricFinder.<String>findByKey(CoreMetrics.COMMENT_LINES_DATA_KEY)).thenReturn(CoreMetrics.COMMENT_LINES_DATA);
    measureCache = mock(MeasureCache.class);
    fileLineMeasures = new DefaultFileLinesContext(sensorContextTester, new TestInputFileBuilder("foo", "src/foo.php").initMetadata("Foo\nbar\nbiz").build(), metricFinder, measureCache);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) MeasureCache(org.sonar.scanner.scan.measure.MeasureCache) MetricFinder(org.sonar.api.batch.measure.MetricFinder) Before(org.junit.Before)

Example 4 with MeasureCache

use of org.sonar.scanner.scan.measure.MeasureCache in project sonarqube by SonarSource.

the class DefaultSensorStorageTest method prepare.

@Before
public void prepare() throws Exception {
    MetricFinder metricFinder = mock(MetricFinder.class);
    when(metricFinder.<Integer>findByKey(CoreMetrics.NCLOC_KEY)).thenReturn(CoreMetrics.NCLOC);
    when(metricFinder.<String>findByKey(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION_KEY)).thenReturn(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION);
    settings = new MapSettings();
    moduleIssues = mock(ModuleIssues.class);
    measureCache = mock(MeasureCache.class);
    CoverageExclusions coverageExclusions = mock(CoverageExclusions.class);
    when(coverageExclusions.isExcluded(any(InputFile.class))).thenReturn(false);
    ReportPublisher reportPublisher = mock(ReportPublisher.class);
    when(reportPublisher.getWriter()).thenReturn(new ScannerReportWriter(temp.newFolder()));
    underTest = new DefaultSensorStorage(metricFinder, moduleIssues, settings, coverageExclusions, reportPublisher, measureCache, mock(SonarCpdBlockIndex.class), contextPropertiesCache, new ScannerMetrics());
}
Also used : ReportPublisher(org.sonar.scanner.report.ReportPublisher) MapSettings(org.sonar.api.config.MapSettings) MeasureCache(org.sonar.scanner.scan.measure.MeasureCache) ModuleIssues(org.sonar.scanner.issue.ModuleIssues) MetricFinder(org.sonar.api.batch.measure.MetricFinder) ScannerMetrics(org.sonar.core.metric.ScannerMetrics) CoverageExclusions(org.sonar.scanner.sensor.coverage.CoverageExclusions) ScannerReportWriter(org.sonar.scanner.protocol.output.ScannerReportWriter) InputFile(org.sonar.api.batch.fs.InputFile) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)4 MeasureCache (org.sonar.scanner.scan.measure.MeasureCache)4 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)3 Matchers.anyString (org.mockito.Matchers.anyString)2 MetricFinder (org.sonar.api.batch.measure.MetricFinder)2 PathResolver (org.sonar.api.scan.filesystem.PathResolver)2 ScannerReportWriter (org.sonar.scanner.protocol.output.ScannerReportWriter)2 InputComponentStore (org.sonar.scanner.scan.filesystem.InputComponentStore)2 InputFile (org.sonar.api.batch.fs.InputFile)1 MapSettings (org.sonar.api.config.MapSettings)1 ScannerMetrics (org.sonar.core.metric.ScannerMetrics)1 ModuleIssues (org.sonar.scanner.issue.ModuleIssues)1 ReportPublisher (org.sonar.scanner.report.ReportPublisher)1 CoverageExclusions (org.sonar.scanner.sensor.coverage.CoverageExclusions)1