Search in sources :

Example 1 with MeasureRepoEntry

use of org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry in project sonarqube by SonarSource.

the class NewCoverageMeasuresStepTest method verify_aggregates_variations.

private void verify_aggregates_variations(LinesAndConditionsWithUncoveredMetricKeys metricKeys, String codeCoverageKey, String lineCoverageKey, String branchCoverageKey) {
    treeRootHolder.setRoot(MULTIPLE_FILES_TREE);
    measureRepository.addRawMeasure(FILE_1_REF, metricKeys.getLines(), createMeasure(3000d)).addRawMeasure(FILE_1_REF, metricKeys.getConditions(), createMeasure(300d)).addRawMeasure(FILE_1_REF, metricKeys.getUncoveredLines(), createMeasure(30d)).addRawMeasure(FILE_1_REF, metricKeys.getUncoveredConditions(), createMeasure(9d)).addRawMeasure(FILE_2_REF, metricKeys.getLines(), createMeasure(2000d)).addRawMeasure(FILE_2_REF, metricKeys.getConditions(), createMeasure(400d)).addRawMeasure(FILE_2_REF, metricKeys.getUncoveredLines(), createMeasure(200d)).addRawMeasure(FILE_2_REF, metricKeys.getUncoveredConditions(), createMeasure(16d));
    underTest.execute(new TestComputationStepContext());
    assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_1_REF))).containsOnly(entryOf(codeCoverageKey, createMeasure(98.8d)), entryOf(lineCoverageKey, createMeasure(99d)), entryOf(branchCoverageKey, createMeasure(97d)));
    assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_2_REF))).containsOnly(entryOf(codeCoverageKey, createMeasure(91d)), entryOf(lineCoverageKey, createMeasure(90d)), entryOf(branchCoverageKey, createMeasure(96d)));
    assertThat(measureRepository.getAddedRawMeasures(FILE_3_REF)).isEmpty();
    assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_1_REF))).containsOnly(entryOf(codeCoverageKey, createMeasure(98.8d)), entryOf(lineCoverageKey, createMeasure(99d)), entryOf(branchCoverageKey, createMeasure(97d)));
    assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_2_REF))).containsOnly(entryOf(codeCoverageKey, createMeasure(91d)), entryOf(lineCoverageKey, createMeasure(90d)), entryOf(branchCoverageKey, createMeasure(96d)));
    MeasureRepoEntry[] modulesAndProjectEntries = { entryOf(codeCoverageKey, createMeasure(95.5d)), entryOf(lineCoverageKey, createMeasure(95.4d)), entryOf(branchCoverageKey, createMeasure(96.4d)) };
    assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).containsOnly(modulesAndProjectEntries);
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) MeasureRepoEntry(org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry)

Example 2 with MeasureRepoEntry

use of org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry in project sonarqube by SonarSource.

the class NewCoverageMeasuresStepTest method verify_aggregation_of_measures_for_new_conditions.

@Test
public void verify_aggregation_of_measures_for_new_conditions() {
    when(newLinesRepository.newLinesAvailable()).thenReturn(true);
    treeRootHolder.setRoot(MULTIPLE_FILES_TREE);
    defineNewLinesAndLineCoverage(FILE_1, new LineCoverageValues(3, 4, 1), new LineCoverageValues(0, 3, 2));
    defineNewLinesAndLineCoverage(FILE_2, new LineCoverageValues(0, 14, 6), new LineCoverageValues(0, 13, 7));
    defineNewLinesAndLineCoverage(FILE_3, new LineCoverageValues(3, 4, 1), new LineCoverageValues(1, 13, 7));
    underTest.execute(new TestComputationStepContext());
    // files
    assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_1_REF))).contains(entryOf(NEW_LINES_TO_COVER_KEY, createMeasure(5d)), entryOf(NEW_UNCOVERED_LINES_KEY, createMeasure(3d)), entryOf(NEW_CONDITIONS_TO_COVER_KEY, createMeasure(7d)), entryOf(NEW_UNCOVERED_CONDITIONS_KEY, createMeasure(4d)));
    assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_2_REF))).contains(entryOf(NEW_LINES_TO_COVER_KEY, createMeasure(5d)), entryOf(NEW_UNCOVERED_LINES_KEY, createMeasure(4d)), entryOf(NEW_CONDITIONS_TO_COVER_KEY, createMeasure(27d)), entryOf(NEW_UNCOVERED_CONDITIONS_KEY, createMeasure(14d)));
    assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_3_REF))).contains(entryOf(NEW_LINES_TO_COVER_KEY, createMeasure(5d)), entryOf(NEW_UNCOVERED_LINES_KEY, createMeasure(2d)), entryOf(NEW_CONDITIONS_TO_COVER_KEY, createMeasure(17d)), entryOf(NEW_UNCOVERED_CONDITIONS_KEY, createMeasure(9d)));
    // directories
    assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_1_REF))).contains(entryOf(NEW_LINES_TO_COVER_KEY, createMeasure(5d)), entryOf(NEW_UNCOVERED_LINES_KEY, createMeasure(3d)), entryOf(NEW_CONDITIONS_TO_COVER_KEY, createMeasure(7d)), entryOf(NEW_UNCOVERED_CONDITIONS_KEY, createMeasure(4d)));
    assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_2_REF))).contains(entryOf(NEW_LINES_TO_COVER_KEY, createMeasure(10d)), entryOf(NEW_UNCOVERED_LINES_KEY, createMeasure(6d)), entryOf(NEW_CONDITIONS_TO_COVER_KEY, createMeasure(44d)), entryOf(NEW_UNCOVERED_CONDITIONS_KEY, createMeasure(23d)));
    // submodule
    MeasureRepoEntry[] repoEntriesFromProject = { entryOf(NEW_LINES_TO_COVER_KEY, createMeasure(15d)), entryOf(NEW_UNCOVERED_LINES_KEY, createMeasure(9d)), entryOf(NEW_CONDITIONS_TO_COVER_KEY, createMeasure(51d)), entryOf(NEW_UNCOVERED_CONDITIONS_KEY, createMeasure(27d)) };
    // project
    assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).contains(repoEntriesFromProject);
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) MeasureRepoEntry(org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry) Test(org.junit.Test)

Example 3 with MeasureRepoEntry

use of org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry in project sonarqube by SonarSource.

the class ViewsCoverageMeasuresStepTest method verify_lines_and_conditions_aggregates_values.

private void verify_lines_and_conditions_aggregates_values(LinesAndConditionsWithUncoveredMetricKeys metricKeys) {
    measureRepository.addRawMeasure(PROJECTVIEW_1_REF, metricKeys.getLines(), newMeasureBuilder().create(3000)).addRawMeasure(PROJECTVIEW_1_REF, metricKeys.getConditions(), newMeasureBuilder().create(300)).addRawMeasure(PROJECTVIEW_1_REF, metricKeys.getUncoveredLines(), newMeasureBuilder().create(30)).addRawMeasure(PROJECTVIEW_1_REF, metricKeys.getUncoveredConditions(), newMeasureBuilder().create(9)).addRawMeasure(PROJECTVIEW_2_REF, metricKeys.getLines(), newMeasureBuilder().create(2000)).addRawMeasure(PROJECTVIEW_2_REF, metricKeys.getConditions(), newMeasureBuilder().create(400)).addRawMeasure(PROJECTVIEW_2_REF, metricKeys.getUncoveredLines(), newMeasureBuilder().create(200)).addRawMeasure(PROJECTVIEW_2_REF, metricKeys.getUncoveredConditions(), newMeasureBuilder().create(16)).addRawMeasure(PROJECTVIEW_3_REF, metricKeys.getLines(), newMeasureBuilder().create(1000)).addRawMeasure(PROJECTVIEW_3_REF, metricKeys.getConditions(), newMeasureBuilder().create(500)).addRawMeasure(PROJECTVIEW_3_REF, metricKeys.getUncoveredLines(), newMeasureBuilder().create(300)).addRawMeasure(PROJECTVIEW_3_REF, metricKeys.getUncoveredConditions(), newMeasureBuilder().create(19));
    underTest.execute(new TestComputationStepContext());
    MeasureRepoEntry[] subViewRepoEntries = { entryOf(metricKeys.getLines(), newMeasureBuilder().create(5000)), entryOf(metricKeys.getConditions(), newMeasureBuilder().create(700)), entryOf(metricKeys.getUncoveredLines(), newMeasureBuilder().create(230)), entryOf(metricKeys.getUncoveredConditions(), newMeasureBuilder().create(25)) };
    assertThat(toEntries(measureRepository.getAddedRawMeasures(SUB_SUBVIEW_REF))).contains(subViewRepoEntries);
    assertThat(toEntries(measureRepository.getAddedRawMeasures(SUBVIEW_REF))).contains(subViewRepoEntries);
    assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).contains(entryOf(metricKeys.getLines(), newMeasureBuilder().create(6000)), entryOf(metricKeys.getConditions(), newMeasureBuilder().create(1200)), entryOf(metricKeys.getUncoveredLines(), newMeasureBuilder().create(530)), entryOf(metricKeys.getUncoveredConditions(), newMeasureBuilder().create(44)));
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) MeasureRepoEntry(org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry)

Example 4 with MeasureRepoEntry

use of org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry in project sonarqube by SonarSource.

the class ReportCoverageMeasuresStepTest method verify_coverage_aggregates_values.

private void verify_coverage_aggregates_values(LinesAndConditionsWithUncoveredMetricKeys metricKeys, String codeCoverageKey, String lineCoverageKey, String branchCoverageKey) {
    measureRepository.addRawMeasure(FILE_1_REF, metricKeys.getLines(), newMeasureBuilder().create(3000)).addRawMeasure(FILE_1_REF, metricKeys.getConditions(), newMeasureBuilder().create(300)).addRawMeasure(FILE_1_REF, metricKeys.getUncoveredLines(), newMeasureBuilder().create(30)).addRawMeasure(FILE_1_REF, metricKeys.getUncoveredConditions(), newMeasureBuilder().create(9)).addRawMeasure(FILE_2_REF, metricKeys.getLines(), newMeasureBuilder().create(2000)).addRawMeasure(FILE_2_REF, metricKeys.getConditions(), newMeasureBuilder().create(400)).addRawMeasure(FILE_2_REF, metricKeys.getUncoveredLines(), newMeasureBuilder().create(200)).addRawMeasure(FILE_2_REF, metricKeys.getUncoveredConditions(), newMeasureBuilder().create(16));
    underTest.execute(new TestComputationStepContext());
    assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_1_REF))).contains(entryOf(codeCoverageKey, newMeasureBuilder().create(98.8d, 1)), entryOf(lineCoverageKey, newMeasureBuilder().create(99d, 1)), entryOf(branchCoverageKey, newMeasureBuilder().create(97d, 1)));
    assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_2_REF))).contains(entryOf(codeCoverageKey, newMeasureBuilder().create(91d, 1)), entryOf(lineCoverageKey, newMeasureBuilder().create(90d, 1)), entryOf(branchCoverageKey, newMeasureBuilder().create(96d, 1)));
    assertThat(toEntries(measureRepository.getAddedRawMeasures(UNIT_TEST_FILE_REF))).isEmpty();
    MeasureRepoEntry[] nonFileRepoEntries = { entryOf(codeCoverageKey, newMeasureBuilder().create(95.5d, 1)), entryOf(lineCoverageKey, newMeasureBuilder().create(95.4d, 1)), entryOf(branchCoverageKey, newMeasureBuilder().create(96.4d, 1)) };
    assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_REF))).contains(nonFileRepoEntries);
    assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).contains(nonFileRepoEntries);
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) MeasureRepoEntry(org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry)

Example 5 with MeasureRepoEntry

use of org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry in project sonarqube by SonarSource.

the class ReportCoverageMeasuresStepTest method verify_aggregates_values_for_lines_and_conditions.

@Test
public void verify_aggregates_values_for_lines_and_conditions() {
    reportReader.putCoverage(FILE_1_REF, asList(ScannerReport.LineCoverage.newBuilder().setLine(2).setHits(false).build(), ScannerReport.LineCoverage.newBuilder().setLine(3).setHits(true).build(), ScannerReport.LineCoverage.newBuilder().setLine(4).setHits(true).setConditions(4).setCoveredConditions(1).build(), ScannerReport.LineCoverage.newBuilder().setLine(5).setConditions(8).setCoveredConditions(2).build(), ScannerReport.LineCoverage.newBuilder().setLine(6).setHits(false).setConditions(3).setCoveredConditions(0).build(), ScannerReport.LineCoverage.newBuilder().setLine(7).setHits(false).build()));
    reportReader.putCoverage(FILE_2_REF, asList(ScannerReport.LineCoverage.newBuilder().setLine(2).setHits(true).build(), ScannerReport.LineCoverage.newBuilder().setLine(3).setHits(false).build(), ScannerReport.LineCoverage.newBuilder().setLine(5).setHits(true).setConditions(5).setCoveredConditions(1).build(), ScannerReport.LineCoverage.newBuilder().setLine(6).setConditions(10).setCoveredConditions(3).build(), ScannerReport.LineCoverage.newBuilder().setLine(7).setHits(false).setConditions(1).setCoveredConditions(0).build(), ScannerReport.LineCoverage.newBuilder().setLine(8).setHits(false).build()));
    underTest.execute(new TestComputationStepContext());
    MeasureRepoEntry[] nonFileRepoEntries = { entryOf(LINES_TO_COVER_KEY, newMeasureBuilder().create(5 + 5)), entryOf(CONDITIONS_TO_COVER_KEY, newMeasureBuilder().create(4 + 8 + 3 + 5 + 10 + 1)), entryOf(UNCOVERED_LINES_KEY, newMeasureBuilder().create(3 + 3)), entryOf(UNCOVERED_CONDITIONS_KEY, newMeasureBuilder().create(3 + 6 + 3 + 4 + 7 + 1)) };
    assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_REF))).contains(nonFileRepoEntries);
    assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).contains(nonFileRepoEntries);
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) MeasureRepoEntry(org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry) Test(org.junit.Test)

Aggregations

MeasureRepoEntry (org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry)7 TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)7 Test (org.junit.Test)2