diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-07-22 12:08:33 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-07-23 18:00:38 +0200 |
commit | 22924e1c45de5003c55cb1031b12a0c7f951fe0e (patch) | |
tree | 0f63a8a1fc61b57c2911b26d230847e2f2bfcbc2 /server/sonar-server | |
parent | 79ea8743f2fc5fb7e24ee99dc76da025fd5efd7d (diff) | |
download | sonarqube-22924e1c45de5003c55cb1031b12a0c7f951fe0e.tar.gz sonarqube-22924e1c45de5003c55cb1031b12a0c7f951fe0e.zip |
SONAR-6605 Move sum coverage formulas to CoverageMeasuresStep
Diffstat (limited to 'server/sonar-server')
3 files changed, 172 insertions, 110 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/formula/CoreFormulaRepositoryImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/formula/CoreFormulaRepositoryImpl.java index 0f4ebfa24fc..bcfc94318a2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/formula/CoreFormulaRepositoryImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/formula/CoreFormulaRepositoryImpl.java @@ -39,62 +39,37 @@ import static org.sonar.api.measures.CoreMetrics.FUNCTION_COMPLEXITY_KEY; public class CoreFormulaRepositoryImpl implements CoreFormulaRepository { private static final List<Formula> FORMULAS = ImmutableList.<Formula>of( - // TODO When all decorators will be moved to CE, uncomment commented lines to activate all formulas and remove formulas declaration in - // {@link org.sonar.api.measures.CoreMetrics} + // TODO When all decorators will be moved to CE, uncomment commented lines to activate all formulas and remove formulas declaration in + // {@link org.sonar.api.measures.CoreMetrics} - // Sum formulas - new SumFormula(COMMENTED_OUT_CODE_LINES_KEY), - new SumFormula(COMPLEXITY_KEY), - new SumFormula(COMPLEXITY_IN_CLASSES_KEY), - // TODO this formula seems to be useless as this measure seems only required on files - new SumFormula(COMPLEXITY_IN_FUNCTIONS_KEY), + // Sum formulas + new SumFormula(COMMENTED_OUT_CODE_LINES_KEY), + new SumFormula(COMPLEXITY_KEY), + new SumFormula(COMPLEXITY_IN_CLASSES_KEY), + // TODO this formula seems to be useless as this measure seems only required on files + new SumFormula(COMPLEXITY_IN_FUNCTIONS_KEY), // new SumFormula(CoreMetrics.COMMENT_LINES_KEY), - // new SumFormula(LINES_TO_COVER_KEY), - // new SumFormula(NEW_LINES_TO_COVER_KEY), - // new SumFormula(UNCOVERED_LINES_KEY), - // new SumFormula(NEW_UNCOVERED_LINES_KEY), - // new SumFormula(CONDITIONS_TO_COVER_KEY), - // new SumFormula(NEW_CONDITIONS_TO_COVER_KEY), - // new SumFormula(UNCOVERED_CONDITIONS_KEY), - // new SumFormula(NEW_UNCOVERED_CONDITIONS_KEY), - // new SumFormula(IT_LINES_TO_COVER_KEY), - // new SumFormula(NEW_IT_LINES_TO_COVER_KEY), - // new SumFormula(IT_UNCOVERED_LINES_KEY), - // new SumFormula(NEW_IT_UNCOVERED_LINES_KEY), - // new SumFormula(IT_CONDITIONS_TO_COVER_KEY), - // new SumFormula(NEW_IT_CONDITIONS_TO_COVER_KEY), - // new SumFormula(IT_UNCOVERED_CONDITIONS_KEY), - // new SumFormula(NEW_IT_UNCOVERED_CONDITIONS_KEY), - // new SumFormula(OVERALL_LINES_TO_COVER_KEY), - // new SumFormula(NEW_OVERALL_LINES_TO_COVER_KEY), - // new SumFormula(OVERALL_UNCOVERED_LINES_KEY), - // new SumFormula(NEW_OVERALL_UNCOVERED_LINES_KEY), - // new SumFormula(OVERALL_CONDITIONS_TO_COVER_KEY), - // new SumFormula(NEW_OVERALL_CONDITIONS_TO_COVER_KEY), - // new SumFormula(OVERALL_UNCOVERED_CONDITIONS_KEY), - // new SumFormula(NEW_OVERALL_UNCOVERED_CONDITIONS_KEY), + // Distribution formulas + new DistributionFormula(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY), + new DistributionFormula(FILE_COMPLEXITY_DISTRIBUTION_KEY), - // Distribution formulas - new DistributionFormula(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY), - new DistributionFormula(FILE_COMPLEXITY_DISTRIBUTION_KEY), - - // Average formulas, must be executed after all sum formulas as they depend on their measures - AverageFormula.Builder.newBuilder().setOutputMetricKey(FILE_COMPLEXITY_KEY) - .setMainMetricKey(COMPLEXITY_KEY) - .setByMetricKey(FILES_KEY) - .build(), - AverageFormula.Builder.newBuilder().setOutputMetricKey(CLASS_COMPLEXITY_KEY) - .setMainMetricKey(COMPLEXITY_IN_CLASSES_KEY) - .setByMetricKey(CLASSES_KEY) - .setFallbackMetricKey(COMPLEXITY_KEY) - .build(), - AverageFormula.Builder.newBuilder().setOutputMetricKey(FUNCTION_COMPLEXITY_KEY) - .setMainMetricKey(COMPLEXITY_IN_FUNCTIONS_KEY) - .setByMetricKey(FUNCTIONS_KEY) - .setFallbackMetricKey(COMPLEXITY_KEY) - .build() + // Average formulas, must be executed after all sum formulas as they depend on their measures + AverageFormula.Builder.newBuilder().setOutputMetricKey(FILE_COMPLEXITY_KEY) + .setMainMetricKey(COMPLEXITY_KEY) + .setByMetricKey(FILES_KEY) + .build(), + AverageFormula.Builder.newBuilder().setOutputMetricKey(CLASS_COMPLEXITY_KEY) + .setMainMetricKey(COMPLEXITY_IN_CLASSES_KEY) + .setByMetricKey(CLASSES_KEY) + .setFallbackMetricKey(COMPLEXITY_KEY) + .build(), + AverageFormula.Builder.newBuilder().setOutputMetricKey(FUNCTION_COMPLEXITY_KEY) + .setMainMetricKey(COMPLEXITY_IN_FUNCTIONS_KEY) + .setByMetricKey(FUNCTIONS_KEY) + .setFallbackMetricKey(COMPLEXITY_KEY) + .build() ); /** diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/CoverageMeasuresStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/CoverageMeasuresStep.java index 9aa3d0100f6..86505c74a15 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/CoverageMeasuresStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/CoverageMeasuresStep.java @@ -20,10 +20,10 @@ package org.sonar.server.computation.step; import com.google.common.collect.ImmutableList; -import org.sonar.api.measures.CoreMetrics; import org.sonar.server.computation.component.TreeRootHolder; import org.sonar.server.computation.formula.Formula; import org.sonar.server.computation.formula.FormulaExecutorComponentVisitor; +import org.sonar.server.computation.formula.SumFormula; import org.sonar.server.computation.formula.coverage.LinesAndConditionsWithUncoveredFormula; import org.sonar.server.computation.formula.coverage.LinesAndConditionsWithUncoveredMetricKeys; import org.sonar.server.computation.formula.coverage.SingleWithUncoveredFormula; @@ -31,22 +31,58 @@ import org.sonar.server.computation.formula.coverage.SingleWithUncoveredMetricKe import org.sonar.server.computation.measure.MeasureRepository; import org.sonar.server.computation.metric.MetricRepository; +import static org.sonar.api.measures.CoreMetrics.BRANCH_COVERAGE_KEY; +import static org.sonar.api.measures.CoreMetrics.CONDITIONS_TO_COVER_KEY; +import static org.sonar.api.measures.CoreMetrics.COVERAGE_KEY; +import static org.sonar.api.measures.CoreMetrics.IT_BRANCH_COVERAGE_KEY; +import static org.sonar.api.measures.CoreMetrics.IT_CONDITIONS_TO_COVER_KEY; +import static org.sonar.api.measures.CoreMetrics.IT_COVERAGE_KEY; +import static org.sonar.api.measures.CoreMetrics.IT_LINES_TO_COVER_KEY; +import static org.sonar.api.measures.CoreMetrics.IT_LINE_COVERAGE_KEY; +import static org.sonar.api.measures.CoreMetrics.IT_UNCOVERED_CONDITIONS_KEY; +import static org.sonar.api.measures.CoreMetrics.IT_UNCOVERED_LINES_KEY; +import static org.sonar.api.measures.CoreMetrics.LINES_TO_COVER_KEY; +import static org.sonar.api.measures.CoreMetrics.LINE_COVERAGE_KEY; +import static org.sonar.api.measures.CoreMetrics.OVERALL_BRANCH_COVERAGE_KEY; +import static org.sonar.api.measures.CoreMetrics.OVERALL_CONDITIONS_TO_COVER_KEY; +import static org.sonar.api.measures.CoreMetrics.OVERALL_COVERAGE_KEY; +import static org.sonar.api.measures.CoreMetrics.OVERALL_LINES_TO_COVER_KEY; +import static org.sonar.api.measures.CoreMetrics.OVERALL_LINE_COVERAGE_KEY; +import static org.sonar.api.measures.CoreMetrics.OVERALL_UNCOVERED_CONDITIONS_KEY; +import static org.sonar.api.measures.CoreMetrics.OVERALL_UNCOVERED_LINES_KEY; +import static org.sonar.api.measures.CoreMetrics.UNCOVERED_CONDITIONS_KEY; +import static org.sonar.api.measures.CoreMetrics.UNCOVERED_LINES_KEY; + /** * Computes coverage measures on files and then aggregates them on higher components. */ public class CoverageMeasuresStep implements ComputationStep { private static final ImmutableList<Formula> COVERAGE_FORMULAS = ImmutableList.<Formula>of( - // code + // unit test + new SumFormula(LINES_TO_COVER_KEY), + new SumFormula(UNCOVERED_LINES_KEY), + new SumFormula(CONDITIONS_TO_COVER_KEY), + new SumFormula(UNCOVERED_CONDITIONS_KEY), new CodeCoverageFormula(), - new ItCoverageFormula(), - new OverallCodeCoverageFormula(), - // branch new BranchCoverageFormula(), - new ItBranchCoverageFormula(), - new OverallBranchCoverageFormula(), - // line new LineCoverageFormula(), + + // integration test + new SumFormula(IT_LINES_TO_COVER_KEY), + new SumFormula(IT_UNCOVERED_LINES_KEY), + new SumFormula(IT_CONDITIONS_TO_COVER_KEY), + new SumFormula(IT_UNCOVERED_CONDITIONS_KEY), + new ItCoverageFormula(), + new ItBranchCoverageFormula(), new ItLineCoverageFormula(), + + // overall test + new SumFormula(OVERALL_LINES_TO_COVER_KEY), + new SumFormula(OVERALL_UNCOVERED_LINES_KEY), + new SumFormula(OVERALL_CONDITIONS_TO_COVER_KEY), + new SumFormula(OVERALL_UNCOVERED_CONDITIONS_KEY), + new OverallCodeCoverageFormula(), + new OverallBranchCoverageFormula(), new OverallLineCoverageFormula() ); @@ -71,10 +107,10 @@ public class CoverageMeasuresStep implements ComputationStep { public CodeCoverageFormula() { super( new LinesAndConditionsWithUncoveredMetricKeys( - CoreMetrics.LINES_TO_COVER_KEY, CoreMetrics.CONDITIONS_TO_COVER_KEY, - CoreMetrics.UNCOVERED_LINES_KEY, CoreMetrics.UNCOVERED_CONDITIONS_KEY + LINES_TO_COVER_KEY, CONDITIONS_TO_COVER_KEY, + UNCOVERED_LINES_KEY, UNCOVERED_CONDITIONS_KEY ), - CoreMetrics.COVERAGE_KEY); + COVERAGE_KEY); } } @@ -82,10 +118,10 @@ public class CoverageMeasuresStep implements ComputationStep { private ItCoverageFormula() { super( new LinesAndConditionsWithUncoveredMetricKeys( - CoreMetrics.IT_LINES_TO_COVER_KEY, CoreMetrics.IT_CONDITIONS_TO_COVER_KEY, - CoreMetrics.IT_UNCOVERED_LINES_KEY, CoreMetrics.IT_UNCOVERED_CONDITIONS_KEY + IT_LINES_TO_COVER_KEY, IT_CONDITIONS_TO_COVER_KEY, + IT_UNCOVERED_LINES_KEY, IT_UNCOVERED_CONDITIONS_KEY ), - CoreMetrics.IT_COVERAGE_KEY); + IT_COVERAGE_KEY); } } @@ -93,10 +129,10 @@ public class CoverageMeasuresStep implements ComputationStep { public OverallCodeCoverageFormula() { super( new LinesAndConditionsWithUncoveredMetricKeys( - CoreMetrics.OVERALL_LINES_TO_COVER_KEY, CoreMetrics.OVERALL_CONDITIONS_TO_COVER_KEY, - CoreMetrics.OVERALL_UNCOVERED_LINES_KEY, CoreMetrics.OVERALL_UNCOVERED_CONDITIONS_KEY + OVERALL_LINES_TO_COVER_KEY, OVERALL_CONDITIONS_TO_COVER_KEY, + OVERALL_UNCOVERED_LINES_KEY, OVERALL_UNCOVERED_CONDITIONS_KEY ), - CoreMetrics.OVERALL_COVERAGE_KEY); + OVERALL_COVERAGE_KEY); } } @@ -104,9 +140,9 @@ public class CoverageMeasuresStep implements ComputationStep { public BranchCoverageFormula() { super( new SingleWithUncoveredMetricKeys( - CoreMetrics.CONDITIONS_TO_COVER_KEY, CoreMetrics.UNCOVERED_CONDITIONS_KEY + CONDITIONS_TO_COVER_KEY, UNCOVERED_CONDITIONS_KEY ), - CoreMetrics.BRANCH_COVERAGE_KEY); + BRANCH_COVERAGE_KEY); } } @@ -114,33 +150,33 @@ public class CoverageMeasuresStep implements ComputationStep { public ItBranchCoverageFormula() { super( new SingleWithUncoveredMetricKeys( - CoreMetrics.IT_CONDITIONS_TO_COVER_KEY, CoreMetrics.IT_UNCOVERED_CONDITIONS_KEY + IT_CONDITIONS_TO_COVER_KEY, IT_UNCOVERED_CONDITIONS_KEY ), - CoreMetrics.IT_BRANCH_COVERAGE_KEY); + IT_BRANCH_COVERAGE_KEY); } } private static class OverallBranchCoverageFormula extends SingleWithUncoveredFormula { public OverallBranchCoverageFormula() { super( - new SingleWithUncoveredMetricKeys(CoreMetrics.OVERALL_CONDITIONS_TO_COVER_KEY, CoreMetrics.OVERALL_UNCOVERED_CONDITIONS_KEY), - CoreMetrics.OVERALL_BRANCH_COVERAGE_KEY); + new SingleWithUncoveredMetricKeys(OVERALL_CONDITIONS_TO_COVER_KEY, OVERALL_UNCOVERED_CONDITIONS_KEY), + OVERALL_BRANCH_COVERAGE_KEY); } } private static class LineCoverageFormula extends SingleWithUncoveredFormula { public LineCoverageFormula() { super( - new SingleWithUncoveredMetricKeys(CoreMetrics.LINES_TO_COVER_KEY, CoreMetrics.UNCOVERED_LINES_KEY), - CoreMetrics.LINE_COVERAGE_KEY); + new SingleWithUncoveredMetricKeys(LINES_TO_COVER_KEY, UNCOVERED_LINES_KEY), + LINE_COVERAGE_KEY); } } private static class ItLineCoverageFormula extends SingleWithUncoveredFormula { public ItLineCoverageFormula() { super( - new SingleWithUncoveredMetricKeys(CoreMetrics.IT_LINES_TO_COVER_KEY, CoreMetrics.IT_UNCOVERED_LINES_KEY), - CoreMetrics.IT_LINE_COVERAGE_KEY); + new SingleWithUncoveredMetricKeys(IT_LINES_TO_COVER_KEY, IT_UNCOVERED_LINES_KEY), + IT_LINE_COVERAGE_KEY); } } @@ -148,9 +184,9 @@ public class CoverageMeasuresStep implements ComputationStep { public OverallLineCoverageFormula() { super( new SingleWithUncoveredMetricKeys( - CoreMetrics.OVERALL_LINES_TO_COVER_KEY, CoreMetrics.OVERALL_UNCOVERED_LINES_KEY + OVERALL_LINES_TO_COVER_KEY, OVERALL_UNCOVERED_LINES_KEY ), - CoreMetrics.OVERALL_LINE_COVERAGE_KEY); + OVERALL_LINE_COVERAGE_KEY); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/CoverageMeasuresStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/CoverageMeasuresStepTest.java index 4ef743b2535..7247919d832 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/CoverageMeasuresStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/CoverageMeasuresStepTest.java @@ -29,6 +29,8 @@ import org.sonar.server.computation.formula.coverage.LinesAndConditionsWithUncov import org.sonar.server.computation.measure.MeasureRepoEntry; import org.sonar.server.computation.measure.MeasureRepositoryRule; import org.sonar.server.computation.metric.MetricRepositoryRule; +import org.sonar.server.computation.period.Period; +import org.sonar.server.computation.period.PeriodsHolderRule; import static org.assertj.core.api.Assertions.assertThat; import static org.sonar.server.computation.component.Component.Type.DIRECTORY; @@ -51,7 +53,7 @@ public class CoverageMeasuresStepTest { @Rule public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule(); - + @Rule public MetricRepositoryRule metricRepository = new MetricRepositoryRule() .add(CoreMetrics.LINES_TO_COVER) @@ -103,69 +105,118 @@ public class CoverageMeasuresStepTest { } @Test - public void verify_aggregates_values_for_code_line_and_branch_Coverage() { + public void verify_aggregates_values_for_ut_lines_and_conditions() { + LinesAndConditionsWithUncoveredMetricKeys metricKeys = new LinesAndConditionsWithUncoveredMetricKeys( + CoreMetrics.LINES_TO_COVER_KEY, CoreMetrics.CONDITIONS_TO_COVER_KEY, + CoreMetrics.UNCOVERED_LINES_KEY, CoreMetrics.UNCOVERED_CONDITIONS_KEY + ); + verify_lines_and_conditions_aggregates_values(metricKeys); + } + + @Test + public void verify_aggregates_values_for_it_lines_and_conditions() { + LinesAndConditionsWithUncoveredMetricKeys metricKeys = new LinesAndConditionsWithUncoveredMetricKeys( + CoreMetrics.IT_LINES_TO_COVER_KEY, CoreMetrics.IT_CONDITIONS_TO_COVER_KEY, + CoreMetrics.IT_UNCOVERED_LINES_KEY, CoreMetrics.IT_UNCOVERED_CONDITIONS_KEY + ); + verify_lines_and_conditions_aggregates_values(metricKeys); + } + + @Test + public void verify_aggregates_values_for_overall_lines_and_conditions() { + LinesAndConditionsWithUncoveredMetricKeys metricKeys = new LinesAndConditionsWithUncoveredMetricKeys( + CoreMetrics.OVERALL_LINES_TO_COVER_KEY, CoreMetrics.OVERALL_CONDITIONS_TO_COVER_KEY, + CoreMetrics.OVERALL_UNCOVERED_LINES_KEY, CoreMetrics.OVERALL_UNCOVERED_CONDITIONS_KEY + ); + verify_lines_and_conditions_aggregates_values(metricKeys); + } + + private void verify_lines_and_conditions_aggregates_values(LinesAndConditionsWithUncoveredMetricKeys metricKeys) { + 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(); + + MeasureRepoEntry[] nonFileRepoEntries = { + 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(DIRECTORY_REF))).contains(nonFileRepoEntries); + assertThat(toEntries(measureRepository.getAddedRawMeasures(SUB_MODULE_REF))).contains(nonFileRepoEntries); + assertThat(toEntries(measureRepository.getAddedRawMeasures(MODULE_REF))).contains(nonFileRepoEntries); + assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).contains(nonFileRepoEntries); + } + + @Test + public void verify_aggregates_values_for_code_line_and_branch_coverage() { LinesAndConditionsWithUncoveredMetricKeys metricKeys = new LinesAndConditionsWithUncoveredMetricKeys( CoreMetrics.LINES_TO_COVER_KEY, CoreMetrics.CONDITIONS_TO_COVER_KEY, CoreMetrics.UNCOVERED_LINES_KEY, CoreMetrics.UNCOVERED_CONDITIONS_KEY - ); + ); String codeCoverageKey = CoreMetrics.COVERAGE_KEY; String lineCoverageKey = CoreMetrics.LINE_COVERAGE_KEY; String branchCoverageKey = CoreMetrics.BRANCH_COVERAGE_KEY; - verify_aggregates_values(metricKeys, codeCoverageKey, lineCoverageKey, branchCoverageKey); + verify_coverage_aggregates_values(metricKeys, codeCoverageKey, lineCoverageKey, branchCoverageKey); } @Test - public void verify_aggregates_values_for_IT_code_line_and_branch_Coverage() { + public void verify_aggregates_values_for_IT_code_line_and_branch_coverage() { LinesAndConditionsWithUncoveredMetricKeys metricKeys = new LinesAndConditionsWithUncoveredMetricKeys( CoreMetrics.IT_LINES_TO_COVER_KEY, CoreMetrics.IT_CONDITIONS_TO_COVER_KEY, CoreMetrics.IT_UNCOVERED_LINES_KEY, CoreMetrics.IT_UNCOVERED_CONDITIONS_KEY - ); + ); String codeCoverageKey = CoreMetrics.IT_COVERAGE_KEY; String lineCoverageKey = CoreMetrics.IT_LINE_COVERAGE_KEY; String branchCoverageKey = CoreMetrics.IT_BRANCH_COVERAGE_KEY; - verify_aggregates_values(metricKeys, codeCoverageKey, lineCoverageKey, branchCoverageKey); + verify_coverage_aggregates_values(metricKeys, codeCoverageKey, lineCoverageKey, branchCoverageKey); } @Test - public void verify_aggregates_values_for_Overall_code_line_and_branch_Coverage() { + public void verify_aggregates_values_for_Overall_code_line_and_branch_coverage() { LinesAndConditionsWithUncoveredMetricKeys metricKeys = new LinesAndConditionsWithUncoveredMetricKeys( CoreMetrics.OVERALL_LINES_TO_COVER_KEY, CoreMetrics.OVERALL_CONDITIONS_TO_COVER_KEY, CoreMetrics.OVERALL_UNCOVERED_LINES_KEY, CoreMetrics.OVERALL_UNCOVERED_CONDITIONS_KEY - ); + ); String codeCoverageKey = CoreMetrics.OVERALL_COVERAGE_KEY; String lineCoverageKey = CoreMetrics.OVERALL_LINE_COVERAGE_KEY; String branchCoverageKey = CoreMetrics.OVERALL_BRANCH_COVERAGE_KEY; - verify_aggregates_values(metricKeys, codeCoverageKey, lineCoverageKey, branchCoverageKey); + verify_coverage_aggregates_values(metricKeys, codeCoverageKey, lineCoverageKey, branchCoverageKey); } - private void verify_aggregates_values(LinesAndConditionsWithUncoveredMetricKeys metricKeys, String codeCoverageKey, String lineCoverageKey, String branchCoverageKey) { + private void verify_coverage_aggregates_values(LinesAndConditionsWithUncoveredMetricKeys metricKeys, String codeCoverageKey, String lineCoverageKey, String branchCoverageKey) { measureRepository - .addRawMeasure(FILE_1_REF, metricKeys.getLines(), newMeasureBuilder().create(3000L)) - .addRawMeasure(FILE_1_REF, metricKeys.getConditions(), newMeasureBuilder().create(300L)) - .addRawMeasure(FILE_1_REF, metricKeys.getUncoveredLines(), newMeasureBuilder().create(30L)) - .addRawMeasure(FILE_1_REF, metricKeys.getUncoveredConditions(), newMeasureBuilder().create(9L)) - - .addRawMeasure(FILE_2_REF, metricKeys.getLines(), newMeasureBuilder().create(2000L)) - .addRawMeasure(FILE_2_REF, metricKeys.getConditions(), newMeasureBuilder().create(400L)) - .addRawMeasure(FILE_2_REF, metricKeys.getUncoveredLines(), newMeasureBuilder().create(200L)) - .addRawMeasure(FILE_2_REF, metricKeys.getUncoveredConditions(), newMeasureBuilder().create(16L)) + .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(UNIT_TEST_FILE_REF, metricKeys.getLines(), newMeasureBuilder().create(1000L)) - .addRawMeasure(UNIT_TEST_FILE_REF, metricKeys.getConditions(), newMeasureBuilder().create(100L)) - .addRawMeasure(UNIT_TEST_FILE_REF, metricKeys.getUncoveredLines(), newMeasureBuilder().create(10L)) - .addRawMeasure(UNIT_TEST_FILE_REF, metricKeys.getUncoveredConditions(), newMeasureBuilder().create(3L)); + .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(); - assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_1_REF))).containsOnly( + assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_1_REF))).contains( entryOf(codeCoverageKey, newMeasureBuilder().create(98.8d)), entryOf(lineCoverageKey, newMeasureBuilder().create(99d)), entryOf(branchCoverageKey, newMeasureBuilder().create(97d)) ); - assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_2_REF))).containsOnly( + assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_2_REF))).contains( entryOf(codeCoverageKey, newMeasureBuilder().create(91d)), entryOf(lineCoverageKey, newMeasureBuilder().create(90d)), entryOf(branchCoverageKey, newMeasureBuilder().create(96d)) @@ -178,10 +229,10 @@ public class CoverageMeasuresStepTest { entryOf(branchCoverageKey, newMeasureBuilder().create(96.4d)) }; - assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_REF))).containsOnly(nonFileRepoEntries); - assertThat(toEntries(measureRepository.getAddedRawMeasures(SUB_MODULE_REF))).containsOnly(nonFileRepoEntries); - assertThat(toEntries(measureRepository.getAddedRawMeasures(MODULE_REF))).containsOnly(nonFileRepoEntries); - assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).containsOnly(nonFileRepoEntries); + assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_REF))).contains(nonFileRepoEntries); + assertThat(toEntries(measureRepository.getAddedRawMeasures(SUB_MODULE_REF))).contains(nonFileRepoEntries); + assertThat(toEntries(measureRepository.getAddedRawMeasures(MODULE_REF))).contains(nonFileRepoEntries); + assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).contains(nonFileRepoEntries); } } |