]> source.dussan.org Git - sonarqube.git/commitdiff
Temporarily remove custom measures from batch
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 10 Jun 2015 07:51:24 +0000 (09:51 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 10 Jun 2015 07:51:24 +0000 (09:51 +0200)
They are being moved to Compute Engine.

sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java
sonar-batch/src/main/java/org/sonar/batch/compute/ManualMeasureDecorator.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/compute/ManualMeasureDecoratorTest.java [deleted file]
sonar-batch/src/test/resources/org/sonar/batch/compute/ManualMeasureDecoratorTest/testCopyManualMeasures.xml [deleted file]

index 1773cd1e7a6e9c13a1caa137c7c702e8698768e1..34235ba135bbc093aaf242985bf9ab095e29cc46 100644 (file)
@@ -35,7 +35,6 @@ 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.ManualMeasureDecorator;
 import org.sonar.batch.compute.NewCoverageAggregator;
 import org.sonar.batch.compute.NewCoverageFileAnalyzer;
 import org.sonar.batch.compute.NewItCoverageFileAnalyzer;
@@ -132,7 +131,6 @@ public class BatchComponents {
       CommentDensityDecorator.class,
       DirectoriesDecorator.class,
       FilesDecorator.class,
-      ManualMeasureDecorator.class,
       VariationDecorator.class,
       TimeMachineConfigurationPersister.class,
       NewCoverageFileAnalyzer.class,
diff --git a/sonar-batch/src/main/java/org/sonar/batch/compute/ManualMeasureDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/compute/ManualMeasureDecorator.java
deleted file mode 100644 (file)
index 94346b3..0000000
+++ /dev/null
@@ -1,79 +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.sonar.api.batch.Decorator;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.batch.Phase;
-import org.sonar.api.batch.RequiresDB;
-import org.sonar.api.database.DatabaseSession;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.measures.MetricFinder;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Resource;
-import org.sonar.jpa.entity.ManualMeasure;
-
-import static com.google.common.base.Preconditions.checkState;
-
-@Phase(name = Phase.Name.PRE)
-@RequiresDB
-public class ManualMeasureDecorator implements Decorator {
-
-  private DatabaseSession session;
-  private MetricFinder metricFinder;
-
-  public ManualMeasureDecorator(DatabaseSession session, MetricFinder metricFinder) {
-    this.session = session;
-    this.metricFinder = metricFinder;
-  }
-
-  @Override
-  public boolean shouldExecuteOnProject(Project project) {
-    return true;
-  }
-
-  @Override
-  public void decorate(Resource resource, DecoratorContext context) {
-    if (resource.getId() != null) {
-      List<ManualMeasure> manualMeasures = session.getResults(ManualMeasure.class, "resourceId", resource.getId());
-      for (ManualMeasure manualMeasure : manualMeasures) {
-        context.saveMeasure(copy(manualMeasure));
-      }
-    }
-  }
-
-  private Measure copy(ManualMeasure manualMeasure) {
-    Metric metric = metricFinder.findById(manualMeasure.getMetricId());
-    checkState(metric != null, "Unable to find manual metric with id: " + manualMeasure.getMetricId());
-
-    Measure measure = new Measure(metric);
-    measure.setValue(manualMeasure.getValue(), 5);
-    measure.setData(manualMeasure.getTextValue());
-    measure.setDescription(manualMeasure.getDescription());
-    return measure;
-  }
-
-  @Override
-  public String toString() {
-    return getClass().getSimpleName();
-  }
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/compute/ManualMeasureDecoratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/compute/ManualMeasureDecoratorTest.java
deleted file mode 100644 (file)
index bd86438..0000000
+++ /dev/null
@@ -1,52 +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.Test;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.resources.File;
-import org.sonar.api.test.IsMeasure;
-import org.sonar.core.metric.DefaultMetricFinder;
-import org.sonar.jpa.test.AbstractDbUnitTestCase;
-
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-public class ManualMeasureDecoratorTest extends AbstractDbUnitTestCase {
-
-  private Metric reviewNote = new Metric.Builder("review_note", "Note", Metric.ValueType.FLOAT).create().setId(2);
-
-  @Test
-  public void testCopyManualMeasures() throws Exception {
-    setupData("testCopyManualMeasures");
-
-    File javaFile = File.create("Foo.java");
-    javaFile.setId(40);
-
-    ManualMeasureDecorator decorator = new ManualMeasureDecorator(getSession(), new DefaultMetricFinder(getSessionFactory()));
-    DecoratorContext context = mock(DecoratorContext.class);
-    decorator.decorate(javaFile, context);
-
-    verify(context).saveMeasure(argThat(new IsMeasure(reviewNote, 6.0, "six")));
-  }
-
-}
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/compute/ManualMeasureDecoratorTest/testCopyManualMeasures.xml b/sonar-batch/src/test/resources/org/sonar/batch/compute/ManualMeasureDecoratorTest/testCopyManualMeasures.xml
deleted file mode 100644 (file)
index 0307f16..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<dataset>
-  <metrics delete_historical_data="[null]" id="1" NAME="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]"  domain="[null]" short_name=""
-           enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
-  <metrics delete_historical_data="[null]" id="2" NAME="review_note" VAL_TYPE="INT" DESCRIPTION="[null]"  domain="[null]" short_name=""
-           enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
-
-
-  <manual_measures id="1" metric_id="2" resource_id="30" value="3.14" text_value="pi" created_at="[null]" updated_at="[null]" description="this is pi" user_login="me"/>
-  <manual_measures id="2" metric_id="2" resource_id="40" value="6" text_value="six" created_at="[null]" updated_at="[null]" description="this is six" user_login="me"/>
-
-</dataset>
\ No newline at end of file