]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6677 remove coverage Decorators from batch 411/head
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Tue, 7 Jul 2015 16:47:35 +0000 (18:47 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 9 Jul 2015 07:24:49 +0000 (09:24 +0200)
20 files changed:
sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java
sonar-batch/src/main/java/org/sonar/batch/compute/AbstractCoverageDecorator.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/compute/BranchCoverageDecorator.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/compute/CoverageDecorator.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/compute/ItBranchCoverageDecorator.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/compute/ItCoverageDecorator.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/compute/ItLineCoverageDecorator.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/compute/LineCoverageDecorator.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/compute/OverallBranchCoverageDecorator.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/compute/OverallCoverageDecorator.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/compute/OverallLineCoverageDecorator.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/compute/BranchCoverageDecoratorTest.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/compute/CoverageDecoratorTest.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/compute/ItBranchCoverageDecoratorTest.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/compute/ItCoverageDecoratorTest.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/compute/ItLineCoverageDecoratorTest.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/compute/LineCoverageDecoratorTest.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/compute/OverallBranchCoverageDecoratorTest.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/compute/OverallCoverageDecoratorTest.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/compute/OverallLineCoverageDecoratorTest.java [deleted file]

index ae4a35f71621df3792e8b491705443ef2e051232..97f77f090760b60657dc973d6dda31edf5de2b88 100644 (file)
@@ -22,18 +22,9 @@ package org.sonar.batch.bootstrap;
 import com.google.common.collect.Lists;
 import java.util.Collection;
 import java.util.List;
-import org.sonar.batch.compute.BranchCoverageDecorator;
 import org.sonar.batch.compute.CommentDensityDecorator;
-import org.sonar.batch.compute.CoverageDecorator;
 import org.sonar.batch.compute.DirectoriesDecorator;
 import org.sonar.batch.compute.FilesDecorator;
-import org.sonar.batch.compute.ItBranchCoverageDecorator;
-import org.sonar.batch.compute.ItCoverageDecorator;
-import org.sonar.batch.compute.ItLineCoverageDecorator;
-import org.sonar.batch.compute.LineCoverageDecorator;
-import org.sonar.batch.compute.OverallBranchCoverageDecorator;
-import org.sonar.batch.compute.OverallCoverageDecorator;
-import org.sonar.batch.compute.OverallLineCoverageDecorator;
 import org.sonar.batch.compute.UnitTestDecorator;
 import org.sonar.batch.cpd.CpdComponents;
 import org.sonar.batch.issue.tracking.IssueTracking;
@@ -48,8 +39,8 @@ import org.sonar.batch.scm.ScmConfiguration;
 import org.sonar.batch.scm.ScmSensor;
 import org.sonar.batch.source.CodeColorizerSensor;
 import org.sonar.batch.source.LinesSensor;
-import org.sonar.core.config.CorePropertyDefinitions;
 import org.sonar.core.component.DefaultResourceTypes;
+import org.sonar.core.config.CorePropertyDefinitions;
 
 public class BatchComponents {
   private BatchComponents() {
@@ -82,15 +73,6 @@ public class BatchComponents {
 
       // to be moved to compute engine
       UnitTestDecorator.class,
-      LineCoverageDecorator.class,
-      CoverageDecorator.class,
-      BranchCoverageDecorator.class,
-      ItLineCoverageDecorator.class,
-      ItCoverageDecorator.class,
-      ItBranchCoverageDecorator.class,
-      OverallLineCoverageDecorator.class,
-      OverallCoverageDecorator.class,
-      OverallBranchCoverageDecorator.class,
       CommentDensityDecorator.class,
       DirectoriesDecorator.class,
       FilesDecorator.class
diff --git a/sonar-batch/src/main/java/org/sonar/batch/compute/AbstractCoverageDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/compute/AbstractCoverageDecorator.java
deleted file mode 100644 (file)
index 8db0fa4..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.compute;
-
-import java.util.Arrays;
-import java.util.Collection;
-import org.sonar.api.batch.Decorator;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.batch.DependedUpon;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.resources.ResourceUtils;
-
-public abstract class AbstractCoverageDecorator implements Decorator {
-
-  @Override
-  public boolean shouldExecuteOnProject(Project project) {
-    return true;
-  }
-
-  @DependedUpon
-  public Collection<Metric> generatedMetrics() {
-    return Arrays.asList(getGeneratedMetric(), getGeneratedMetricForNewCode());
-  }
-
-  @Override
-  public void decorate(final Resource resource, final DecoratorContext context) {
-    if (shouldDecorate(resource)) {
-      computeMeasure(context);
-      computeMeasureForNewCode(context);
-    }
-  }
-
-  protected boolean shouldDecorate(final Resource resource) {
-    return !ResourceUtils.isUnitTestFile(resource);
-  }
-
-  private void computeMeasure(DecoratorContext context) {
-    if (context.getMeasure(getGeneratedMetric()) == null) {
-      Long elements = countElements(context);
-      if (elements != null && elements > 0L) {
-        Long coveredElements = countCoveredElements(context);
-        context.saveMeasure(getGeneratedMetric(), calculateCoverage(coveredElements, elements));
-      }
-    }
-  }
-
-  private void computeMeasureForNewCode(DecoratorContext context) {
-    if (context.getMeasure(getGeneratedMetricForNewCode()) == null) {
-      Measure measure = new Measure(getGeneratedMetricForNewCode());
-      boolean hasValue = false;
-      /* TODO remove this magic number */
-      for (int periodIndex = 1; periodIndex <= 5; periodIndex++) {
-        Long elements = countElementsForNewCode(context, periodIndex);
-
-        if (elements != null && elements > 0L) {
-          long coveredElements = countCoveredElementsForNewCode(context, periodIndex);
-          measure.setVariation(periodIndex, calculateCoverage(coveredElements, elements));
-          hasValue = true;
-        }
-      }
-      if (hasValue) {
-        context.saveMeasure(measure);
-      }
-    }
-  }
-
-  private static double calculateCoverage(final long coveredLines, final long lines) {
-    return (100.0 * coveredLines) / lines;
-  }
-
-  protected abstract Metric getGeneratedMetric();
-
-  protected abstract Long countElements(DecoratorContext context);
-
-  protected abstract long countCoveredElements(DecoratorContext context);
-
-  protected abstract Metric getGeneratedMetricForNewCode();
-
-  protected abstract Long countElementsForNewCode(DecoratorContext context, int periodIndex);
-
-  protected abstract long countCoveredElementsForNewCode(DecoratorContext context, int periodIndex);
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/compute/BranchCoverageDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/compute/BranchCoverageDecorator.java
deleted file mode 100644 (file)
index 637ea6e..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.compute;
-
-import java.util.Collection;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.batch.DependsUpon;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.MeasureUtils;
-import org.sonar.api.measures.Metric;
-import org.sonar.batch.sensor.coverage.CoverageConstants;
-
-public final class BranchCoverageDecorator extends AbstractCoverageDecorator {
-
-  @DependsUpon
-  public Collection<Metric> dependsUponMetrics() {
-    return CoverageConstants.BRANCH_COVERAGE_METRICS;
-  }
-
-  @Override
-  protected Metric getGeneratedMetric() {
-    return CoreMetrics.BRANCH_COVERAGE;
-  }
-
-  @Override
-  protected Long countElements(DecoratorContext context) {
-    return MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.CONDITIONS_TO_COVER), 0L);
-  }
-
-  @Override
-  protected long countCoveredElements(DecoratorContext context) {
-    long uncoveredConditions = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.UNCOVERED_CONDITIONS), 0L);
-    long conditions = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.CONDITIONS_TO_COVER), 0L);
-
-    return conditions - uncoveredConditions;
-  }
-
-  @Override
-  protected Metric getGeneratedMetricForNewCode() {
-    return CoreMetrics.NEW_BRANCH_COVERAGE;
-  }
-
-  @Override
-  protected Long countElementsForNewCode(DecoratorContext context, int periodIndex) {
-    return MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_CONDITIONS_TO_COVER), periodIndex);
-  }
-
-  @Override
-  protected long countCoveredElementsForNewCode(DecoratorContext context, int periodIndex) {
-    long uncoveredConditions = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_UNCOVERED_CONDITIONS), periodIndex, 0L);
-    long conditions = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_CONDITIONS_TO_COVER), periodIndex, 0L);
-
-    return conditions - uncoveredConditions;
-  }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/compute/CoverageDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/compute/CoverageDecorator.java
deleted file mode 100644 (file)
index 7d8bed2..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.compute;
-
-import java.util.Collection;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.batch.DependsUpon;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.MeasureUtils;
-import org.sonar.api.measures.Metric;
-import org.sonar.batch.sensor.coverage.CoverageConstants;
-
-public final class CoverageDecorator extends AbstractCoverageDecorator {
-
-  @DependsUpon
-  public Collection<Metric> usedMetrics() {
-    return CoverageConstants.COVERAGE_METRICS;
-  }
-
-  @Override
-  protected Metric getGeneratedMetric() {
-    return CoreMetrics.COVERAGE;
-  }
-
-  @Override
-  protected Long countElements(DecoratorContext context) {
-    long linesToCover = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.LINES_TO_COVER), 0L);
-    long conditions = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.CONDITIONS_TO_COVER), 0L);
-
-    return linesToCover + conditions;
-  }
-
-  @Override
-  protected long countCoveredElements(DecoratorContext context) {
-    long uncoveredLines = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.UNCOVERED_LINES), 0L);
-    long lines = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.LINES_TO_COVER), 0L);
-    long uncoveredConditions = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.UNCOVERED_CONDITIONS), 0L);
-    long conditions = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.CONDITIONS_TO_COVER), 0L);
-
-    return lines + conditions - uncoveredConditions - uncoveredLines;
-  }
-
-  @Override
-  protected Metric getGeneratedMetricForNewCode() {
-    return CoreMetrics.NEW_COVERAGE;
-  }
-
-  @Override
-  protected Long countElementsForNewCode(DecoratorContext context, int periodIndex) {
-    Long newLinesToCover = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_LINES_TO_COVER), periodIndex);
-    if (newLinesToCover == null) {
-      return null;
-    }
-
-    long newConditionsToCover = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_CONDITIONS_TO_COVER), periodIndex, 0L);
-
-    return newLinesToCover + newConditionsToCover;
-  }
-
-  @Override
-  protected long countCoveredElementsForNewCode(DecoratorContext context, int periodIndex) {
-    long newLines = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_LINES_TO_COVER), periodIndex, 0L);
-    long newUncoveredLines = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_UNCOVERED_LINES), periodIndex, 0L);
-    long newUncoveredConditions = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_UNCOVERED_CONDITIONS), periodIndex, 0L);
-    long newConditions = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_CONDITIONS_TO_COVER), periodIndex, 0L);
-
-    return newLines + newConditions - newUncoveredConditions - newUncoveredLines;
-  }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/compute/ItBranchCoverageDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/compute/ItBranchCoverageDecorator.java
deleted file mode 100644 (file)
index 926a34d..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.compute;
-
-import com.google.common.collect.ImmutableList;
-import java.util.List;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.batch.DependsUpon;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.MeasureUtils;
-import org.sonar.api.measures.Metric;
-
-public final class ItBranchCoverageDecorator extends AbstractCoverageDecorator {
-
-  @DependsUpon
-  public List<Metric> dependsUponMetrics() {
-    return ImmutableList.<Metric>of(CoreMetrics.IT_UNCOVERED_CONDITIONS, CoreMetrics.IT_CONDITIONS_TO_COVER,
-      CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS, CoreMetrics.NEW_IT_CONDITIONS_TO_COVER);
-  }
-
-  @Override
-  protected Metric getGeneratedMetric() {
-    return CoreMetrics.IT_BRANCH_COVERAGE;
-  }
-
-  @Override
-  protected Long countElements(DecoratorContext context) {
-    return MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.IT_CONDITIONS_TO_COVER), 0L);
-  }
-
-  @Override
-  protected long countCoveredElements(DecoratorContext context) {
-    long uncoveredConditions = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.IT_UNCOVERED_CONDITIONS), 0L);
-    long conditions = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.IT_CONDITIONS_TO_COVER), 0L);
-
-    return conditions - uncoveredConditions;
-  }
-
-  @Override
-  protected Metric getGeneratedMetricForNewCode() {
-    return CoreMetrics.NEW_IT_BRANCH_COVERAGE;
-  }
-
-  @Override
-  protected Long countElementsForNewCode(DecoratorContext context, int periodIndex) {
-    return MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_IT_CONDITIONS_TO_COVER), periodIndex);
-  }
-
-  @Override
-  protected long countCoveredElementsForNewCode(DecoratorContext context, int periodIndex) {
-    long uncoveredConditions = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS), periodIndex, 0L);
-    long conditions = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_IT_CONDITIONS_TO_COVER), periodIndex, 0L);
-
-    return conditions - uncoveredConditions;
-  }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/compute/ItCoverageDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/compute/ItCoverageDecorator.java
deleted file mode 100644 (file)
index 4d99b75..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.compute;
-
-import com.google.common.collect.ImmutableList;
-import java.util.Collection;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.batch.DependsUpon;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.MeasureUtils;
-import org.sonar.api.measures.Metric;
-
-public final class ItCoverageDecorator extends AbstractCoverageDecorator {
-
-  @DependsUpon
-  public Collection<Metric> usedMetrics() {
-    return ImmutableList.<Metric>of(CoreMetrics.IT_LINES_TO_COVER, CoreMetrics.IT_UNCOVERED_LINES, CoreMetrics.NEW_IT_LINES_TO_COVER,
-      CoreMetrics.NEW_IT_UNCOVERED_LINES, CoreMetrics.IT_CONDITIONS_TO_COVER, CoreMetrics.IT_UNCOVERED_CONDITIONS,
-      CoreMetrics.NEW_IT_CONDITIONS_TO_COVER, CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS);
-  }
-
-  @Override
-  protected Metric getGeneratedMetric() {
-    return CoreMetrics.IT_COVERAGE;
-  }
-
-  @Override
-  protected Long countElements(DecoratorContext context) {
-    long lines = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.IT_LINES_TO_COVER), 0L);
-    long conditions = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.IT_CONDITIONS_TO_COVER), 0L);
-
-    return lines + conditions;
-  }
-
-  @Override
-  protected long countCoveredElements(DecoratorContext context) {
-    long uncoveredLines = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.IT_UNCOVERED_LINES), 0L);
-    long lines = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.IT_LINES_TO_COVER), 0L);
-    long uncoveredConditions = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.IT_UNCOVERED_CONDITIONS), 0L);
-    long conditions = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.IT_CONDITIONS_TO_COVER), 0L);
-
-    return lines + conditions - uncoveredConditions - uncoveredLines;
-  }
-
-  @Override
-  protected Metric getGeneratedMetricForNewCode() {
-    return CoreMetrics.NEW_IT_COVERAGE;
-  }
-
-  @Override
-  protected Long countElementsForNewCode(DecoratorContext context, int periodIndex) {
-    Long newLinesToCover = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_IT_LINES_TO_COVER), periodIndex);
-    if (newLinesToCover == null) {
-      return null;
-    }
-
-    long newConditionsToCover = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_IT_CONDITIONS_TO_COVER), periodIndex, 0L);
-    return newLinesToCover + newConditionsToCover;
-  }
-
-  @Override
-  protected long countCoveredElementsForNewCode(DecoratorContext context, int periodIndex) {
-    long newLines = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_IT_LINES_TO_COVER), periodIndex, 0L);
-    long newUncoveredLines = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_IT_UNCOVERED_LINES), periodIndex, 0L);
-    long newUncoveredConditions = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS), periodIndex, 0L);
-    long newConditions = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_IT_CONDITIONS_TO_COVER), periodIndex, 0L);
-
-    return newLines + newConditions - newUncoveredConditions - newUncoveredLines;
-  }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/compute/ItLineCoverageDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/compute/ItLineCoverageDecorator.java
deleted file mode 100644 (file)
index dddddd0..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.compute;
-
-import com.google.common.collect.ImmutableList;
-import java.util.List;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.batch.DependsUpon;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.MeasureUtils;
-import org.sonar.api.measures.Metric;
-
-public final class ItLineCoverageDecorator extends AbstractCoverageDecorator {
-
-  @DependsUpon
-  public List<Metric> dependsUponMetrics() {
-    return ImmutableList.<Metric>of(CoreMetrics.IT_UNCOVERED_LINES, CoreMetrics.IT_LINES_TO_COVER, CoreMetrics.NEW_IT_UNCOVERED_LINES,
-      CoreMetrics.NEW_IT_LINES_TO_COVER);
-  }
-
-  @Override
-  protected Metric getGeneratedMetric() {
-    return CoreMetrics.IT_LINE_COVERAGE;
-  }
-
-  @Override
-  protected Long countElements(DecoratorContext context) {
-    return MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.IT_LINES_TO_COVER), 0L);
-  }
-
-  @Override
-  protected long countCoveredElements(DecoratorContext context) {
-    long uncoveredLines = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.IT_UNCOVERED_LINES), 0L);
-    long lines = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.IT_LINES_TO_COVER), 0L);
-
-    return lines - uncoveredLines;
-  }
-
-  @Override
-  protected Metric getGeneratedMetricForNewCode() {
-    return CoreMetrics.NEW_IT_LINE_COVERAGE;
-  }
-
-  @Override
-  protected Long countElementsForNewCode(DecoratorContext context, int periodIndex) {
-    return MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_IT_LINES_TO_COVER), periodIndex);
-  }
-
-  @Override
-  protected long countCoveredElementsForNewCode(DecoratorContext context, int periodIndex) {
-    long uncoveredLines = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_IT_UNCOVERED_LINES), periodIndex, 0L);
-    long lines = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_IT_LINES_TO_COVER), periodIndex, 0L);
-
-    return lines - uncoveredLines;
-  }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/compute/LineCoverageDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/compute/LineCoverageDecorator.java
deleted file mode 100644 (file)
index 71c6a03..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.compute;
-
-import java.util.Collection;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.batch.DependsUpon;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.MeasureUtils;
-import org.sonar.api.measures.Metric;
-import org.sonar.batch.sensor.coverage.CoverageConstants;
-
-public final class LineCoverageDecorator extends AbstractCoverageDecorator {
-
-  @DependsUpon
-  public Collection<Metric> dependsUponMetrics() {
-    return CoverageConstants.LINE_COVERAGE_METRICS;
-  }
-
-  @Override
-  protected Metric getGeneratedMetric() {
-    return CoreMetrics.LINE_COVERAGE;
-  }
-
-  @Override
-  protected Long countElements(DecoratorContext context) {
-    return MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.LINES_TO_COVER), 0L);
-  }
-
-  @Override
-  protected long countCoveredElements(DecoratorContext context) {
-    long uncoveredLines = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.UNCOVERED_LINES), 0L);
-    long lines = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.LINES_TO_COVER), 0L);
-
-    return lines - uncoveredLines;
-  }
-
-  @Override
-  protected Metric getGeneratedMetricForNewCode() {
-    return CoreMetrics.NEW_LINE_COVERAGE;
-  }
-
-  @Override
-  protected Long countElementsForNewCode(DecoratorContext context, int periodIndex) {
-    return MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_LINES_TO_COVER), periodIndex);
-  }
-
-  @Override
-  protected long countCoveredElementsForNewCode(DecoratorContext context, int periodIndex) {
-    long uncoveredLines = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_UNCOVERED_LINES), periodIndex, 0L);
-    long lines = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_LINES_TO_COVER), periodIndex, 0L);
-
-    return lines - uncoveredLines;
-  }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/compute/OverallBranchCoverageDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/compute/OverallBranchCoverageDecorator.java
deleted file mode 100644 (file)
index 271cfcd..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.compute;
-
-import com.google.common.collect.ImmutableList;
-import java.util.List;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.batch.DependsUpon;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.MeasureUtils;
-import org.sonar.api.measures.Metric;
-
-public final class OverallBranchCoverageDecorator extends AbstractCoverageDecorator {
-
-  @DependsUpon
-  public List<Metric> dependsUponMetrics() {
-    return ImmutableList.<Metric>of(CoreMetrics.OVERALL_UNCOVERED_CONDITIONS, CoreMetrics.OVERALL_CONDITIONS_TO_COVER,
-      CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS, CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER);
-  }
-
-  @Override
-  protected Metric getGeneratedMetric() {
-    return CoreMetrics.OVERALL_BRANCH_COVERAGE;
-  }
-
-  @Override
-  protected Long countElements(DecoratorContext context) {
-    return MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.OVERALL_CONDITIONS_TO_COVER), 0L);
-  }
-
-  @Override
-  protected long countCoveredElements(DecoratorContext context) {
-    long uncoveredConditions = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.OVERALL_UNCOVERED_CONDITIONS), 0L);
-    long conditions = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.OVERALL_CONDITIONS_TO_COVER), 0L);
-
-    return conditions - uncoveredConditions;
-  }
-
-  @Override
-  protected Metric getGeneratedMetricForNewCode() {
-    return CoreMetrics.NEW_OVERALL_BRANCH_COVERAGE;
-  }
-
-  @Override
-  protected Long countElementsForNewCode(DecoratorContext context, int periodIndex) {
-    return MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER), periodIndex);
-  }
-
-  @Override
-  protected long countCoveredElementsForNewCode(DecoratorContext context, int periodIndex) {
-    long uncoveredConditions = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS), periodIndex, 0L);
-    long conditions = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER), periodIndex, 0L);
-
-    return conditions - uncoveredConditions;
-  }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/compute/OverallCoverageDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/compute/OverallCoverageDecorator.java
deleted file mode 100644 (file)
index c4a4d03..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.compute;
-
-import com.google.common.collect.ImmutableList;
-import java.util.Collection;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.batch.DependsUpon;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.MeasureUtils;
-import org.sonar.api.measures.Metric;
-
-public final class OverallCoverageDecorator extends AbstractCoverageDecorator {
-
-  @DependsUpon
-  public Collection<Metric> usedMetrics() {
-    return ImmutableList.<Metric>of(CoreMetrics.OVERALL_LINES_TO_COVER, CoreMetrics.OVERALL_UNCOVERED_LINES, CoreMetrics.NEW_OVERALL_LINES_TO_COVER,
-      CoreMetrics.NEW_OVERALL_UNCOVERED_LINES, CoreMetrics.OVERALL_CONDITIONS_TO_COVER, CoreMetrics.OVERALL_UNCOVERED_CONDITIONS,
-      CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER, CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS);
-  }
-
-  @Override
-  protected Metric getGeneratedMetric() {
-    return CoreMetrics.OVERALL_COVERAGE;
-  }
-
-  @Override
-  protected Long countElements(DecoratorContext context) {
-    long lines = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.OVERALL_LINES_TO_COVER), 0L);
-    long conditions = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.OVERALL_CONDITIONS_TO_COVER), 0L);
-
-    return lines + conditions;
-  }
-
-  @Override
-  protected long countCoveredElements(DecoratorContext context) {
-    long uncoveredLines = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.OVERALL_UNCOVERED_LINES), 0L);
-    long lines = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.OVERALL_LINES_TO_COVER), 0L);
-    long uncoveredConditions = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.OVERALL_UNCOVERED_CONDITIONS), 0L);
-    long conditions = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.OVERALL_CONDITIONS_TO_COVER), 0L);
-
-    return lines + conditions - uncoveredConditions - uncoveredLines;
-  }
-
-  @Override
-  protected Metric getGeneratedMetricForNewCode() {
-    return CoreMetrics.NEW_OVERALL_COVERAGE;
-  }
-
-  @Override
-  protected Long countElementsForNewCode(DecoratorContext context, int periodIndex) {
-    Long newLinesToCover = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_OVERALL_LINES_TO_COVER), periodIndex);
-    if (newLinesToCover == null) {
-      return null;
-    }
-
-    long newConditionsToCover = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER), periodIndex, 0L);
-
-    return newLinesToCover + newConditionsToCover;
-  }
-
-  @Override
-  protected long countCoveredElementsForNewCode(DecoratorContext context, int periodIndex) {
-    long newLines = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_OVERALL_LINES_TO_COVER), periodIndex, 0L);
-    long newUncoveredLines = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_OVERALL_UNCOVERED_LINES), periodIndex, 0L);
-    long newUncoveredConditions = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS), periodIndex, 0L);
-    long newConditions = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER), periodIndex, 0L);
-
-    return newLines + newConditions - newUncoveredConditions - newUncoveredLines;
-  }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/compute/OverallLineCoverageDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/compute/OverallLineCoverageDecorator.java
deleted file mode 100644 (file)
index a41440e..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.compute;
-
-import com.google.common.collect.ImmutableList;
-import java.util.List;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.batch.DependsUpon;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.MeasureUtils;
-import org.sonar.api.measures.Metric;
-
-public final class OverallLineCoverageDecorator extends AbstractCoverageDecorator {
-
-  @DependsUpon
-  public List<Metric> dependsUponMetrics() {
-    return ImmutableList.<Metric>of(CoreMetrics.OVERALL_UNCOVERED_LINES, CoreMetrics.OVERALL_LINES_TO_COVER, CoreMetrics.NEW_OVERALL_UNCOVERED_LINES,
-      CoreMetrics.NEW_OVERALL_LINES_TO_COVER);
-  }
-
-  @Override
-  protected Metric getGeneratedMetric() {
-    return CoreMetrics.OVERALL_LINE_COVERAGE;
-  }
-
-  @Override
-  protected Long countElements(DecoratorContext context) {
-    return MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.OVERALL_LINES_TO_COVER), 0L);
-  }
-
-  @Override
-  protected long countCoveredElements(DecoratorContext context) {
-    long uncoveredLines = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.OVERALL_UNCOVERED_LINES), 0L);
-    long lines = MeasureUtils.getValueAsLong(context.getMeasure(CoreMetrics.OVERALL_LINES_TO_COVER), 0L);
-
-    return lines - uncoveredLines;
-  }
-
-  @Override
-  protected Metric getGeneratedMetricForNewCode() {
-    return CoreMetrics.NEW_OVERALL_LINE_COVERAGE;
-  }
-
-  @Override
-  protected Long countElementsForNewCode(DecoratorContext context, int periodIndex) {
-    return MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_OVERALL_LINES_TO_COVER), periodIndex);
-  }
-
-  @Override
-  protected long countCoveredElementsForNewCode(DecoratorContext context, int periodIndex) {
-    long uncoveredLines = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_OVERALL_UNCOVERED_LINES), periodIndex, 0L);
-    long lines = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_OVERALL_LINES_TO_COVER), periodIndex, 0L);
-
-    return lines - uncoveredLines;
-  }
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/compute/BranchCoverageDecoratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/compute/BranchCoverageDecoratorTest.java
deleted file mode 100644 (file)
index a7f9e09..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.compute;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.Scopes;
-
-import static org.mockito.Matchers.anyDouble;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class BranchCoverageDecoratorTest {
-  private final BranchCoverageDecorator decorator = new BranchCoverageDecorator();
-  private final Project resource = mock(Project.class);
-
-  @Before
-  public void setUp() {
-    when(resource.getScope()).thenReturn(Scopes.PROJECT);
-    when(resource.getQualifier()).thenReturn(Qualifiers.PROJECT);
-  }
-
-  @Test
-  public void shouldSaveBranchCoverage() {
-    DecoratorContext context = mockContext(20, 15);
-
-    decorator.decorate(resource, context);
-
-    verify(context).saveMeasure(CoreMetrics.BRANCH_COVERAGE, 25.0);
-  }
-
-  @Test
-  public void shouldNotSaveBranchCoverageIfMissingConditions() {
-    DecoratorContext context = mock(DecoratorContext.class);
-
-    decorator.decorate(resource, context);
-
-    verify(context, never()).saveMeasure(eq(CoreMetrics.BRANCH_COVERAGE), anyDouble());
-  }
-
-  private static DecoratorContext mockContext(int conditions, int uncoveredConditions) {
-    DecoratorContext context = mock(DecoratorContext.class);
-    when(context.getMeasure(CoreMetrics.CONDITIONS_TO_COVER)).thenReturn(new Measure(CoreMetrics.CONDITIONS_TO_COVER, (double) conditions));
-    when(context.getMeasure(CoreMetrics.UNCOVERED_CONDITIONS)).thenReturn(new Measure(CoreMetrics.UNCOVERED_CONDITIONS, (double) uncoveredConditions));
-    return context;
-  }
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/compute/CoverageDecoratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/compute/CoverageDecoratorTest.java
deleted file mode 100644 (file)
index 5994f3e..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.compute;
-
-import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Scopes;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.anyDouble;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class CoverageDecoratorTest {
-  private CoverageDecorator decorator;
-  private final Project project = mock(Project.class);
-
-  @Before
-  public void before() {
-    when(project.getScope()).thenReturn(Scopes.PROJECT);
-    decorator = new CoverageDecorator();
-  }
-
-  @Test
-  public void should_use_metrics() {
-    Collection<Metric> metrics = decorator.usedMetrics();
-
-    assertThat(metrics).containsOnly(CoreMetrics.LINES_TO_COVER, CoreMetrics.UNCOVERED_LINES, CoreMetrics.NEW_LINES_TO_COVER,
-      CoreMetrics.NEW_UNCOVERED_LINES, CoreMetrics.CONDITIONS_TO_COVER, CoreMetrics.UNCOVERED_CONDITIONS,
-      CoreMetrics.NEW_CONDITIONS_TO_COVER, CoreMetrics.NEW_UNCOVERED_CONDITIONS);
-  }
-
-  @Test
-  public void coverage() {
-    DecoratorContext context = mockContext(50, 40, 10, 8);
-
-    decorator.decorate(project, context);
-
-    // (50-40 covered lines + 10-8 covered conditions) / (50 lines + 10 conditions)
-    verify(context).saveMeasure(CoreMetrics.COVERAGE, 20.0);
-  }
-
-  @Test
-  public void coverageCanBe0() {
-    DecoratorContext context = mockContext(50, 50, 5, 5);
-
-    decorator.decorate(project, context);
-
-    verify(context).saveMeasure(CoreMetrics.COVERAGE, 0.0);
-  }
-
-  @Test
-  public void coverageCanBe100() {
-    DecoratorContext context = mockContext(50, 0, 5, 0);
-
-    decorator.decorate(project, context);
-
-    verify(context).saveMeasure(CoreMetrics.COVERAGE, 100.0);
-  }
-
-  @Test
-  public void noCoverageIfNoElements() {
-    DecoratorContext context = mock(DecoratorContext.class);
-
-    decorator.decorate(project, context);
-
-    verify(context, never()).saveMeasure(eq(CoreMetrics.COVERAGE), anyDouble());
-  }
-
-  @Test
-  public void should_count_elements_for_new_code() {
-    Measure newLines = measureWithVariation(1, 100.0);
-    Measure newConditions = measureWithVariation(1, 1.0);
-    DecoratorContext context = mockNewContext(newLines, null, null, newConditions);
-
-    long count = decorator.countElementsForNewCode(context, 1);
-
-    assertThat(count).isEqualTo(101).isEqualTo(100 + 1);
-  }
-
-  @Test
-  public void should_count_covered_elements_for_new_code() {
-    Measure newLines = measureWithVariation(1, 100.0);
-    Measure newUncoveredConditions = measureWithVariation(1, 10.0);
-    Measure newUncoveredLines = measureWithVariation(1, 5.0);
-    Measure newConditions = measureWithVariation(1, 1.0);
-    DecoratorContext context = mockNewContext(newLines, newUncoveredConditions, newUncoveredLines, newConditions);
-
-    long count = decorator.countCoveredElementsForNewCode(context, 1);
-
-    assertThat(count).isEqualTo(86).isEqualTo(100 + 1 - 10 - 5);
-  }
-
-  private static DecoratorContext mockContext(int lines, int uncoveredLines, int conditions, int uncoveredConditions) {
-    DecoratorContext context = mock(DecoratorContext.class);
-    when(context.getMeasure(CoreMetrics.LINES_TO_COVER)).thenReturn(new Measure(CoreMetrics.LINES_TO_COVER, (double) lines));
-    when(context.getMeasure(CoreMetrics.UNCOVERED_LINES)).thenReturn(new Measure(CoreMetrics.UNCOVERED_LINES, (double) uncoveredLines));
-    when(context.getMeasure(CoreMetrics.CONDITIONS_TO_COVER)).thenReturn(new Measure(CoreMetrics.CONDITIONS_TO_COVER, (double) conditions));
-    when(context.getMeasure(CoreMetrics.UNCOVERED_CONDITIONS)).thenReturn(new Measure(CoreMetrics.UNCOVERED_CONDITIONS, (double) uncoveredConditions));
-    return context;
-  }
-
-  private static DecoratorContext mockNewContext(Measure newLines, Measure newUncoveredConditions, Measure newUncoveredLines, Measure newConditions) {
-    DecoratorContext context = mock(DecoratorContext.class);
-    when(context.getMeasure(CoreMetrics.NEW_LINES_TO_COVER)).thenReturn(newLines);
-    when(context.getMeasure(CoreMetrics.NEW_UNCOVERED_LINES)).thenReturn(newUncoveredLines);
-    when(context.getMeasure(CoreMetrics.NEW_UNCOVERED_CONDITIONS)).thenReturn(newUncoveredConditions);
-    when(context.getMeasure(CoreMetrics.NEW_CONDITIONS_TO_COVER)).thenReturn(newConditions);
-    return context;
-  }
-
-  private static Measure measureWithVariation(int period, double variation) {
-    Measure measure = mock(Measure.class);
-    when(measure.getVariation(period)).thenReturn(variation);
-    return measure;
-  }
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/compute/ItBranchCoverageDecoratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/compute/ItBranchCoverageDecoratorTest.java
deleted file mode 100644 (file)
index 0e5b70a..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.compute;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.Scopes;
-
-import static org.mockito.Matchers.anyDouble;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class ItBranchCoverageDecoratorTest {
-  private final ItBranchCoverageDecorator decorator = new ItBranchCoverageDecorator();
-  private final Project resource = mock(Project.class);
-
-  @Before
-  public void setUp() {
-    when(resource.getScope()).thenReturn(Scopes.PROJECT);
-    when(resource.getQualifier()).thenReturn(Qualifiers.PROJECT);
-  }
-
-  @Test
-  public void shouldSaveBranchCoverage() {
-    DecoratorContext context = mockContext(20, 15);
-
-    decorator.decorate(resource, context);
-
-    verify(context).saveMeasure(CoreMetrics.IT_BRANCH_COVERAGE, 25.0);
-  }
-
-  @Test
-  public void shouldNotSaveBranchCoverageIfMissingConditions() {
-    DecoratorContext context = mock(DecoratorContext.class);
-
-    decorator.decorate(resource, context);
-
-    verify(context, never()).saveMeasure(eq(CoreMetrics.IT_BRANCH_COVERAGE), anyDouble());
-  }
-
-  private static DecoratorContext mockContext(int conditions, int uncoveredConditions) {
-    DecoratorContext context = mock(DecoratorContext.class);
-    when(context.getMeasure(CoreMetrics.IT_CONDITIONS_TO_COVER)).thenReturn(new Measure(CoreMetrics.IT_CONDITIONS_TO_COVER, (double) conditions));
-    when(context.getMeasure(CoreMetrics.IT_UNCOVERED_CONDITIONS)).thenReturn(new Measure(CoreMetrics.IT_UNCOVERED_CONDITIONS, (double) uncoveredConditions));
-    return context;
-  }
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/compute/ItCoverageDecoratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/compute/ItCoverageDecoratorTest.java
deleted file mode 100644 (file)
index 839577f..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.compute;
-
-import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Scopes;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.anyDouble;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class ItCoverageDecoratorTest {
-  private final ItCoverageDecorator decorator = new ItCoverageDecorator();
-  private final Project project = mock(Project.class);
-
-  @Before
-  public void before() {
-    when(project.getScope()).thenReturn(Scopes.PROJECT);
-  }
-
-  @Test
-  public void should_use_metrics() {
-    Collection<Metric> metrics = decorator.usedMetrics();
-
-    assertThat(metrics).containsOnly(CoreMetrics.IT_LINES_TO_COVER, CoreMetrics.IT_UNCOVERED_LINES, CoreMetrics.NEW_IT_LINES_TO_COVER,
-      CoreMetrics.NEW_IT_UNCOVERED_LINES, CoreMetrics.IT_CONDITIONS_TO_COVER, CoreMetrics.IT_UNCOVERED_CONDITIONS,
-      CoreMetrics.NEW_IT_CONDITIONS_TO_COVER, CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS);
-  }
-
-  @Test
-  public void coverage() {
-    DecoratorContext context = mockContext(50, 40, 10, 8);
-
-    decorator.decorate(project, context);
-
-    // (50-40 covered lines + 10-8 covered conditions) / (50 lines + 10 conditions)
-    verify(context).saveMeasure(CoreMetrics.IT_COVERAGE, 20.0);
-  }
-
-  @Test
-  public void coverageCanBe0() {
-    DecoratorContext context = mockContext(50, 50, 5, 5);
-
-    decorator.decorate(project, context);
-
-    verify(context).saveMeasure(CoreMetrics.IT_COVERAGE, 0.0);
-  }
-
-  @Test
-  public void coverageCanBe100() {
-    DecoratorContext context = mockContext(50, 0, 5, 0);
-
-    decorator.decorate(project, context);
-
-    verify(context).saveMeasure(CoreMetrics.IT_COVERAGE, 100.0);
-  }
-
-  @Test
-  public void noCoverageIfNoElements() {
-    DecoratorContext context = mock(DecoratorContext.class);
-
-    decorator.decorate(project, context);
-
-    verify(context, never()).saveMeasure(eq(CoreMetrics.IT_COVERAGE), anyDouble());
-  }
-
-  @Test
-  public void should_count_elements_for_new_code() {
-    Measure newLines = measureWithVariation(1, 100.0);
-    Measure newConditions = measureWithVariation(1, 1.0);
-    DecoratorContext context = mockNewContext(newLines, null, null, newConditions);
-
-    long count = decorator.countElementsForNewCode(context, 1);
-
-    assertThat(count).isEqualTo(101).isEqualTo(100 + 1);
-  }
-
-  @Test
-  public void should_count_covered_elements_for_new_code() {
-    Measure newLines = measureWithVariation(1, 100.0);
-    Measure newUncoveredConditions = measureWithVariation(1, 10.0);
-    Measure newUncoveredLines = measureWithVariation(1, 5.0);
-    Measure newConditions = measureWithVariation(1, 1.0);
-    DecoratorContext context = mockNewContext(newLines, newUncoveredConditions, newUncoveredLines, newConditions);
-
-    long count = decorator.countCoveredElementsForNewCode(context, 1);
-
-    assertThat(count).isEqualTo(86).isEqualTo(100 + 1 - 10 - 5);
-  }
-
-  private static DecoratorContext mockContext(int lines, int uncoveredLines, int conditions, int uncoveredConditions) {
-    DecoratorContext context = mock(DecoratorContext.class);
-    when(context.getMeasure(CoreMetrics.IT_LINES_TO_COVER)).thenReturn(new Measure(CoreMetrics.IT_LINES_TO_COVER, (double) lines));
-    when(context.getMeasure(CoreMetrics.IT_UNCOVERED_LINES)).thenReturn(new Measure(CoreMetrics.IT_UNCOVERED_LINES, (double) uncoveredLines));
-    when(context.getMeasure(CoreMetrics.IT_CONDITIONS_TO_COVER)).thenReturn(new Measure(CoreMetrics.IT_CONDITIONS_TO_COVER, (double) conditions));
-    when(context.getMeasure(CoreMetrics.IT_UNCOVERED_CONDITIONS)).thenReturn(new Measure(CoreMetrics.IT_UNCOVERED_CONDITIONS, (double) uncoveredConditions));
-    return context;
-  }
-
-  private static DecoratorContext mockNewContext(Measure newLines, Measure newUncoveredConditions, Measure newUncoveredLines, Measure newConditions) {
-    DecoratorContext context = mock(DecoratorContext.class);
-    when(context.getMeasure(CoreMetrics.NEW_IT_LINES_TO_COVER)).thenReturn(newLines);
-    when(context.getMeasure(CoreMetrics.NEW_IT_UNCOVERED_LINES)).thenReturn(newUncoveredLines);
-    when(context.getMeasure(CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS)).thenReturn(newUncoveredConditions);
-    when(context.getMeasure(CoreMetrics.NEW_IT_CONDITIONS_TO_COVER)).thenReturn(newConditions);
-    return context;
-  }
-
-  private static Measure measureWithVariation(int period, double variation) {
-    Measure measure = mock(Measure.class);
-    when(measure.getVariation(period)).thenReturn(variation);
-    return measure;
-  }
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/compute/ItLineCoverageDecoratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/compute/ItLineCoverageDecoratorTest.java
deleted file mode 100644 (file)
index 95e7177..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.compute;
-
-import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Scopes;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.anyDouble;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class ItLineCoverageDecoratorTest {
-  private final ItLineCoverageDecorator decorator = new ItLineCoverageDecorator();
-  private final Project project = mock(Project.class);
-
-  @Before
-  public void before() {
-    when(project.getScope()).thenReturn(Scopes.PROJECT);
-  }
-
-  @Test
-  public void should_depend_on_coverage_metrics() {
-    List<Metric> metrics = decorator.dependsUponMetrics();
-
-    assertThat(metrics).containsOnly(CoreMetrics.IT_UNCOVERED_LINES, CoreMetrics.IT_LINES_TO_COVER, CoreMetrics.NEW_IT_UNCOVERED_LINES, CoreMetrics.NEW_IT_LINES_TO_COVER);
-  }
-
-  @Test
-  public void lineCoverage() {
-    DecoratorContext context = mockContext(50, 10);
-
-    decorator.decorate(project, context);
-
-    // 50-10 covered lines / 50 lines
-    verify(context).saveMeasure(CoreMetrics.IT_LINE_COVERAGE, 80.0);
-  }
-
-  @Test
-  public void zeroCoveredLines() {
-    DecoratorContext context = mockContext(50, 50);
-
-    decorator.decorate(project, context);
-
-    verify(context).saveMeasure(CoreMetrics.IT_LINE_COVERAGE, 0.0);
-  }
-
-  @Test
-  public void allCoveredLines() {
-    DecoratorContext context = mockContext(50, 00);
-
-    decorator.decorate(project, context);
-
-    verify(context).saveMeasure(CoreMetrics.IT_LINE_COVERAGE, 100.0);
-  }
-
-  @Test
-  public void noLineCoverageIfNoLines() {
-    DecoratorContext context = mock(DecoratorContext.class);
-
-    decorator.decorate(project, context);
-
-    verify(context, never()).saveMeasure(eq(CoreMetrics.IT_LINE_COVERAGE), anyDouble());
-  }
-
-  private static DecoratorContext mockContext(int lines, int uncoveredLines) {
-    DecoratorContext context = mock(DecoratorContext.class);
-    when(context.getMeasure(CoreMetrics.IT_LINES_TO_COVER)).thenReturn(new Measure(CoreMetrics.IT_LINES_TO_COVER, (double) lines));
-    when(context.getMeasure(CoreMetrics.IT_UNCOVERED_LINES)).thenReturn(new Measure(CoreMetrics.IT_UNCOVERED_LINES, (double) uncoveredLines));
-    return context;
-  }
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/compute/LineCoverageDecoratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/compute/LineCoverageDecoratorTest.java
deleted file mode 100644 (file)
index 2a49f83..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.compute;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Scopes;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.anyDouble;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class LineCoverageDecoratorTest {
-
-  private LineCoverageDecorator decorator;
-  private final Project project = mock(Project.class);
-
-  @Before
-  public void before() {
-    when(project.getScope()).thenReturn(Scopes.PROJECT);
-    decorator = new LineCoverageDecorator();
-  }
-
-  @Test
-  public void should_depend_on_coverage_metrics() {
-    assertThat(decorator.dependsUponMetrics()).containsOnly(CoreMetrics.UNCOVERED_LINES, CoreMetrics.LINES_TO_COVER, CoreMetrics.NEW_UNCOVERED_LINES,
-      CoreMetrics.NEW_LINES_TO_COVER);
-  }
-
-  @Test
-  public void lineCoverage() {
-    DecoratorContext context = mockContext(50, 10);
-
-    decorator.decorate(project, context);
-
-    // 50-10 covered lines / 50 lines
-    verify(context).saveMeasure(CoreMetrics.LINE_COVERAGE, 80.0);
-  }
-
-  @Test
-  public void zeroCoveredLines() {
-    DecoratorContext context = mockContext(50, 50);
-
-    decorator.decorate(project, context);
-
-    verify(context).saveMeasure(CoreMetrics.LINE_COVERAGE, 0.0);
-  }
-
-  @Test
-  public void allCoveredLines() {
-    DecoratorContext context = mockContext(50, 00);
-
-    decorator.decorate(project, context);
-
-    verify(context).saveMeasure(CoreMetrics.LINE_COVERAGE, 100.0);
-  }
-
-  @Test
-  public void noLineCoverageIfNoLines() {
-    DecoratorContext context = mock(DecoratorContext.class);
-
-    decorator.decorate(project, context);
-
-    verify(context, never()).saveMeasure(eq(CoreMetrics.LINE_COVERAGE), anyDouble());
-  }
-
-  private static DecoratorContext mockContext(int lines, int uncoveredLines) {
-    DecoratorContext context = mock(DecoratorContext.class);
-    when(context.getMeasure(CoreMetrics.LINES_TO_COVER)).thenReturn(new Measure(CoreMetrics.LINES_TO_COVER, (double) lines));
-    when(context.getMeasure(CoreMetrics.UNCOVERED_LINES)).thenReturn(new Measure(CoreMetrics.UNCOVERED_LINES, (double) uncoveredLines));
-    return context;
-  }
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/compute/OverallBranchCoverageDecoratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/compute/OverallBranchCoverageDecoratorTest.java
deleted file mode 100644 (file)
index 9c5e585..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.compute;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.Scopes;
-
-import static org.mockito.Matchers.anyDouble;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class OverallBranchCoverageDecoratorTest {
-  private final OverallBranchCoverageDecorator decorator = new OverallBranchCoverageDecorator();
-  private final Project resource = mock(Project.class);
-
-  @Before
-  public void setUp() {
-    when(resource.getScope()).thenReturn(Scopes.PROJECT);
-    when(resource.getQualifier()).thenReturn(Qualifiers.PROJECT);
-  }
-
-  @Test
-  public void shouldSaveBranchCoverage() {
-    DecoratorContext context = mockContext(20, 15);
-
-    decorator.decorate(resource, context);
-
-    verify(context).saveMeasure(CoreMetrics.OVERALL_BRANCH_COVERAGE, 25.0);
-  }
-
-  @Test
-  public void shouldNotSaveBranchCoverageIfMissingConditions() {
-    DecoratorContext context = mock(DecoratorContext.class);
-
-    decorator.decorate(resource, context);
-
-    verify(context, never()).saveMeasure(eq(CoreMetrics.OVERALL_BRANCH_COVERAGE), anyDouble());
-  }
-
-  private static DecoratorContext mockContext(int conditions, int uncoveredConditions) {
-    DecoratorContext context = mock(DecoratorContext.class);
-    when(context.getMeasure(CoreMetrics.OVERALL_CONDITIONS_TO_COVER)).thenReturn(new Measure(CoreMetrics.OVERALL_CONDITIONS_TO_COVER, (double) conditions));
-    when(context.getMeasure(CoreMetrics.OVERALL_UNCOVERED_CONDITIONS)).thenReturn(new Measure(CoreMetrics.OVERALL_UNCOVERED_CONDITIONS, (double) uncoveredConditions));
-    return context;
-  }
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/compute/OverallCoverageDecoratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/compute/OverallCoverageDecoratorTest.java
deleted file mode 100644 (file)
index d694227..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.compute;
-
-import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Scopes;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.anyDouble;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class OverallCoverageDecoratorTest {
-  private final OverallCoverageDecorator decorator = new OverallCoverageDecorator();
-  private final Project project = mock(Project.class);
-
-  @Before
-  public void before() {
-    when(project.getScope()).thenReturn(Scopes.PROJECT);
-  }
-
-  @Test
-  public void should_use_metrics() {
-    Collection<Metric> metrics = decorator.usedMetrics();
-
-    assertThat(metrics).containsOnly(CoreMetrics.OVERALL_LINES_TO_COVER, CoreMetrics.OVERALL_UNCOVERED_LINES, CoreMetrics.NEW_OVERALL_LINES_TO_COVER,
-      CoreMetrics.NEW_OVERALL_UNCOVERED_LINES, CoreMetrics.OVERALL_CONDITIONS_TO_COVER, CoreMetrics.OVERALL_UNCOVERED_CONDITIONS,
-      CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER, CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS);
-  }
-
-  @Test
-  public void coverage() {
-    DecoratorContext context = mockContext(50, 40, 10, 8);
-
-    decorator.decorate(project, context);
-
-    // (50-40 covered lines + 10-8 covered conditions) / (50 lines + 10 conditions)
-    verify(context).saveMeasure(CoreMetrics.OVERALL_COVERAGE, 20.0);
-  }
-
-  @Test
-  public void coverageCanBe0() {
-    DecoratorContext context = mockContext(50, 50, 5, 5);
-
-    decorator.decorate(project, context);
-
-    verify(context).saveMeasure(CoreMetrics.OVERALL_COVERAGE, 0.0);
-  }
-
-  @Test
-  public void coverageCanBe100() {
-    DecoratorContext context = mockContext(50, 0, 5, 0);
-
-    decorator.decorate(project, context);
-
-    verify(context).saveMeasure(CoreMetrics.OVERALL_COVERAGE, 100.0);
-  }
-
-  @Test
-  public void noCoverageIfNoElements() {
-    DecoratorContext context = mock(DecoratorContext.class);
-
-    decorator.decorate(project, context);
-
-    verify(context, never()).saveMeasure(eq(CoreMetrics.OVERALL_COVERAGE), anyDouble());
-  }
-
-  @Test
-  public void should_count_elements_for_new_code() {
-    Measure newLines = measureWithVariation(1, 100.0);
-    Measure newConditions = measureWithVariation(1, 1.0);
-    DecoratorContext context = mockNewContext(newLines, null, null, newConditions);
-
-    long count = decorator.countElementsForNewCode(context, 1);
-
-    assertThat(count).isEqualTo(101).isEqualTo(100 + 1);
-  }
-
-  @Test
-  public void should_count_covered_elements_for_new_code() {
-    Measure newLines = measureWithVariation(1, 100.0);
-    Measure newUncoveredConditions = measureWithVariation(1, 10.0);
-    Measure newUncoveredLines = measureWithVariation(1, 5.0);
-    Measure newConditions = measureWithVariation(1, 1.0);
-    DecoratorContext context = mockNewContext(newLines, newUncoveredConditions, newUncoveredLines, newConditions);
-
-    long count = decorator.countCoveredElementsForNewCode(context, 1);
-
-    assertThat(count).isEqualTo(86).isEqualTo(100 + 1 - 10 - 5);
-  }
-
-  private static DecoratorContext mockContext(int lines, int uncoveredLines, int conditions, int uncoveredConditions) {
-    DecoratorContext context = mock(DecoratorContext.class);
-    when(context.getMeasure(CoreMetrics.OVERALL_LINES_TO_COVER)).thenReturn(new Measure(CoreMetrics.OVERALL_LINES_TO_COVER, (double) lines));
-    when(context.getMeasure(CoreMetrics.OVERALL_UNCOVERED_LINES)).thenReturn(new Measure(CoreMetrics.OVERALL_UNCOVERED_LINES, (double) uncoveredLines));
-    when(context.getMeasure(CoreMetrics.OVERALL_CONDITIONS_TO_COVER)).thenReturn(new Measure(CoreMetrics.OVERALL_CONDITIONS_TO_COVER, (double) conditions));
-    when(context.getMeasure(CoreMetrics.OVERALL_UNCOVERED_CONDITIONS)).thenReturn(new Measure(CoreMetrics.OVERALL_UNCOVERED_CONDITIONS, (double) uncoveredConditions));
-    return context;
-  }
-
-  private static DecoratorContext mockNewContext(Measure newLines, Measure newUncoveredConditions, Measure newUncoveredLines, Measure newConditions) {
-    DecoratorContext context = mock(DecoratorContext.class);
-    when(context.getMeasure(CoreMetrics.NEW_OVERALL_LINES_TO_COVER)).thenReturn(newLines);
-    when(context.getMeasure(CoreMetrics.NEW_OVERALL_UNCOVERED_LINES)).thenReturn(newUncoveredLines);
-    when(context.getMeasure(CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS)).thenReturn(newUncoveredConditions);
-    when(context.getMeasure(CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER)).thenReturn(newConditions);
-    return context;
-  }
-
-  private static Measure measureWithVariation(int period, double variation) {
-    Measure measure = mock(Measure.class);
-    when(measure.getVariation(period)).thenReturn(variation);
-    return measure;
-  }
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/compute/OverallLineCoverageDecoratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/compute/OverallLineCoverageDecoratorTest.java
deleted file mode 100644 (file)
index 17d5452..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.compute;
-
-import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Scopes;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.anyDouble;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class OverallLineCoverageDecoratorTest {
-  private final OverallLineCoverageDecorator decorator = new OverallLineCoverageDecorator();
-  private final Project project = mock(Project.class);
-
-  @Before
-  public void before() {
-    when(project.getScope()).thenReturn(Scopes.PROJECT);
-  }
-
-  @Test
-  public void should_depend_on_coverage_metrics() {
-    List<Metric> metrics = decorator.dependsUponMetrics();
-
-    assertThat(metrics).containsOnly(CoreMetrics.OVERALL_UNCOVERED_LINES, CoreMetrics.OVERALL_LINES_TO_COVER, CoreMetrics.NEW_OVERALL_UNCOVERED_LINES,
-      CoreMetrics.NEW_OVERALL_LINES_TO_COVER);
-  }
-
-  @Test
-  public void lineCoverage() {
-    DecoratorContext context = mockContext(50, 10);
-
-    decorator.decorate(project, context);
-
-    // 50-10 covered lines / 50 lines
-    verify(context).saveMeasure(CoreMetrics.OVERALL_LINE_COVERAGE, 80.0);
-  }
-
-  @Test
-  public void zeroCoveredLines() {
-    DecoratorContext context = mockContext(50, 50);
-
-    decorator.decorate(project, context);
-
-    verify(context).saveMeasure(CoreMetrics.OVERALL_LINE_COVERAGE, 0.0);
-  }
-
-  @Test
-  public void allCoveredLines() {
-    DecoratorContext context = mockContext(50, 00);
-
-    decorator.decorate(project, context);
-
-    verify(context).saveMeasure(CoreMetrics.OVERALL_LINE_COVERAGE, 100.0);
-  }
-
-  @Test
-  public void noLineCoverageIfNoLines() {
-    DecoratorContext context = mock(DecoratorContext.class);
-
-    decorator.decorate(project, context);
-
-    verify(context, never()).saveMeasure(eq(CoreMetrics.OVERALL_LINE_COVERAGE), anyDouble());
-  }
-
-  private static DecoratorContext mockContext(int lines, int uncoveredLines) {
-    DecoratorContext context = mock(DecoratorContext.class);
-    when(context.getMeasure(CoreMetrics.OVERALL_LINES_TO_COVER)).thenReturn(new Measure(CoreMetrics.OVERALL_LINES_TO_COVER, (double) lines));
-    when(context.getMeasure(CoreMetrics.OVERALL_UNCOVERED_LINES)).thenReturn(new Measure(CoreMetrics.OVERALL_UNCOVERED_LINES, (double) uncoveredLines));
-    return context;
-  }
-}