aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-07-21 18:26:10 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-07-23 18:00:38 +0200
commit79ea8743f2fc5fb7e24ee99dc76da025fd5efd7d (patch)
tree34e0357edd748bc60429f749a63522049f644cbc /server
parent57706bff285689865f34afaee47a031375ac874c (diff)
downloadsonarqube-79ea8743f2fc5fb7e24ee99dc76da025fd5efd7d.tar.gz
sonarqube-79ea8743f2fc5fb7e24ee99dc76da025fd5efd7d.zip
SONAR-6605 Move coverage measures with variations to NewCoverageMeasuresStep
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/CoverageMeasuresStep.java133
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/NewCoverageMeasuresStep.java125
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/CoverageMeasuresStepTest.java137
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/NewCoverageMeasuresStepTest.java168
4 files changed, 278 insertions, 285 deletions
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 4046dc6dfce..9aa3d0100f6 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
@@ -26,51 +26,36 @@ import org.sonar.server.computation.formula.Formula;
import org.sonar.server.computation.formula.FormulaExecutorComponentVisitor;
import org.sonar.server.computation.formula.coverage.LinesAndConditionsWithUncoveredFormula;
import org.sonar.server.computation.formula.coverage.LinesAndConditionsWithUncoveredMetricKeys;
-import org.sonar.server.computation.formula.coverage.LinesAndConditionsWithUncoveredVariationFormula;
import org.sonar.server.computation.formula.coverage.SingleWithUncoveredFormula;
import org.sonar.server.computation.formula.coverage.SingleWithUncoveredMetricKeys;
-import org.sonar.server.computation.formula.coverage.SingleWithUncoveredVariationFormula;
import org.sonar.server.computation.measure.MeasureRepository;
import org.sonar.server.computation.metric.MetricRepository;
-import org.sonar.server.computation.period.PeriodsHolder;
/**
* 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
- new CodeCoverageFormula(),
- new NewCodeCoverageFormula(),
- new ItCoverageFormula(),
- new NewItCoverageFormula(),
- new OverallCodeCoverageFormula(),
- new NewOverallCodeCoverageFormula(),
- // branch
- new BranchCoverageFormula(),
- new NewBranchCoverageFormula(),
- new ItBranchCoverageFormula(),
- new NewItBranchCoverageFormula(),
- new OverallBranchCoverageFormula(),
- new NewOverallBranchCoverageFormula(),
- // line
- new LineCoverageFormula(),
- new NewLineCoverageFormula(),
- new ItLineCoverageFormula(),
- new NewItLinesCoverageFormula(),
- new OverallLineCoverageFormula(),
- new NewOverallLineCoverageFormula()
- );
+ // code
+ new CodeCoverageFormula(),
+ new ItCoverageFormula(),
+ new OverallCodeCoverageFormula(),
+ // branch
+ new BranchCoverageFormula(),
+ new ItBranchCoverageFormula(),
+ new OverallBranchCoverageFormula(),
+ // line
+ new LineCoverageFormula(),
+ new ItLineCoverageFormula(),
+ new OverallLineCoverageFormula()
+ );
private final TreeRootHolder treeRootHolder;
- private final PeriodsHolder periodsHolder;
private final MetricRepository metricRepository;
private final MeasureRepository measureRepository;
- public CoverageMeasuresStep(TreeRootHolder treeRootHolder,
- PeriodsHolder periodsHolder, MetricRepository metricRepository, MeasureRepository measureRepository) {
+ public CoverageMeasuresStep(TreeRootHolder treeRootHolder, MetricRepository metricRepository, MeasureRepository measureRepository) {
this.treeRootHolder = treeRootHolder;
- this.periodsHolder = periodsHolder;
this.metricRepository = metricRepository;
this.measureRepository = measureRepository;
}
@@ -78,7 +63,6 @@ public class CoverageMeasuresStep implements ComputationStep {
@Override
public void execute() {
FormulaExecutorComponentVisitor.newBuilder(metricRepository, measureRepository)
- .withVariationSupport(periodsHolder)
.buildFor(COVERAGE_FORMULAS)
.visit(treeRootHolder.getRoot());
}
@@ -94,17 +78,6 @@ public class CoverageMeasuresStep implements ComputationStep {
}
}
- private static class NewCodeCoverageFormula extends LinesAndConditionsWithUncoveredVariationFormula {
- public NewCodeCoverageFormula() {
- super(
- new LinesAndConditionsWithUncoveredMetricKeys(
- CoreMetrics.NEW_LINES_TO_COVER_KEY, CoreMetrics.NEW_CONDITIONS_TO_COVER_KEY,
- CoreMetrics.NEW_UNCOVERED_LINES_KEY, CoreMetrics.NEW_UNCOVERED_CONDITIONS_KEY
- ),
- CoreMetrics.NEW_COVERAGE_KEY);
- }
- }
-
private static class ItCoverageFormula extends LinesAndConditionsWithUncoveredFormula {
private ItCoverageFormula() {
super(
@@ -116,18 +89,6 @@ public class CoverageMeasuresStep implements ComputationStep {
}
}
- private static class NewItCoverageFormula extends LinesAndConditionsWithUncoveredVariationFormula {
- private NewItCoverageFormula() {
- super(
- new LinesAndConditionsWithUncoveredMetricKeys(
- CoreMetrics.NEW_IT_LINES_TO_COVER_KEY, CoreMetrics.NEW_IT_CONDITIONS_TO_COVER_KEY,
- CoreMetrics.NEW_IT_UNCOVERED_LINES_KEY, CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS_KEY
- ),
- CoreMetrics.NEW_IT_COVERAGE_KEY);
- }
-
- }
-
private static class OverallCodeCoverageFormula extends LinesAndConditionsWithUncoveredFormula {
public OverallCodeCoverageFormula() {
super(
@@ -139,17 +100,6 @@ public class CoverageMeasuresStep implements ComputationStep {
}
}
- private static class NewOverallCodeCoverageFormula extends LinesAndConditionsWithUncoveredVariationFormula {
- public NewOverallCodeCoverageFormula() {
- super(
- new LinesAndConditionsWithUncoveredMetricKeys(
- CoreMetrics.NEW_OVERALL_LINES_TO_COVER_KEY, CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER_KEY,
- CoreMetrics.NEW_OVERALL_UNCOVERED_LINES_KEY, CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS_KEY
- ),
- CoreMetrics.NEW_OVERALL_COVERAGE_KEY);
- }
- }
-
private static class BranchCoverageFormula extends SingleWithUncoveredFormula {
public BranchCoverageFormula() {
super(
@@ -160,16 +110,6 @@ public class CoverageMeasuresStep implements ComputationStep {
}
}
- private static class NewBranchCoverageFormula extends SingleWithUncoveredVariationFormula {
- public NewBranchCoverageFormula() {
- super(
- new SingleWithUncoveredMetricKeys(
- CoreMetrics.NEW_CONDITIONS_TO_COVER_KEY, CoreMetrics.NEW_UNCOVERED_CONDITIONS_KEY
- ),
- CoreMetrics.NEW_BRANCH_COVERAGE_KEY);
- }
- }
-
private static class ItBranchCoverageFormula extends SingleWithUncoveredFormula {
public ItBranchCoverageFormula() {
super(
@@ -180,16 +120,6 @@ public class CoverageMeasuresStep implements ComputationStep {
}
}
- private static class NewItBranchCoverageFormula extends SingleWithUncoveredVariationFormula {
- public NewItBranchCoverageFormula() {
- super(
- new SingleWithUncoveredMetricKeys(
- CoreMetrics.NEW_IT_CONDITIONS_TO_COVER_KEY, CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS_KEY
- ),
- CoreMetrics.NEW_IT_BRANCH_COVERAGE_KEY);
- }
- }
-
private static class OverallBranchCoverageFormula extends SingleWithUncoveredFormula {
public OverallBranchCoverageFormula() {
super(
@@ -198,15 +128,6 @@ public class CoverageMeasuresStep implements ComputationStep {
}
}
- private static class NewOverallBranchCoverageFormula extends SingleWithUncoveredVariationFormula {
- public NewOverallBranchCoverageFormula() {
- super(
- new SingleWithUncoveredMetricKeys(
- CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER_KEY, CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS_KEY),
- CoreMetrics.NEW_OVERALL_BRANCH_COVERAGE_KEY);
- }
- }
-
private static class LineCoverageFormula extends SingleWithUncoveredFormula {
public LineCoverageFormula() {
super(
@@ -215,14 +136,6 @@ public class CoverageMeasuresStep implements ComputationStep {
}
}
- private static class NewLineCoverageFormula extends SingleWithUncoveredVariationFormula {
- public NewLineCoverageFormula() {
- super(
- new SingleWithUncoveredMetricKeys(CoreMetrics.NEW_LINES_TO_COVER_KEY, CoreMetrics.NEW_UNCOVERED_LINES_KEY),
- CoreMetrics.NEW_LINE_COVERAGE_KEY);
- }
- }
-
private static class ItLineCoverageFormula extends SingleWithUncoveredFormula {
public ItLineCoverageFormula() {
super(
@@ -231,14 +144,6 @@ public class CoverageMeasuresStep implements ComputationStep {
}
}
- private static class NewItLinesCoverageFormula extends SingleWithUncoveredVariationFormula {
- public NewItLinesCoverageFormula() {
- super(
- new SingleWithUncoveredMetricKeys(CoreMetrics.NEW_IT_LINES_TO_COVER_KEY, CoreMetrics.NEW_IT_UNCOVERED_LINES_KEY),
- CoreMetrics.NEW_IT_LINE_COVERAGE_KEY);
- }
- }
-
private static class OverallLineCoverageFormula extends SingleWithUncoveredFormula {
public OverallLineCoverageFormula() {
super(
@@ -249,16 +154,6 @@ public class CoverageMeasuresStep implements ComputationStep {
}
}
- private static class NewOverallLineCoverageFormula extends SingleWithUncoveredVariationFormula {
- public NewOverallLineCoverageFormula() {
- super(
- new SingleWithUncoveredMetricKeys(
- CoreMetrics.NEW_OVERALL_LINES_TO_COVER_KEY, CoreMetrics.NEW_OVERALL_UNCOVERED_LINES_KEY
- ),
- CoreMetrics.NEW_OVERALL_LINE_COVERAGE_KEY);
- }
- }
-
@Override
public String getDescription() {
return "Aggregation of coverage measures";
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/NewCoverageMeasuresStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/NewCoverageMeasuresStep.java
index c63580cb29c..ef2c0e6d70e 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/NewCoverageMeasuresStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/NewCoverageMeasuresStep.java
@@ -39,6 +39,10 @@ import org.sonar.server.computation.formula.FileAggregateContext;
import org.sonar.server.computation.formula.Formula;
import org.sonar.server.computation.formula.FormulaExecutorComponentVisitor;
import org.sonar.server.computation.formula.counter.IntVariationValue;
+import org.sonar.server.computation.formula.coverage.LinesAndConditionsWithUncoveredMetricKeys;
+import org.sonar.server.computation.formula.coverage.LinesAndConditionsWithUncoveredVariationFormula;
+import org.sonar.server.computation.formula.coverage.SingleWithUncoveredMetricKeys;
+import org.sonar.server.computation.formula.coverage.SingleWithUncoveredVariationFormula;
import org.sonar.server.computation.measure.Measure;
import org.sonar.server.computation.measure.MeasureRepository;
import org.sonar.server.computation.measure.MeasureVariations;
@@ -73,12 +77,21 @@ public class NewCoverageMeasuresStep implements ComputationStep {
FormulaExecutorComponentVisitor.newBuilder(metricRepository, measureRepository)
.withVariationSupport(periodsHolder)
.buildFor(ImmutableList.<Formula>of(
- // File coverage
- new NewCoverageOnFileFormula(batchReportReader),
+ // UT coverage
+ new NewLinesAndConditionsCoverageFormula(batchReportReader),
+ new NewCoverageFormula(),
+ new NewBranchCoverageFormula(),
+ new NewLineCoverageFormula(),
// IT File coverage
- new NewCoverageOnITFileFormula(batchReportReader),
+ new NewItLinesAndConditionsCoverageFormula(batchReportReader),
+ new NewItCoverageFormula(),
+ new NewItBranchCoverageFormula(),
+ new NewItLinesCoverageFormula(),
// Overall coverage
- new NewOverallCoverageFormula(batchReportReader)
+ new NewOverallLinesAndConditionsCoverageFormula(batchReportReader),
+ new NewOverallCodeCoverageFormula(),
+ new NewOverallBranchCoverageFormula(),
+ new NewOverallLineCoverageFormula()
))
.visit(treeRootHolder.getRoot());
}
@@ -88,8 +101,8 @@ public class NewCoverageMeasuresStep implements ComputationStep {
return "Computation of New Coverage measures";
}
- private static class NewCoverageOnFileFormula extends NewCoverageFormula {
- public NewCoverageOnFileFormula(BatchReportReader batchReportReader) {
+ private static class NewLinesAndConditionsCoverageFormula extends NewLinesAndConditionsFormula {
+ public NewLinesAndConditionsCoverageFormula(BatchReportReader batchReportReader) {
super(batchReportReader,
new NewCoverageInputMetricKeys(
CoreMetrics.COVERAGE_LINE_HITS_DATA_KEY, CoreMetrics.CONDITIONS_BY_LINE_KEY, CoreMetrics.COVERED_CONDITIONS_BY_LINE_KEY
@@ -101,8 +114,37 @@ public class NewCoverageMeasuresStep implements ComputationStep {
}
}
- private static class NewCoverageOnITFileFormula extends NewCoverageFormula {
- public NewCoverageOnITFileFormula(BatchReportReader batchReportReader) {
+ private static class NewCoverageFormula extends LinesAndConditionsWithUncoveredVariationFormula {
+ public NewCoverageFormula() {
+ super(
+ new LinesAndConditionsWithUncoveredMetricKeys(
+ CoreMetrics.NEW_LINES_TO_COVER_KEY, CoreMetrics.NEW_CONDITIONS_TO_COVER_KEY,
+ CoreMetrics.NEW_UNCOVERED_LINES_KEY, CoreMetrics.NEW_UNCOVERED_CONDITIONS_KEY
+ ),
+ CoreMetrics.NEW_COVERAGE_KEY);
+ }
+ }
+
+ private static class NewBranchCoverageFormula extends SingleWithUncoveredVariationFormula {
+ public NewBranchCoverageFormula() {
+ super(
+ new SingleWithUncoveredMetricKeys(
+ CoreMetrics.NEW_CONDITIONS_TO_COVER_KEY, CoreMetrics.NEW_UNCOVERED_CONDITIONS_KEY
+ ),
+ CoreMetrics.NEW_BRANCH_COVERAGE_KEY);
+ }
+ }
+
+ private static class NewLineCoverageFormula extends SingleWithUncoveredVariationFormula {
+ public NewLineCoverageFormula() {
+ super(
+ new SingleWithUncoveredMetricKeys(CoreMetrics.NEW_LINES_TO_COVER_KEY, CoreMetrics.NEW_UNCOVERED_LINES_KEY),
+ CoreMetrics.NEW_LINE_COVERAGE_KEY);
+ }
+ }
+
+ private static class NewItLinesAndConditionsCoverageFormula extends NewLinesAndConditionsFormula {
+ public NewItLinesAndConditionsCoverageFormula(BatchReportReader batchReportReader) {
super(batchReportReader,
new NewCoverageInputMetricKeys(
CoreMetrics.IT_COVERAGE_LINE_HITS_DATA_KEY, CoreMetrics.IT_CONDITIONS_BY_LINE_KEY, CoreMetrics.IT_COVERED_CONDITIONS_BY_LINE_KEY
@@ -114,8 +156,37 @@ public class NewCoverageMeasuresStep implements ComputationStep {
}
}
- private static class NewOverallCoverageFormula extends NewCoverageFormula {
- public NewOverallCoverageFormula(BatchReportReader batchReportReader) {
+ private static class NewItCoverageFormula extends LinesAndConditionsWithUncoveredVariationFormula {
+ private NewItCoverageFormula() {
+ super(
+ new LinesAndConditionsWithUncoveredMetricKeys(
+ CoreMetrics.NEW_IT_LINES_TO_COVER_KEY, CoreMetrics.NEW_IT_CONDITIONS_TO_COVER_KEY,
+ CoreMetrics.NEW_IT_UNCOVERED_LINES_KEY, CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS_KEY
+ ),
+ CoreMetrics.NEW_IT_COVERAGE_KEY);
+ }
+ }
+
+ private static class NewItBranchCoverageFormula extends SingleWithUncoveredVariationFormula {
+ public NewItBranchCoverageFormula() {
+ super(
+ new SingleWithUncoveredMetricKeys(
+ CoreMetrics.NEW_IT_CONDITIONS_TO_COVER_KEY, CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS_KEY
+ ),
+ CoreMetrics.NEW_IT_BRANCH_COVERAGE_KEY);
+ }
+ }
+
+ private static class NewItLinesCoverageFormula extends SingleWithUncoveredVariationFormula {
+ public NewItLinesCoverageFormula() {
+ super(
+ new SingleWithUncoveredMetricKeys(CoreMetrics.NEW_IT_LINES_TO_COVER_KEY, CoreMetrics.NEW_IT_UNCOVERED_LINES_KEY),
+ CoreMetrics.NEW_IT_LINE_COVERAGE_KEY);
+ }
+ }
+
+ private static class NewOverallLinesAndConditionsCoverageFormula extends NewLinesAndConditionsFormula {
+ public NewOverallLinesAndConditionsCoverageFormula(BatchReportReader batchReportReader) {
super(batchReportReader,
new NewCoverageInputMetricKeys(
CoreMetrics.OVERALL_COVERAGE_LINE_HITS_DATA_KEY, CoreMetrics.OVERALL_CONDITIONS_BY_LINE_KEY, CoreMetrics.OVERALL_COVERED_CONDITIONS_BY_LINE_KEY
@@ -127,12 +198,42 @@ public class NewCoverageMeasuresStep implements ComputationStep {
}
}
- public static class NewCoverageFormula implements Formula<NewCoverageCounter> {
+ private static class NewOverallCodeCoverageFormula extends LinesAndConditionsWithUncoveredVariationFormula {
+ public NewOverallCodeCoverageFormula() {
+ super(
+ new LinesAndConditionsWithUncoveredMetricKeys(
+ CoreMetrics.NEW_OVERALL_LINES_TO_COVER_KEY, CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER_KEY,
+ CoreMetrics.NEW_OVERALL_UNCOVERED_LINES_KEY, CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS_KEY
+ ),
+ CoreMetrics.NEW_OVERALL_COVERAGE_KEY);
+ }
+ }
+
+ private static class NewOverallBranchCoverageFormula extends SingleWithUncoveredVariationFormula {
+ public NewOverallBranchCoverageFormula() {
+ super(
+ new SingleWithUncoveredMetricKeys(
+ CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER_KEY, CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS_KEY),
+ CoreMetrics.NEW_OVERALL_BRANCH_COVERAGE_KEY);
+ }
+ }
+
+ private static class NewOverallLineCoverageFormula extends SingleWithUncoveredVariationFormula {
+ public NewOverallLineCoverageFormula() {
+ super(
+ new SingleWithUncoveredMetricKeys(
+ CoreMetrics.NEW_OVERALL_LINES_TO_COVER_KEY, CoreMetrics.NEW_OVERALL_UNCOVERED_LINES_KEY
+ ),
+ CoreMetrics.NEW_OVERALL_LINE_COVERAGE_KEY);
+ }
+ }
+
+ public static class NewLinesAndConditionsFormula implements Formula<NewCoverageCounter> {
private final BatchReportReader batchReportReader;
private final NewCoverageInputMetricKeys inputMetricKeys;
private final NewCoverageOutputMetricKeys outputMetricKeys;
- public NewCoverageFormula(BatchReportReader batchReportReader, NewCoverageInputMetricKeys inputMetricKeys, NewCoverageOutputMetricKeys outputMetricKeys) {
+ public NewLinesAndConditionsFormula(BatchReportReader batchReportReader, NewCoverageInputMetricKeys inputMetricKeys, NewCoverageOutputMetricKeys outputMetricKeys) {
this.batchReportReader = batchReportReader;
this.inputMetricKeys = inputMetricKeys;
this.outputMetricKeys = outputMetricKeys;
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 0be9df6afff..4ef743b2535 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
@@ -26,13 +26,9 @@ import org.sonar.api.measures.CoreMetrics;
import org.sonar.server.computation.batch.TreeRootHolderRule;
import org.sonar.server.computation.component.FileAttributes;
import org.sonar.server.computation.formula.coverage.LinesAndConditionsWithUncoveredMetricKeys;
-import org.sonar.server.computation.measure.Measure;
import org.sonar.server.computation.measure.MeasureRepoEntry;
import org.sonar.server.computation.measure.MeasureRepositoryRule;
-import org.sonar.server.computation.measure.MeasureVariations;
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;
@@ -55,12 +51,7 @@ public class CoverageMeasuresStepTest {
@Rule
public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule();
- @Rule
- public PeriodsHolderRule periodsHolder = new PeriodsHolderRule()
- .setPeriods(
- new Period(2, "mode2", null, 52L, 96L),
- new Period(5, "mode5", null, 52L, 96L)
- );
+
@Rule
public MetricRepositoryRule metricRepository = new MetricRepositoryRule()
.add(CoreMetrics.LINES_TO_COVER)
@@ -68,47 +59,28 @@ public class CoverageMeasuresStepTest {
.add(CoreMetrics.UNCOVERED_LINES)
.add(CoreMetrics.UNCOVERED_CONDITIONS)
.add(CoreMetrics.COVERAGE)
- .add(CoreMetrics.NEW_LINES_TO_COVER)
- .add(CoreMetrics.NEW_CONDITIONS_TO_COVER)
- .add(CoreMetrics.NEW_UNCOVERED_LINES)
- .add(CoreMetrics.NEW_UNCOVERED_CONDITIONS)
- .add(CoreMetrics.NEW_COVERAGE)
+ .add(CoreMetrics.BRANCH_COVERAGE)
+ .add(CoreMetrics.LINE_COVERAGE)
+
.add(CoreMetrics.IT_LINES_TO_COVER)
.add(CoreMetrics.IT_CONDITIONS_TO_COVER)
.add(CoreMetrics.IT_UNCOVERED_LINES)
.add(CoreMetrics.IT_UNCOVERED_CONDITIONS)
.add(CoreMetrics.IT_COVERAGE)
- .add(CoreMetrics.NEW_IT_LINES_TO_COVER)
- .add(CoreMetrics.NEW_IT_CONDITIONS_TO_COVER)
- .add(CoreMetrics.NEW_IT_UNCOVERED_LINES)
- .add(CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS)
- .add(CoreMetrics.NEW_IT_COVERAGE)
+ .add(CoreMetrics.IT_BRANCH_COVERAGE)
+ .add(CoreMetrics.IT_LINE_COVERAGE)
+
.add(CoreMetrics.OVERALL_LINES_TO_COVER)
.add(CoreMetrics.OVERALL_CONDITIONS_TO_COVER)
.add(CoreMetrics.OVERALL_UNCOVERED_LINES)
.add(CoreMetrics.OVERALL_UNCOVERED_CONDITIONS)
.add(CoreMetrics.OVERALL_COVERAGE)
- .add(CoreMetrics.NEW_OVERALL_LINES_TO_COVER)
- .add(CoreMetrics.NEW_OVERALL_UNCOVERED_LINES)
- .add(CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS)
- .add(CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER)
- .add(CoreMetrics.NEW_OVERALL_COVERAGE)
- .add(CoreMetrics.BRANCH_COVERAGE)
- .add(CoreMetrics.NEW_BRANCH_COVERAGE)
- .add(CoreMetrics.IT_BRANCH_COVERAGE)
- .add(CoreMetrics.NEW_IT_BRANCH_COVERAGE)
.add(CoreMetrics.OVERALL_BRANCH_COVERAGE)
- .add(CoreMetrics.NEW_OVERALL_BRANCH_COVERAGE)
- .add(CoreMetrics.LINE_COVERAGE)
- .add(CoreMetrics.NEW_LINE_COVERAGE)
- .add(CoreMetrics.IT_LINE_COVERAGE)
- .add(CoreMetrics.NEW_IT_LINE_COVERAGE)
- .add(CoreMetrics.OVERALL_LINE_COVERAGE)
- .add(CoreMetrics.NEW_OVERALL_LINE_COVERAGE);
+ .add(CoreMetrics.OVERALL_LINE_COVERAGE);
@Rule
public MeasureRepositoryRule measureRepository = MeasureRepositoryRule.create(treeRootHolder, metricRepository);
- CoverageMeasuresStep underTest = new CoverageMeasuresStep(treeRootHolder, periodsHolder, metricRepository, measureRepository);
+ CoverageMeasuresStep underTest = new CoverageMeasuresStep(treeRootHolder, metricRepository, measureRepository);
@Before
public void setUp() throws Exception {
@@ -135,7 +107,7 @@ public class CoverageMeasuresStepTest {
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;
@@ -148,7 +120,7 @@ public class CoverageMeasuresStepTest {
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;
@@ -161,7 +133,7 @@ public class CoverageMeasuresStepTest {
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;
@@ -212,89 +184,4 @@ public class CoverageMeasuresStepTest {
assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).containsOnly(nonFileRepoEntries);
}
- @Test
- public void verify_aggregates_variations_for_new_code_line_and_branch_Coverage() {
- LinesAndConditionsWithUncoveredMetricKeys metricKeys = new LinesAndConditionsWithUncoveredMetricKeys(
- CoreMetrics.NEW_LINES_TO_COVER_KEY, CoreMetrics.NEW_CONDITIONS_TO_COVER_KEY,
- CoreMetrics.NEW_UNCOVERED_LINES_KEY, CoreMetrics.NEW_UNCOVERED_CONDITIONS_KEY
- );
- String codeCoverageKey = CoreMetrics.NEW_COVERAGE_KEY;
- String lineCoverageKey = CoreMetrics.NEW_LINE_COVERAGE_KEY;
- String branchCoverageKey = CoreMetrics.NEW_BRANCH_COVERAGE_KEY;
-
- verify_aggregates_variations(metricKeys, codeCoverageKey, lineCoverageKey, branchCoverageKey);
- }
-
- @Test
- public void verify_aggregates_variations_for_new_IT_code_line_and_branch_Coverage() {
- LinesAndConditionsWithUncoveredMetricKeys metricKeys = new LinesAndConditionsWithUncoveredMetricKeys(
- CoreMetrics.NEW_IT_LINES_TO_COVER_KEY, CoreMetrics.NEW_IT_CONDITIONS_TO_COVER_KEY,
- CoreMetrics.NEW_IT_UNCOVERED_LINES_KEY, CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS_KEY
- );
- String codeCoverageKey = CoreMetrics.NEW_IT_COVERAGE_KEY;
- String lineCoverageKey = CoreMetrics.NEW_IT_LINE_COVERAGE_KEY;
- String branchCoverageKey = CoreMetrics.NEW_IT_BRANCH_COVERAGE_KEY;
-
- verify_aggregates_variations(metricKeys, codeCoverageKey, lineCoverageKey, branchCoverageKey);
- }
-
- @Test
- public void verify_aggregates_variations_for_new_Overall_code_line_and_branch_Coverage() {
- LinesAndConditionsWithUncoveredMetricKeys metricKeys = new LinesAndConditionsWithUncoveredMetricKeys(
- CoreMetrics.NEW_OVERALL_LINES_TO_COVER_KEY, CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER_KEY,
- CoreMetrics.NEW_OVERALL_UNCOVERED_LINES_KEY, CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS_KEY
- );
- String codeCoverageKey = CoreMetrics.NEW_OVERALL_COVERAGE_KEY;
- String lineCoverageKey = CoreMetrics.NEW_OVERALL_LINE_COVERAGE_KEY;
- String branchCoverageKey = CoreMetrics.NEW_OVERALL_BRANCH_COVERAGE_KEY;
-
- verify_aggregates_variations(metricKeys, codeCoverageKey, lineCoverageKey, branchCoverageKey);
- }
-
- private void verify_aggregates_variations(LinesAndConditionsWithUncoveredMetricKeys metricKeys, String codeCoverageKey, String lineCoverageKey, String branchCoverageKey) {
- measureRepository
- .addRawMeasure(FILE_1_REF, metricKeys.getLines(), measureWithVariation(3000L, 2000L))
- .addRawMeasure(FILE_1_REF, metricKeys.getConditions(), measureWithVariation(300L, 400L))
- .addRawMeasure(FILE_1_REF, metricKeys.getUncoveredLines(), measureWithVariation(30L, 200L))
- .addRawMeasure(FILE_1_REF, metricKeys.getUncoveredConditions(), measureWithVariation(9L, 16L))
-
- .addRawMeasure(FILE_2_REF, metricKeys.getLines(), measureWithVariation(2000L, 3000L))
- .addRawMeasure(FILE_2_REF, metricKeys.getConditions(), measureWithVariation(400L, 300L))
- .addRawMeasure(FILE_2_REF, metricKeys.getUncoveredLines(), measureWithVariation(200L, 30L))
- .addRawMeasure(FILE_2_REF, metricKeys.getUncoveredConditions(), measureWithVariation(16L, 9L))
-
- .addRawMeasure(UNIT_TEST_FILE_REF, metricKeys.getLines(), measureWithVariation(1000L, 2000L))
- .addRawMeasure(UNIT_TEST_FILE_REF, metricKeys.getConditions(), measureWithVariation(100L, 400L))
- .addRawMeasure(UNIT_TEST_FILE_REF, metricKeys.getUncoveredLines(), measureWithVariation(10L, 200L))
- .addRawMeasure(UNIT_TEST_FILE_REF, metricKeys.getUncoveredConditions(), measureWithVariation(3L, 16L));
-
- underTest.execute();
-
- assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_1_REF))).containsOnly(
- entryOf(codeCoverageKey, measureWithVariation(98.8d, 91d)),
- entryOf(lineCoverageKey, measureWithVariation(99d, 90d)),
- entryOf(branchCoverageKey, measureWithVariation(97d, 96d))
- );
- assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_2_REF))).containsOnly(
- entryOf(codeCoverageKey, measureWithVariation(91d, 98.8d)),
- entryOf(lineCoverageKey, measureWithVariation(90d, 99d)),
- entryOf(branchCoverageKey, measureWithVariation(96d, 97d))
- );
- assertThat(toEntries(measureRepository.getAddedRawMeasures(UNIT_TEST_FILE_REF))).isEmpty();
-
- MeasureRepoEntry[] nonFileRepoEntries = {
- entryOf(codeCoverageKey, measureWithVariation(95.5d, 95.5d)),
- entryOf(lineCoverageKey, measureWithVariation(95.4d, 95.4d)),
- entryOf(branchCoverageKey, measureWithVariation(96.4d, 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);
- }
-
- private static Measure measureWithVariation(double variation2, double variation5) {
- return newMeasureBuilder().setVariations(new MeasureVariations(null, variation2, null, null, variation5)).createNoValue();
- }
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/NewCoverageMeasuresStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/NewCoverageMeasuresStepTest.java
index 44c94f3cd7c..626c7f95239 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/NewCoverageMeasuresStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/NewCoverageMeasuresStepTest.java
@@ -30,6 +30,7 @@ import org.sonar.server.computation.batch.TreeRootHolderRule;
import org.sonar.server.computation.component.Component;
import org.sonar.server.computation.component.DumbComponent;
import org.sonar.server.computation.component.FileAttributes;
+import org.sonar.server.computation.formula.coverage.LinesAndConditionsWithUncoveredMetricKeys;
import org.sonar.server.computation.measure.Measure;
import org.sonar.server.computation.measure.MeasureRepoEntry;
import org.sonar.server.computation.measure.MeasureRepositoryRule;
@@ -60,20 +61,30 @@ import static org.sonar.server.computation.measure.MeasureRepoEntry.toEntries;
import static org.sonar.server.computation.measure.MeasureVariations.newMeasureVariationsBuilder;
public class NewCoverageMeasuresStepTest {
- private static final DumbComponent MULTIPLE_FILES_TREE = builder(PROJECT, 1)
+
+ private static final int ROOT_REF = 1;
+ private static final int MODULE_REF = 11;
+ private static final int SUB_MODULE_REF = 111;
+ private static final int DIRECTORY_1_REF = 1111;
+ private static final int FILE_1_REF = 11111;
+ private static final int DIRECTORY_2_REF = 1112;
+ private static final int FILE_2_REF = 11121;
+ private static final int FILE_3_REF = 11122;
+
+ private static final DumbComponent MULTIPLE_FILES_TREE = builder(PROJECT, ROOT_REF)
.addChildren(
- builder(MODULE, 11)
+ builder(MODULE, MODULE_REF)
.addChildren(
- builder(MODULE, 111)
+ builder(MODULE, SUB_MODULE_REF)
.addChildren(
- builder(DIRECTORY, 1111)
+ builder(DIRECTORY, DIRECTORY_1_REF)
.addChildren(
- builder(FILE, 11111).build()
+ builder(FILE, FILE_1_REF).build()
).build(),
- builder(DIRECTORY, 1112)
+ builder(DIRECTORY, DIRECTORY_2_REF)
.addChildren(
- builder(FILE, 11121).build(),
- builder(FILE, 11122).build()
+ builder(FILE, FILE_2_REF).build(),
+ builder(FILE, FILE_3_REF).build()
).build()
)
.build()
@@ -95,6 +106,9 @@ public class NewCoverageMeasuresStepTest {
.add(CoreMetrics.NEW_UNCOVERED_LINES)
.add(CoreMetrics.NEW_CONDITIONS_TO_COVER)
.add(CoreMetrics.NEW_UNCOVERED_CONDITIONS)
+ .add(CoreMetrics.NEW_COVERAGE)
+ .add(CoreMetrics.NEW_BRANCH_COVERAGE)
+ .add(CoreMetrics.NEW_LINE_COVERAGE)
.add(CoreMetrics.IT_COVERAGE_LINE_HITS_DATA)
.add(CoreMetrics.IT_CONDITIONS_BY_LINE)
@@ -103,6 +117,9 @@ public class NewCoverageMeasuresStepTest {
.add(CoreMetrics.NEW_IT_UNCOVERED_LINES)
.add(CoreMetrics.NEW_IT_CONDITIONS_TO_COVER)
.add(CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS)
+ .add(CoreMetrics.NEW_IT_COVERAGE)
+ .add(CoreMetrics.NEW_IT_BRANCH_COVERAGE)
+ .add(CoreMetrics.NEW_IT_LINE_COVERAGE)
.add(CoreMetrics.OVERALL_COVERAGE_LINE_HITS_DATA)
.add(CoreMetrics.OVERALL_CONDITIONS_BY_LINE)
@@ -110,13 +127,17 @@ public class NewCoverageMeasuresStepTest {
.add(CoreMetrics.NEW_OVERALL_LINES_TO_COVER)
.add(CoreMetrics.NEW_OVERALL_UNCOVERED_LINES)
.add(CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER)
- .add(CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS);
+ .add(CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS)
+ .add(CoreMetrics.NEW_OVERALL_COVERAGE)
+ .add(CoreMetrics.NEW_OVERALL_BRANCH_COVERAGE)
+ .add(CoreMetrics.NEW_OVERALL_LINE_COVERAGE)
+ ;
@Rule
public MeasureRepositoryRule measureRepository = MeasureRepositoryRule.create(treeRootHolder, metricRepository);
private NewCoverageMeasuresStep underTest = new NewCoverageMeasuresStep(treeRootHolder, periodsHolder, reportReader,
measureRepository, metricRepository);
- public static final DumbComponent FILE_COMPONENT = DumbComponent.builder(Component.Type.FILE, 1)
+ public static final DumbComponent FILE_COMPONENT = DumbComponent.builder(Component.Type.FILE, FILE_1_REF)
.setFileAttributes(new FileAttributes(false, null)).build();
@Before
@@ -128,7 +149,7 @@ public class NewCoverageMeasuresStepTest {
@Test
public void no_measure_for_PROJECT_component() {
- treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).build());
+ treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, ROOT_REF).build());
underTest.execute();
@@ -137,7 +158,7 @@ public class NewCoverageMeasuresStepTest {
@Test
public void no_measure_for_MODULE_component() {
- treeRootHolder.setRoot(DumbComponent.builder(Component.Type.MODULE, 1).build());
+ treeRootHolder.setRoot(DumbComponent.builder(Component.Type.MODULE, MODULE_REF).build());
underTest.execute();
@@ -146,7 +167,7 @@ public class NewCoverageMeasuresStepTest {
@Test
public void no_measure_for_DIRECTORY_component() {
- treeRootHolder.setRoot(DumbComponent.builder(Component.Type.DIRECTORY, 1).build());
+ treeRootHolder.setRoot(DumbComponent.builder(Component.Type.DIRECTORY, DIRECTORY_1_REF).build());
underTest.execute();
@@ -155,7 +176,7 @@ public class NewCoverageMeasuresStepTest {
@Test
public void no_measure_for_unit_test_FILE_component() {
- treeRootHolder.setRoot(DumbComponent.builder(Component.Type.FILE, 1).setFileAttributes(new FileAttributes(true, null)).build());
+ treeRootHolder.setRoot(DumbComponent.builder(Component.Type.FILE, FILE_1_REF).setFileAttributes(new FileAttributes(true, null)).build());
underTest.execute();
@@ -164,7 +185,7 @@ public class NewCoverageMeasuresStepTest {
@Test
public void no_measures_for_FILE_component_without_code() {
- treeRootHolder.setRoot(DumbComponent.builder(Component.Type.FILE, 1).setFileAttributes(new FileAttributes(false, null)).build());
+ treeRootHolder.setRoot(DumbComponent.builder(Component.Type.FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, null)).build());
underTest.execute();
@@ -218,7 +239,7 @@ public class NewCoverageMeasuresStepTest {
@Test
public void no_measures_for_FILE_component_without_CoverageData() {
- DumbComponent fileComponent = DumbComponent.builder(Component.Type.FILE, 1).setFileAttributes(new FileAttributes(false, null)).build();
+ DumbComponent fileComponent = DumbComponent.builder(Component.Type.FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, null)).build();
treeRootHolder.setRoot(fileComponent);
reportReader.putChangesets(Changesets.newBuilder()
@@ -291,7 +312,7 @@ public class NewCoverageMeasuresStepTest {
underTest.execute();
- assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_COMPONENT.getRef()))).containsOnly(
+ assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_COMPONENT.getRef()))).contains(
entryOf(newLinesToCover, createMeasure(2d, null)),
entryOf(newUncoveredLines, createMeasure(1d, null)),
entryOf(newConditionsToCover, createMeasure(0d, null)),
@@ -355,39 +376,39 @@ public class NewCoverageMeasuresStepTest {
newLinesToCover, newUncoveredLines, newConditionsToCover, newUncoveredConditions);
treeRootHolder.setRoot(MULTIPLE_FILES_TREE);
- defineChangeSetsAndMeasures(11111, metricKeys, new MeasureValues(3, 4, 1), new MeasureValues(0, 3, 2));
- defineChangeSetsAndMeasures(11121, metricKeys, new MeasureValues(0, 14, 6), new MeasureValues(0, 13, 7));
- defineChangeSetsAndMeasures(11122, metricKeys, new MeasureValues(3, 4, 1), new MeasureValues(1, 13, 7));
+ defineChangeSetsAndMeasures(FILE_1_REF, metricKeys, new MeasureValues(3, 4, 1), new MeasureValues(0, 3, 2));
+ defineChangeSetsAndMeasures(FILE_2_REF, metricKeys, new MeasureValues(0, 14, 6), new MeasureValues(0, 13, 7));
+ defineChangeSetsAndMeasures(FILE_3_REF, metricKeys, new MeasureValues(3, 4, 1), new MeasureValues(1, 13, 7));
underTest.execute();
// files
- assertThat(toEntries(measureRepository.getAddedRawMeasures(11111))).containsOnly(
+ assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_1_REF))).contains(
entryOf(metricKeys.newLinesToCover, createMeasure(5d, 3d)),
entryOf(metricKeys.newUncoveredLines, createMeasure(3d, 2d)),
entryOf(metricKeys.newConditionsToCover, createMeasure(7d, 3d)),
entryOf(metricKeys.newUncoveredConditions, createMeasure(4d, 1d))
);
- assertThat(toEntries(measureRepository.getAddedRawMeasures(11121))).containsOnly(
+ assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_2_REF))).contains(
entryOf(metricKeys.newLinesToCover, createMeasure(5d, 3d)),
entryOf(metricKeys.newUncoveredLines, createMeasure(4d, 2d)),
entryOf(metricKeys.newConditionsToCover, createMeasure(27d, 13d)),
entryOf(metricKeys.newUncoveredConditions, createMeasure(14d, 6d))
);
- assertThat(toEntries(measureRepository.getAddedRawMeasures(11122))).containsOnly(
+ assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_3_REF))).contains(
entryOf(metricKeys.newLinesToCover, createMeasure(5d, 3d)),
entryOf(metricKeys.newUncoveredLines, createMeasure(2d, 1d)),
entryOf(metricKeys.newConditionsToCover, createMeasure(17d, 13d)),
entryOf(metricKeys.newUncoveredConditions, createMeasure(9d, 6d))
);
// directories
- assertThat(toEntries(measureRepository.getAddedRawMeasures(1111))).containsOnly(
+ assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_1_REF))).contains(
entryOf(metricKeys.newLinesToCover, createMeasure(5d, 3d)),
entryOf(metricKeys.newUncoveredLines, createMeasure(3d, 2d)),
entryOf(metricKeys.newConditionsToCover, createMeasure(7d, 3d)),
entryOf(metricKeys.newUncoveredConditions, createMeasure(4d, 1d))
);
- assertThat(toEntries(measureRepository.getAddedRawMeasures(1112))).containsOnly(
+ assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_2_REF))).contains(
entryOf(metricKeys.newLinesToCover, createMeasure(10d, 6d)),
entryOf(metricKeys.newUncoveredLines, createMeasure(6d, 3d)),
entryOf(metricKeys.newConditionsToCover, createMeasure(44d, 26d)),
@@ -398,11 +419,100 @@ public class NewCoverageMeasuresStepTest {
entryOf(metricKeys.newUncoveredLines, createMeasure(9d, 5d)),
entryOf(metricKeys.newConditionsToCover, createMeasure(51d, 29d)),
entryOf(metricKeys.newUncoveredConditions, createMeasure(27d, 13d))};
- assertThat(toEntries(measureRepository.getAddedRawMeasures(111))).containsOnly(repoEntriesFromSubModuleUp);
+ assertThat(toEntries(measureRepository.getAddedRawMeasures(SUB_MODULE_REF))).contains(repoEntriesFromSubModuleUp);
// module
- assertThat(toEntries(measureRepository.getAddedRawMeasures(11))).containsOnly(repoEntriesFromSubModuleUp);
+ assertThat(toEntries(measureRepository.getAddedRawMeasures(MODULE_REF))).contains(repoEntriesFromSubModuleUp);
// project
- assertThat(toEntries(measureRepository.getAddedRawMeasures(11))).containsOnly(repoEntriesFromSubModuleUp);
+ assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).contains(repoEntriesFromSubModuleUp);
+ }
+
+ @Test
+ public void verify_aggregates_variations_for_new_code_line_and_branch_Coverage() {
+ LinesAndConditionsWithUncoveredMetricKeys metricKeys = new LinesAndConditionsWithUncoveredMetricKeys(
+ CoreMetrics.NEW_LINES_TO_COVER_KEY, CoreMetrics.NEW_CONDITIONS_TO_COVER_KEY,
+ CoreMetrics.NEW_UNCOVERED_LINES_KEY, CoreMetrics.NEW_UNCOVERED_CONDITIONS_KEY
+ );
+ String codeCoverageKey = CoreMetrics.NEW_COVERAGE_KEY;
+ String lineCoverageKey = CoreMetrics.NEW_LINE_COVERAGE_KEY;
+ String branchCoverageKey = CoreMetrics.NEW_BRANCH_COVERAGE_KEY;
+
+ verify_aggregates_variations(metricKeys, codeCoverageKey, lineCoverageKey, branchCoverageKey);
+ }
+
+ @Test
+ public void verify_aggregates_variations_for_new_IT_code_line_and_branch_Coverage() {
+ LinesAndConditionsWithUncoveredMetricKeys metricKeys = new LinesAndConditionsWithUncoveredMetricKeys(
+ CoreMetrics.NEW_IT_LINES_TO_COVER_KEY, CoreMetrics.NEW_IT_CONDITIONS_TO_COVER_KEY,
+ CoreMetrics.NEW_IT_UNCOVERED_LINES_KEY, CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS_KEY
+ );
+ String codeCoverageKey = CoreMetrics.NEW_IT_COVERAGE_KEY;
+ String lineCoverageKey = CoreMetrics.NEW_IT_LINE_COVERAGE_KEY;
+ String branchCoverageKey = CoreMetrics.NEW_IT_BRANCH_COVERAGE_KEY;
+
+ verify_aggregates_variations(metricKeys, codeCoverageKey, lineCoverageKey, branchCoverageKey);
+ }
+
+ @Test
+ public void verify_aggregates_variations_for_new_Overall_code_line_and_branch_Coverage() {
+ LinesAndConditionsWithUncoveredMetricKeys metricKeys = new LinesAndConditionsWithUncoveredMetricKeys(
+ CoreMetrics.NEW_OVERALL_LINES_TO_COVER_KEY, CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER_KEY,
+ CoreMetrics.NEW_OVERALL_UNCOVERED_LINES_KEY, CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS_KEY
+ );
+ String codeCoverageKey = CoreMetrics.NEW_OVERALL_COVERAGE_KEY;
+ String lineCoverageKey = CoreMetrics.NEW_OVERALL_LINE_COVERAGE_KEY;
+ String branchCoverageKey = CoreMetrics.NEW_OVERALL_BRANCH_COVERAGE_KEY;
+
+ verify_aggregates_variations(metricKeys, codeCoverageKey, lineCoverageKey, branchCoverageKey);
+ }
+
+ 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, 2000d))
+ .addRawMeasure(FILE_1_REF, metricKeys.getConditions(), createMeasure(300d, 400d))
+ .addRawMeasure(FILE_1_REF, metricKeys.getUncoveredLines(), createMeasure(30d, 200d))
+ .addRawMeasure(FILE_1_REF, metricKeys.getUncoveredConditions(), createMeasure(9d, 16d))
+
+ .addRawMeasure(FILE_2_REF, metricKeys.getLines(), createMeasure(2000d, 3000d))
+ .addRawMeasure(FILE_2_REF, metricKeys.getConditions(), createMeasure(400d, 300d))
+ .addRawMeasure(FILE_2_REF, metricKeys.getUncoveredLines(), createMeasure(200d, 30d))
+ .addRawMeasure(FILE_2_REF, metricKeys.getUncoveredConditions(), createMeasure(16d, 9d));
+
+ underTest.execute();
+
+ assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_1_REF))).containsOnly(
+ entryOf(codeCoverageKey, createMeasure(98.8d, 91d)),
+ entryOf(lineCoverageKey, createMeasure(99d, 90d)),
+ entryOf(branchCoverageKey, createMeasure(97d, 96d))
+ );
+ assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_2_REF))).containsOnly(
+ entryOf(codeCoverageKey, createMeasure(91d, 98.8d)),
+ entryOf(lineCoverageKey, createMeasure(90d, 99d)),
+ entryOf(branchCoverageKey, createMeasure(96d, 97d))
+ );
+ assertThat(measureRepository.getAddedRawMeasures(FILE_3_REF)).isEmpty();
+
+ assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_1_REF))).containsOnly(
+ entryOf(codeCoverageKey, createMeasure(98.8d, 91d)),
+ entryOf(lineCoverageKey, createMeasure(99d, 90d)),
+ entryOf(branchCoverageKey, createMeasure(97d, 96d))
+ );
+
+ assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_2_REF))).containsOnly(
+ entryOf(codeCoverageKey, createMeasure(91d, 98.8d)),
+ entryOf(lineCoverageKey, createMeasure(90d, 99d)),
+ entryOf(branchCoverageKey, createMeasure(96d, 97d))
+ );
+
+ MeasureRepoEntry[] modulesAndProjectEntries = {
+ entryOf(codeCoverageKey, createMeasure(95.5d, 95.5d)),
+ entryOf(lineCoverageKey, createMeasure(95.4d, 95.4d)),
+ entryOf(branchCoverageKey, createMeasure(96.4d, 96.4d))
+ };
+
+ assertThat(toEntries(measureRepository.getAddedRawMeasures(SUB_MODULE_REF))).containsOnly(modulesAndProjectEntries);
+ assertThat(toEntries(measureRepository.getAddedRawMeasures(MODULE_REF))).containsOnly(modulesAndProjectEntries);
+ assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).containsOnly(modulesAndProjectEntries);
}
private void defineChangeSetsAndMeasures(int componentRef, MetricKeys metricKeys, MeasureValues line4, MeasureValues line6) {
@@ -471,7 +581,7 @@ public class NewCoverageMeasuresStepTest {
underTest.execute();
- assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_COMPONENT.getRef()))).containsOnly(
+ assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_COMPONENT.getRef()))).contains(
entryOf(metricKeys.newLinesToCover, createMeasure(5d, 3d)),
entryOf(metricKeys.newUncoveredLines, createMeasure(3d, 2d)),
entryOf(metricKeys.newConditionsToCover, createMeasure(7d, 3d)),