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);
}
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);
}
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);
}
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());
}
Aggregations