]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7816 Measures on new lines should always be computed but only when SCM is available
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 14 Sep 2016 12:25:24 +0000 (14:25 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 16 Sep 2016 14:27:08 +0000 (16:27 +0200)
it/it-tests/src/test/java/it/dbCleaner/PurgeTest.java
it/it-tests/src/test/java/it/measureHistory/DifferentialPeriodsTest.java
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/NewCoverageMeasuresStep.java
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/NewSizeMeasuresStep.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/NewSizeMeasuresStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportNewCoverageMeasuresStepTest.java

index 3891af3855fc4b9bf6897dce4403ebc1072c00c8..4a86157219a463b7bbc784c43d01c8b1f4c2a5cb 100644 (file)
@@ -115,10 +115,10 @@ public class PurgeTest {
     // must be a different date, else a single snapshot is kept per day
     scan(PROJECT_SAMPLE_PATH, DateFormatUtils.ISO_DATE_FORMAT.format(today));
 
-    int newMeasuresOnTrk = 56;
-    int newMeasuresOnBrc = 292;
-    int newMeasuresOnDir = 48;
-    int newMeasuresOnFil = 4;
+    int newMeasuresOnTrk = 55;
+    int newMeasuresOnBrc = 286;
+    int newMeasuresOnDir = 44;
+    int newMeasuresOnFil = 0;
 
     assertMeasuresCountForQualifier("TRK", measuresOnTrk + newMeasuresOnTrk);
     assertMeasuresCountForQualifier("BRC", measuresOnBrc + newMeasuresOnBrc);
@@ -129,7 +129,7 @@ public class PurgeTest {
     collector.checkThat(
       "Wrong number of measure of new_ metrics",
       count("project_measures, metrics where metrics.id = project_measures.metric_id and metrics.name like 'new_%'"),
-      equalTo(136));
+      equalTo(121));
 
     // added measures relate to project and new_* metrics
     expectedMeasures += newMeasuresOnTrk + newMeasuresOnBrc + newMeasuresOnDir + newMeasuresOnFil;
index 00a0236650269d8cdc3151b46cda19e886d6a88f..81a757b9fda78141c7d99a8b376fb855ad304bc9 100644 (file)
  */
 package it.measureHistory;
 
+import com.google.common.collect.ImmutableMap;
 import com.sonar.orchestrator.Orchestrator;
 import com.sonar.orchestrator.locator.FileLocation;
 import it.Category1Suite;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.sonar.wsclient.services.Measure;
 import org.sonar.wsclient.services.Resource;
 import org.sonar.wsclient.services.ResourceQuery;
+import org.sonarqube.ws.WsMeasures;
+import org.sonarqube.ws.client.WsClient;
+import org.sonarqube.ws.client.measure.ComponentWsRequest;
 import pageobjects.Navigation;
-import util.ItUtils;
 
+import static java.util.Arrays.asList;
+import static java.util.Collections.singletonList;
 import static org.apache.commons.lang.time.DateUtils.addDays;
 import static org.assertj.core.api.Assertions.assertThat;
 import static util.ItUtils.formatDate;
+import static util.ItUtils.newAdminWsClient;
+import static util.ItUtils.resetPeriods;
 import static util.ItUtils.runProjectAnalysis;
 import static util.ItUtils.setServerProperty;
 
@@ -45,24 +56,24 @@ public class DifferentialPeriodsTest {
   static final String PROJECT_KEY = "sample";
   static final String MULTI_MODULE_PROJECT_KEY = "com.sonarsource.it.samples:multi-modules-sample";
 
+  static WsClient CLIENT;
+
   @ClassRule
   public static final Orchestrator orchestrator = Category1Suite.ORCHESTRATOR;
 
-  @Before
-  public void cleanUpAnalysisData() {
-    orchestrator.resetData();
+  @BeforeClass
+  public static void createWsClient() throws Exception {
+    CLIENT = newAdminWsClient(orchestrator);
   }
 
   @Before
-  public void initPeriods() throws Exception {
-    setServerProperty(orchestrator, "sonar.timemachine.period1", "previous_analysis");
-    setServerProperty(orchestrator, "sonar.timemachine.period2", "previous_analysis");
-    setServerProperty(orchestrator, "sonar.timemachine.period3", "previous_analysis");
+  public void cleanUpAnalysisData() {
+    orchestrator.resetData();
   }
 
   @After
-  public void resetPeriods() throws Exception {
-    ItUtils.resetPeriods(orchestrator);
+  public void reset() throws Exception {
+    resetPeriods(orchestrator);
   }
 
   /**
@@ -71,6 +82,9 @@ public class DifferentialPeriodsTest {
   @Test
   public void ensure_differential_period_4_and_5_defined_at_project_level_is_taken_into_account() throws Exception {
     orchestrator.getServer().provisionProject(PROJECT_KEY, PROJECT_KEY);
+    setServerProperty(orchestrator, "sonar.timemachine.period1", "previous_analysis");
+    setServerProperty(orchestrator, "sonar.timemachine.period2", "previous_analysis");
+    setServerProperty(orchestrator, "sonar.timemachine.period3", "previous_analysis");
     setServerProperty(orchestrator, PROJECT_KEY, "sonar.timemachine.period4", "30");
     setServerProperty(orchestrator, PROJECT_KEY, "sonar.timemachine.period5", "previous_analysis");
 
@@ -95,8 +109,7 @@ public class DifferentialPeriodsTest {
     runProjectAnalysis(orchestrator, "shared/xoo-sample");
 
     newTechnicalDebt = orchestrator.getServer().getWsClient().find(
-      ResourceQuery.createForMetrics("sample:src/main/xoo/sample/Sample.xoo", "new_technical_debt").setIncludeTrends(true)
-      );
+      ResourceQuery.createForMetrics("sample:src/main/xoo/sample/Sample.xoo", "new_technical_debt").setIncludeTrends(true));
 
     // No variation => measure is purged
     assertThat(newTechnicalDebt).isNull();
@@ -148,16 +161,14 @@ public class DifferentialPeriodsTest {
     orchestrator.getServer().associateProjectToQualityProfile(MULTI_MODULE_PROJECT_KEY, "xoo", "empty");
     runProjectAnalysis(orchestrator, "shared/xoo-multi-modules-sample",
       "sonar.projectDate", formatDate(addDays(new Date(), -60)),
-      "sonar.modules", "module_a"
-    );
+      "sonar.modules", "module_a");
 
     // Second analysis, 20 days ago, issues will be created
     orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/measureHistory/one-issue-per-line-profile.xml"));
     orchestrator.getServer().associateProjectToQualityProfile(MULTI_MODULE_PROJECT_KEY, "xoo", "one-issue-per-line");
     runProjectAnalysis(orchestrator, "shared/xoo-multi-modules-sample",
       "sonar.projectDate", formatDate(addDays(new Date(), -20)),
-      "sonar.modules", "module_a,module_b"
-    );
+      "sonar.modules", "module_a,module_b");
 
     // Variation on module b should exist
     Resource ncloc = orchestrator.getServer().getWsClient()
@@ -166,4 +177,62 @@ public class DifferentialPeriodsTest {
     assertThat(measures.get(0).getVariation1()).isEqualTo(24);
   }
 
+  @Test
+  public void compute_no_new_lines_measures_when_changes_but_no_scm() throws Exception {
+    orchestrator.getServer().provisionProject(MULTI_MODULE_PROJECT_KEY, MULTI_MODULE_PROJECT_KEY);
+    setServerProperty(orchestrator, MULTI_MODULE_PROJECT_KEY, "sonar.timemachine.period1", "previous_analysis");
+
+    // Execute an analysis 60 days ago without module b
+    orchestrator.getServer().associateProjectToQualityProfile(MULTI_MODULE_PROJECT_KEY, "xoo", "empty");
+    runProjectAnalysis(orchestrator, "shared/xoo-multi-modules-sample",
+      "sonar.projectDate", formatDate(addDays(new Date(), -60)),
+      "sonar.modules", "module_a");
+
+    // Second analysis, 20 days ago
+    orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/measureHistory/one-issue-per-line-profile.xml"));
+    orchestrator.getServer().associateProjectToQualityProfile(MULTI_MODULE_PROJECT_KEY, "xoo", "one-issue-per-line");
+    runProjectAnalysis(orchestrator, "shared/xoo-multi-modules-sample",
+      "sonar.projectDate", formatDate(addDays(new Date(), -20)),
+      "sonar.modules", "module_a,module_b");
+
+    // No new lines measure
+    assertNoMeasures(MULTI_MODULE_PROJECT_KEY, "new_lines", "new_lines_to_cover");
+  }
+
+  @Test
+  public void compute_zero_new_lines_measures_when_no_changes_and_scm_available() throws Exception {
+    String projectKey = "sample-scm";
+    orchestrator.getServer().provisionProject(projectKey, projectKey);
+    setServerProperty(orchestrator, projectKey, "sonar.timemachine.period1", "previous_analysis");
+
+    // Execute an analysis 60 days ago
+    runProjectAnalysis(orchestrator, "scm/xoo-sample-with-scm", "sonar.projectDate", formatDate(addDays(new Date(), -60)),
+      "sonar.scm.provider", "xoo", "sonar.scm.disabled", "false");
+
+    // Second analysis, 20 days ago
+    runProjectAnalysis(orchestrator, "scm/xoo-sample-with-scm", "sonar.projectDate", formatDate(addDays(new Date(), -20)),
+      "sonar.scm.provider", "xoo", "sonar.scm.disabled", "false");
+
+    // New lines measures is zero
+    assertMeasures(projectKey, ImmutableMap.of("new_lines", 0, "new_lines_to_cover", 0));
+  }
+
+  private void assertMeasures(String projectKey, Map<String, Integer> expectedMeasures) {
+    WsMeasures.ComponentWsResponse response = CLIENT.measures().component(new ComponentWsRequest()
+      .setComponentKey(projectKey)
+      .setMetricKeys(new ArrayList<>(expectedMeasures.keySet()))
+      .setAdditionalFields(singletonList("periods")));
+    Map<String, Integer> measures = response.getComponent().getMeasuresList().stream()
+      .collect(Collectors.toMap(WsMeasures.Measure::getMetric, m -> Integer.parseInt(m.getPeriods().getPeriodsValue(0).getValue())));
+    assertThat(measures).isEqualTo(expectedMeasures);
+  }
+
+  private void assertNoMeasures(String projectKey, String... metrics) {
+    WsMeasures.ComponentWsResponse response = CLIENT.measures().component(new ComponentWsRequest()
+      .setComponentKey(projectKey)
+      .setMetricKeys(asList(metrics))
+      .setAdditionalFields(singletonList("periods")));
+    assertThat(response.getComponent().getMeasuresList()).isEmpty();
+  }
+
 }
index 299cea60b216e727084ab4592ca453bcde7f9638..c6012cd8c25f217c0520d2855c451abbfcf96c3a 100644 (file)
@@ -375,11 +375,14 @@ public class NewCoverageMeasuresStep implements ComputationStep {
       }
       ScmInfo componentScm = scmInfoOptional.get();
 
-      Optional<Measure> hitsByLineMeasure = context.getMeasure(metricKeys.getCoverageLineHitsData());
-      if (!hitsByLineMeasure.isPresent() || hitsByLineMeasure.get().getValueType() == Measure.ValueType.NO_VALUE) {
-        return;
-      }
+      context.getPeriods().forEach(period -> {
+        newLines.increment(period, 0);
+        newCoveredLines.increment(period, 0);
+        newConditions.increment(period, 0);
+        newCoveredConditions.increment(period, 0);
+      });
 
+      Optional<Measure> hitsByLineMeasure = context.getMeasure(metricKeys.getCoverageLineHitsData());
       Map<Integer, Integer> hitsByLine = parseCountByLine(hitsByLineMeasure);
       Map<Integer, Integer> conditionsByLine = parseCountByLine(context.getMeasure(metricKeys.getConditionsByLine()));
       Map<Integer, Integer> coveredConditionsByLine = parseCountByLine(context.getMeasure(metricKeys.getCoveredConditionsByLine()));
index 54c3a77d7cd433856b511e5873664799e2e07f0f..5cbf0445e0196e39ad5839066cfb746f03c286c9 100644 (file)
@@ -123,6 +123,11 @@ public class NewSizeMeasuresStep implements ComputationStep {
     @Override
     public void initialize(CounterInitializationContext context) {
       Component leaf = context.getLeaf();
+      Optional<ScmInfo> scmInfo = scmInfoRepository.getScmInfo(leaf);
+      if (!scmInfo.isPresent()) {
+        return;
+      }
+
       context.getPeriods().forEach(period -> newLines.increment(period, 0));
       if (leaf.getType() != Component.Type.FILE) {
         context.getPeriods().forEach(period -> {
@@ -131,10 +136,6 @@ public class NewSizeMeasuresStep implements ComputationStep {
         });
         return;
       }
-      Optional<ScmInfo> scmInfo = scmInfoRepository.getScmInfo(leaf);
-      if (!scmInfo.isPresent()) {
-        return;
-      }
 
       initNewLines(scmInfo.get(), context.getPeriods());
       initNewDuplicated(leaf, scmInfo.get(), context.getPeriods());
index 3a2794242cfef6f747b6f2a3c4ce00bb7a37f30a..227b7b6c0edada0a48088d3aa42602c5d666ed8d 100644 (file)
@@ -126,10 +126,10 @@ public class NewSizeMeasuresStepTest {
 
     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_LINES_KEY, 11);
     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_2_REF, NEW_LINES_KEY, 11);
-    assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_3_REF, NEW_LINES_KEY, 0);
+    assertNoRawMeasure(FILE_3_REF, NEW_LINES_KEY);
     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_4_REF, NEW_LINES_KEY, 11);
     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(DIRECTORY_REF, NEW_LINES_KEY, 22);
-    assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(DIRECTORY_2_REF, NEW_LINES_KEY, 0);
+    assertNoRawMeasure(DIRECTORY_2_REF, NEW_LINES_KEY);
     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(SUB_MODULE_1_REF, NEW_LINES_KEY, 22);
     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(SUB_MODULE_2_REF, NEW_LINES_KEY, 11);
     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(MODULE_REF, NEW_LINES_KEY, 33);
@@ -137,17 +137,10 @@ public class NewSizeMeasuresStepTest {
   }
 
   @Test
-  public void compute_new_lines_with_no_changeset() {
+  public void does_not_compute_new_lines_when_no_changeset() {
     underTest.execute();
 
-    assertComputedAndAggregatedToZeroInt(NEW_LINES_KEY);
-  }
-
-  @Test
-  public void compute_new_lines_with_no_ncloc_data() {
-    underTest.execute();
-
-    assertComputedAndAggregatedToZeroInt(NEW_LINES_KEY);
+    assertNoRawMeasures(NEW_LINES_KEY);
   }
 
   @Test
@@ -235,7 +228,7 @@ public class NewSizeMeasuresStepTest {
     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_3_REF, NEW_DUPLICATED_LINES_KEY, 9d);
     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_4_REF, NEW_DUPLICATED_LINES_KEY, 11d);
     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(DIRECTORY_REF, NEW_DUPLICATED_LINES_KEY, 2d);
-    assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(DIRECTORY_2_REF, NEW_DUPLICATED_LINES_KEY, 0d);
+    assertNoRawMeasure(DIRECTORY_2_REF, NEW_DUPLICATED_LINES_KEY);
     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(SUB_MODULE_1_REF, NEW_DUPLICATED_LINES_KEY, 2d);
     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(SUB_MODULE_2_REF, NEW_DUPLICATED_LINES_KEY, 20d);
     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(MODULE_REF, NEW_DUPLICATED_LINES_KEY, 22d);
index 59a4f56d1ad4b02099606d88ccb77788d13409f7..9e3fbec167ba4c889654ceb8371761a2e7fc7823 100644 (file)
@@ -24,10 +24,10 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.measures.CoreMetrics;
-import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.component.Component;
 import org.sonar.server.computation.task.projectanalysis.component.FileAttributes;
 import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
+import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.formula.coverage.LinesAndConditionsWithUncoveredMetricKeys;
 import org.sonar.server.computation.task.projectanalysis.measure.Measure;
 import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepoEntry;
@@ -45,7 +45,15 @@ import static org.sonar.api.measures.CoreMetrics.CONDITIONS_BY_LINE_KEY;
 import static org.sonar.api.measures.CoreMetrics.COVERAGE_LINE_HITS_DATA_KEY;
 import static org.sonar.api.measures.CoreMetrics.COVERED_CONDITIONS_BY_LINE_KEY;
 import static org.sonar.api.measures.CoreMetrics.NEW_CONDITIONS_TO_COVER_KEY;
+import static org.sonar.api.measures.CoreMetrics.NEW_IT_CONDITIONS_TO_COVER_KEY;
+import static org.sonar.api.measures.CoreMetrics.NEW_IT_LINES_TO_COVER_KEY;
+import static org.sonar.api.measures.CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS_KEY;
+import static org.sonar.api.measures.CoreMetrics.NEW_IT_UNCOVERED_LINES_KEY;
 import static org.sonar.api.measures.CoreMetrics.NEW_LINES_TO_COVER_KEY;
+import static org.sonar.api.measures.CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER_KEY;
+import static org.sonar.api.measures.CoreMetrics.NEW_OVERALL_LINES_TO_COVER_KEY;
+import static org.sonar.api.measures.CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS_KEY;
+import static org.sonar.api.measures.CoreMetrics.NEW_OVERALL_UNCOVERED_LINES_KEY;
 import static org.sonar.api.measures.CoreMetrics.NEW_UNCOVERED_CONDITIONS_KEY;
 import static org.sonar.api.measures.CoreMetrics.NEW_UNCOVERED_LINES_KEY;
 import static org.sonar.api.utils.DateUtils.parseDate;
@@ -78,17 +86,16 @@ public class ReportNewCoverageMeasuresStepTest {
             .addChildren(
               builder(DIRECTORY, DIRECTORY_1_REF)
                 .addChildren(
-                  builder(FILE, FILE_1_REF).build()
-                ).build(),
+                  builder(FILE, FILE_1_REF).build())
+                .build(),
               builder(DIRECTORY, DIRECTORY_2_REF)
                 .addChildren(
                   builder(FILE, FILE_2_REF).build(),
-                  builder(FILE, FILE_3_REF).build()
-                ).build()
-            )
-            .build()
-        ).build()
-    ).build();
+                  builder(FILE, FILE_3_REF).build())
+                .build())
+            .build())
+        .build())
+    .build();
 
   @Rule
   public ScmInfoRepositoryRule scmInfoRepository = new ScmInfoRepositoryRule();
@@ -190,29 +197,14 @@ public class ReportNewCoverageMeasuresStepTest {
   }
 
   @Test
-  public void verify_measure_of_condition_not_computed_if_there_is_none() {
-    treeRootHolder.setRoot(FILE_COMPONENT);
-    scmInfoRepository.setScmInfo(FILE_1_REF,
-      Changeset.newChangesetBuilder().setDate(parseDate("2007-01-15").getTime()).setRevision("rev-1").build(),
-      Changeset.newChangesetBuilder().setDate(parseDate("2007-01-15").getTime()).setRevision("rev-1").build(),
-      Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-2").build()
-      );
-
-    underTest.execute();
-
-    assertThat(measureRepository.isEmpty()).isTrue();
-  }
-
-  @Test
-  public void verify_no_measure_when_nothing_has_changed() {
+  public void zero_measures_when_nothing_has_changed() {
     treeRootHolder.setRoot(FILE_COMPONENT);
     scmInfoRepository.setScmInfo(FILE_1_REF,
       Changeset.newChangesetBuilder().setDate(parseDate("2008-08-02").getTime()).setRevision("rev-1").build(),
       Changeset.newChangesetBuilder().setDate(parseDate("2008-08-02").getTime()).setRevision("rev-1").build(),
       Changeset.newChangesetBuilder().setDate(parseDate("2008-08-02").getTime()).setRevision("rev-1").build(),
       Changeset.newChangesetBuilder().setDate(parseDate("2008-08-02").getTime()).setRevision("rev-1").build(),
-      Changeset.newChangesetBuilder().setDate(parseDate("2008-08-02").getTime()).setRevision("rev-1").build()
-      );
+      Changeset.newChangesetBuilder().setDate(parseDate("2008-08-02").getTime()).setRevision("rev-1").build());
 
     measureRepository.addRawMeasure(FILE_COMPONENT.getReportAttributes().getRef(), COVERAGE_LINE_HITS_DATA_KEY, newMeasureBuilder().create("2=1;3=1"));
     measureRepository.addRawMeasure(FILE_COMPONENT.getReportAttributes().getRef(), CONDITIONS_BY_LINE_KEY, newMeasureBuilder().create("2=1"));
@@ -220,22 +212,19 @@ public class ReportNewCoverageMeasuresStepTest {
 
     underTest.execute();
 
-    assertThat(measureRepository.getAddedRawMeasures(FILE_COMPONENT.getReportAttributes().getRef())).isEmpty();
+    verify_only_zero_measures_on_new_lines_and_conditions_measures(FILE_COMPONENT);
   }
 
   @Test
-  public void no_measures_for_FILE_component_without_CoverageData() {
-    ReportComponent fileComponent = ReportComponent.builder(Component.Type.FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, null)).build();
-
-    treeRootHolder.setRoot(fileComponent);
+  public void zero_measures_for_FILE_component_without_CoverageData() {
+    treeRootHolder.setRoot(FILE_COMPONENT);
     scmInfoRepository.setScmInfo(FILE_1_REF,
       Changeset.newChangesetBuilder().setDate(parseDate("2008-05-18").getTime()).setRevision("rev-1").build(),
-      Changeset.newChangesetBuilder().setDate(parseDate("2008-05-18").getTime()).setRevision("rev-1").build()
-      );
+      Changeset.newChangesetBuilder().setDate(parseDate("2008-05-18").getTime()).setRevision("rev-1").build());
 
     underTest.execute();
 
-    assertThat(measureRepository.isEmpty()).isTrue();
+    verify_only_zero_measures_on_new_lines_and_conditions_measures(FILE_COMPONENT);
   }
 
   @Test
@@ -253,10 +242,10 @@ public class ReportNewCoverageMeasuresStepTest {
   @Test
   public void verify_computation_of_measures_for_new_lines_for_IT_FILE() {
     String coverageLineHitsData = CoreMetrics.IT_COVERAGE_LINE_HITS_DATA_KEY;
-    String newLinesToCover = CoreMetrics.NEW_IT_LINES_TO_COVER_KEY;
-    String newUncoveredLines = CoreMetrics.NEW_IT_UNCOVERED_LINES_KEY;
-    String newConditionsToCover = CoreMetrics.NEW_IT_CONDITIONS_TO_COVER_KEY;
-    String newUncoveredConditions = CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS_KEY;
+    String newLinesToCover = NEW_IT_LINES_TO_COVER_KEY;
+    String newUncoveredLines = NEW_IT_UNCOVERED_LINES_KEY;
+    String newConditionsToCover = NEW_IT_CONDITIONS_TO_COVER_KEY;
+    String newUncoveredConditions = NEW_IT_UNCOVERED_CONDITIONS_KEY;
 
     verify_computation_of_measures_for_new_lines(coverageLineHitsData,
       newLinesToCover, newUncoveredLines, newConditionsToCover, newUncoveredConditions);
@@ -265,10 +254,10 @@ public class ReportNewCoverageMeasuresStepTest {
   @Test
   public void verify_computation_of_measures_for_new_lines_for_Overall() {
     String coverageLineHitsData = CoreMetrics.OVERALL_COVERAGE_LINE_HITS_DATA_KEY;
-    String newLinesToCover = CoreMetrics.NEW_OVERALL_LINES_TO_COVER_KEY;
-    String newUncoveredLines = CoreMetrics.NEW_OVERALL_UNCOVERED_LINES_KEY;
-    String newConditionsToCover = CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER_KEY;
-    String newUncoveredConditions = CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS_KEY;
+    String newLinesToCover = NEW_OVERALL_LINES_TO_COVER_KEY;
+    String newUncoveredLines = NEW_OVERALL_UNCOVERED_LINES_KEY;
+    String newConditionsToCover = NEW_OVERALL_CONDITIONS_TO_COVER_KEY;
+    String newUncoveredConditions = NEW_OVERALL_UNCOVERED_CONDITIONS_KEY;
 
     verify_computation_of_measures_for_new_lines(coverageLineHitsData,
       newLinesToCover, newUncoveredLines, newConditionsToCover, newUncoveredConditions);
@@ -281,19 +270,17 @@ public class ReportNewCoverageMeasuresStepTest {
       Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build(),
       Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build(),
       Changeset.newChangesetBuilder().setDate(parseDate("2007-01-15").getTime()).setRevision("rev-2").build(),
-      Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build()
-      );
+      Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build());
 
     measureRepository.addRawMeasure(FILE_COMPONENT.getReportAttributes().getRef(), coverageLineHitsData, newMeasureBuilder().create("2=0;3=2;4=3"));
 
     underTest.execute();
 
     assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_COMPONENT.getReportAttributes().getRef()))).contains(
-      entryOf(newLinesToCover, createMeasure(2d, null)),
-      entryOf(newUncoveredLines, createMeasure(1d, null)),
-      entryOf(newConditionsToCover, createMeasure(0d, null)),
-      entryOf(newUncoveredConditions, createMeasure(0d, null))
-      );
+      entryOf(newLinesToCover, createMeasure(2d, 0d)),
+      entryOf(newUncoveredLines, createMeasure(1d, 0d)),
+      entryOf(newConditionsToCover, createMeasure(0d, 0d)),
+      entryOf(newUncoveredConditions, createMeasure(0d, 0d)));
   }
 
   @Test
@@ -315,10 +302,10 @@ public class ReportNewCoverageMeasuresStepTest {
     String coverageLineHitsData = CoreMetrics.IT_COVERAGE_LINE_HITS_DATA_KEY;
     String conditionsByLine = CoreMetrics.IT_CONDITIONS_BY_LINE_KEY;
     String coveredConditionsByLine = CoreMetrics.IT_COVERED_CONDITIONS_BY_LINE_KEY;
-    String newLinesToCover = CoreMetrics.NEW_IT_LINES_TO_COVER_KEY;
-    String newUncoveredLines = CoreMetrics.NEW_IT_UNCOVERED_LINES_KEY;
-    String newConditionsToCover = CoreMetrics.NEW_IT_CONDITIONS_TO_COVER_KEY;
-    String newUncoveredConditions = CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS_KEY;
+    String newLinesToCover = NEW_IT_LINES_TO_COVER_KEY;
+    String newUncoveredLines = NEW_IT_UNCOVERED_LINES_KEY;
+    String newConditionsToCover = NEW_IT_CONDITIONS_TO_COVER_KEY;
+    String newUncoveredConditions = NEW_IT_UNCOVERED_CONDITIONS_KEY;
 
     verify_computation_of_measures_for_new_conditions(new MetricKeys(coverageLineHitsData, conditionsByLine, coveredConditionsByLine,
       newLinesToCover, newUncoveredLines, newConditionsToCover, newUncoveredConditions));
@@ -329,10 +316,10 @@ public class ReportNewCoverageMeasuresStepTest {
     String coverageLineHitsData = CoreMetrics.OVERALL_COVERAGE_LINE_HITS_DATA_KEY;
     String conditionsByLine = CoreMetrics.OVERALL_CONDITIONS_BY_LINE_KEY;
     String coveredConditionsByLine = CoreMetrics.OVERALL_COVERED_CONDITIONS_BY_LINE_KEY;
-    String newLinesToCover = CoreMetrics.NEW_OVERALL_LINES_TO_COVER_KEY;
-    String newUncoveredLines = CoreMetrics.NEW_OVERALL_UNCOVERED_LINES_KEY;
-    String newConditionsToCover = CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER_KEY;
-    String newUncoveredConditions = CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS_KEY;
+    String newLinesToCover = NEW_OVERALL_LINES_TO_COVER_KEY;
+    String newUncoveredLines = NEW_OVERALL_UNCOVERED_LINES_KEY;
+    String newConditionsToCover = NEW_OVERALL_CONDITIONS_TO_COVER_KEY;
+    String newUncoveredConditions = NEW_OVERALL_UNCOVERED_CONDITIONS_KEY;
 
     verify_computation_of_measures_for_new_conditions(new MetricKeys(coverageLineHitsData, conditionsByLine, coveredConditionsByLine,
       newLinesToCover, newUncoveredLines, newConditionsToCover, newUncoveredConditions));
@@ -343,10 +330,10 @@ public class ReportNewCoverageMeasuresStepTest {
     String coverageLineHitsData = CoreMetrics.IT_COVERAGE_LINE_HITS_DATA_KEY;
     String conditionsByLine = CoreMetrics.IT_CONDITIONS_BY_LINE_KEY;
     String coveredConditionsByLine = CoreMetrics.IT_COVERED_CONDITIONS_BY_LINE_KEY;
-    String newLinesToCover = CoreMetrics.NEW_IT_LINES_TO_COVER_KEY;
-    String newUncoveredLines = CoreMetrics.NEW_IT_UNCOVERED_LINES_KEY;
-    String newConditionsToCover = CoreMetrics.NEW_IT_CONDITIONS_TO_COVER_KEY;
-    String newUncoveredConditions = CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS_KEY;
+    String newLinesToCover = NEW_IT_LINES_TO_COVER_KEY;
+    String newUncoveredLines = NEW_IT_UNCOVERED_LINES_KEY;
+    String newConditionsToCover = NEW_IT_CONDITIONS_TO_COVER_KEY;
+    String newUncoveredConditions = NEW_IT_UNCOVERED_CONDITIONS_KEY;
 
     MetricKeys metricKeys = new MetricKeys(coverageLineHitsData, conditionsByLine, coveredConditionsByLine,
       newLinesToCover, newUncoveredLines, newConditionsToCover, newUncoveredConditions);
@@ -363,33 +350,28 @@ public class ReportNewCoverageMeasuresStepTest {
       entryOf(metricKeys.newLinesToCover, createMeasure(5d, 3d)),
       entryOf(metricKeys.newUncoveredLines, createMeasure(3d, 2d)),
       entryOf(metricKeys.newConditionsToCover, createMeasure(7d, 3d)),
-      entryOf(metricKeys.newUncoveredConditions, createMeasure(4d, 1d))
-      );
+      entryOf(metricKeys.newUncoveredConditions, createMeasure(4d, 1d)));
     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))
-      );
+      entryOf(metricKeys.newUncoveredConditions, createMeasure(14d, 6d)));
     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))
-      );
+      entryOf(metricKeys.newUncoveredConditions, createMeasure(9d, 6d)));
     // directories
     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))
-      );
+      entryOf(metricKeys.newUncoveredConditions, createMeasure(4d, 1d)));
     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)),
-      entryOf(metricKeys.newUncoveredConditions, createMeasure(23d, 12d))
-      );
+      entryOf(metricKeys.newUncoveredConditions, createMeasure(23d, 12d)));
     // submodule
     MeasureRepoEntry[] repoEntriesFromSubModuleUp = {entryOf(metricKeys.newLinesToCover, createMeasure(15d, 9d)),
       entryOf(metricKeys.newUncoveredLines, createMeasure(9d, 5d)),
@@ -406,8 +388,7 @@ public class ReportNewCoverageMeasuresStepTest {
   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
-      );
+      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;
@@ -418,9 +399,8 @@ public class ReportNewCoverageMeasuresStepTest {
   @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
-      );
+      NEW_IT_LINES_TO_COVER_KEY, NEW_IT_CONDITIONS_TO_COVER_KEY,
+      NEW_IT_UNCOVERED_LINES_KEY, 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;
@@ -431,9 +411,8 @@ public class ReportNewCoverageMeasuresStepTest {
   @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
-      );
+      NEW_OVERALL_LINES_TO_COVER_KEY, NEW_OVERALL_CONDITIONS_TO_COVER_KEY,
+      NEW_OVERALL_UNCOVERED_LINES_KEY, 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;
@@ -459,26 +438,22 @@ public class ReportNewCoverageMeasuresStepTest {
     assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_1_REF))).containsOnly(
       entryOf(codeCoverageKey, createMeasure(98.8d, 91d)),
       entryOf(lineCoverageKey, createMeasure(99d, 90d)),
-      entryOf(branchCoverageKey, createMeasure(97d, 96d))
-      );
+      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))
-      );
+      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))
-      );
+      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))
-      );
+      entryOf(branchCoverageKey, createMeasure(96d, 97d)));
 
     MeasureRepoEntry[] modulesAndProjectEntries = {
       entryOf(codeCoverageKey, createMeasure(95.5d, 95.5d)),
@@ -491,6 +466,24 @@ public class ReportNewCoverageMeasuresStepTest {
     assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).containsOnly(modulesAndProjectEntries);
   }
 
+  private void verify_only_zero_measures_on_new_lines_and_conditions_measures(Component component) {
+    assertThat(toEntries(measureRepository.getAddedRawMeasures(component.getReportAttributes().getRef()))).containsOnly(
+      entryOf(NEW_LINES_TO_COVER_KEY, createMeasure(0d, 0d)),
+      entryOf(NEW_UNCOVERED_LINES_KEY, createMeasure(0d, 0d)),
+      entryOf(NEW_CONDITIONS_TO_COVER_KEY, createMeasure(0d, 0d)),
+      entryOf(NEW_UNCOVERED_CONDITIONS_KEY, createMeasure(0d, 0d)),
+
+      entryOf(NEW_IT_LINES_TO_COVER_KEY, createMeasure(0d, 0d)),
+      entryOf(NEW_IT_UNCOVERED_LINES_KEY, createMeasure(0d, 0d)),
+      entryOf(NEW_IT_CONDITIONS_TO_COVER_KEY, createMeasure(0d, 0d)),
+      entryOf(NEW_IT_UNCOVERED_CONDITIONS_KEY, createMeasure(0d, 0d)),
+
+      entryOf(NEW_OVERALL_LINES_TO_COVER_KEY, createMeasure(0d, 0d)),
+      entryOf(NEW_OVERALL_UNCOVERED_LINES_KEY, createMeasure(0d, 0d)),
+      entryOf(NEW_OVERALL_CONDITIONS_TO_COVER_KEY, createMeasure(0d, 0d)),
+      entryOf(NEW_OVERALL_UNCOVERED_CONDITIONS_KEY, createMeasure(0d, 0d)));
+  }
+
   private void defineChangeSetsAndMeasures(int componentRef, MetricKeys metricKeys, MeasureValues line4, MeasureValues line6) {
     scmInfoRepository.setScmInfo(componentRef,
       Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build(),
@@ -499,8 +492,7 @@ public class ReportNewCoverageMeasuresStepTest {
       Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build(),
       Changeset.newChangesetBuilder().setDate(parseDate("2012-02-23").getTime()).setRevision("rev-3").build(),
       Changeset.newChangesetBuilder().setDate(parseDate("2012-02-23").getTime()).setRevision("rev-3").build(),
-      Changeset.newChangesetBuilder().setDate(parseDate("2012-02-23").getTime()).setRevision("rev-3").build()
-      );
+      Changeset.newChangesetBuilder().setDate(parseDate("2012-02-23").getTime()).setRevision("rev-3").build());
 
     measureRepository.addRawMeasure(componentRef, metricKeys.coverageLineHitsData, newMeasureBuilder().create("2=0;3=2;4=" + line4.lineHits + ";5=1;6=" + line6.lineHits + ";7=0"));
     measureRepository.addRawMeasure(componentRef, metricKeys.conditionsByLine, newMeasureBuilder().create("4=" + line4.coveredConditions + ";6=" + line6.coveredConditions));
@@ -551,8 +543,7 @@ public class ReportNewCoverageMeasuresStepTest {
       entryOf(metricKeys.newLinesToCover, createMeasure(5d, 3d)),
       entryOf(metricKeys.newUncoveredLines, createMeasure(3d, 2d)),
       entryOf(metricKeys.newConditionsToCover, createMeasure(7d, 3d)),
-      entryOf(metricKeys.newUncoveredConditions, createMeasure(4d, 1d))
-      );
+      entryOf(metricKeys.newUncoveredConditions, createMeasure(4d, 1d)));
   }
 
   private static Measure createMeasure(@Nullable Double variationPeriod2, @Nullable Double variationPeriod5) {