Search in sources :

Example 6 with MeasureRepoEntry

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

the class ReportSizeMeasuresStepTest method verifyTwoMeasureAggregation.

private void verifyTwoMeasureAggregation(String metric1Key, String metric2Key) {
    measureRepository.addRawMeasure(FILE_1_REF, metric1Key, newMeasureBuilder().create(1));
    measureRepository.addRawMeasure(FILE_1_REF, metric2Key, newMeasureBuilder().create(10));
    // FILE_2_REF has no metric2 measure
    measureRepository.addRawMeasure(FILE_2_REF, metric1Key, newMeasureBuilder().create(6));
    // FILE_3_REF has no measure at all
    // UNIT_TEST_1_REF has no metric1
    measureRepository.addRawMeasure(UNIT_TEST_1_REF, metric2Key, newMeasureBuilder().create(90));
    measureRepository.addRawMeasure(FILE_4_REF, metric1Key, newMeasureBuilder().create(2));
    measureRepository.addRawMeasure(FILE_4_REF, metric2Key, newMeasureBuilder().create(3));
    underTest.execute(new TestComputationStepContext());
    verifyMeasuresOnFile(FILE_1_REF, 1, 1);
    verifyMeasuresOnFile(FILE_2_REF, 2, 1);
    verifyMeasuresOnFile(FILE_3_REF, 7, 1);
    verifyNoMeasure(UNIT_TEST_1_REF);
    verifyNoMeasure(UNIT_TEST_2_REF);
    verifyMeasuresOnOtherComponent(DIRECTORY_1_REF, 3, 2, NO_METRIC, entryOf(metric1Key, newMeasureBuilder().create(7)), entryOf(metric2Key, newMeasureBuilder().create(10)));
    verifyMeasuresOnOtherComponent(DIRECTORY_2_REF, 7, 1, NO_METRIC, entryOf(metric2Key, newMeasureBuilder().create(90)));
    MeasureRepoEntry[] subModuleAndAboveEntries = { entryOf(metric1Key, newMeasureBuilder().create(9)), entryOf(metric2Key, newMeasureBuilder().create(103)) };
    verifyMeasuresOnOtherComponent(DIRECTORY_3_REF, NO_METRIC, NO_METRIC, NO_METRIC);
    verifyMeasuresOnOtherComponent(ROOT_REF, 24, 5, 5, subModuleAndAboveEntries);
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) MeasureRepoEntry(org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry)

Example 7 with MeasureRepoEntry

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

the class ViewsCoverageMeasuresStepTest method verify_coverage_aggregates_values.

private void verify_coverage_aggregates_values(LinesAndConditionsWithUncoveredMetricKeys metricKeys, String codeCoverageKey, String lineCoverageKey, String branchCoverageKey) {
    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());
    assertThat(toEntries(measureRepository.getAddedRawMeasures(PROJECTVIEW_1_REF))).isEmpty();
    assertThat(toEntries(measureRepository.getAddedRawMeasures(PROJECTVIEW_2_REF))).isEmpty();
    assertThat(toEntries(measureRepository.getAddedRawMeasures(PROJECTVIEW_3_REF))).isEmpty();
    MeasureRepoEntry[] subViewRepoEntries = { 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(SUB_SUBVIEW_REF))).contains(subViewRepoEntries);
    assertThat(toEntries(measureRepository.getAddedRawMeasures(SUBVIEW_REF))).contains(subViewRepoEntries);
    assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).contains(entryOf(codeCoverageKey, newMeasureBuilder().create(92d, 1)), entryOf(lineCoverageKey, newMeasureBuilder().create(91.2d, 1)), entryOf(branchCoverageKey, newMeasureBuilder().create(96.3d, 1)));
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) MeasureRepoEntry(org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry)

Aggregations

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