diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-06-10 09:51:24 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-06-10 09:51:24 +0200 |
commit | fb72da37f25c49ca70518082ed70a8a1af4866b8 (patch) | |
tree | 3d1faca3373179a3fe829858b79e1433f4f1de01 /sonar-batch | |
parent | d62c3a4e2b0fc74ad5041963da90c294080c05b8 (diff) | |
download | sonarqube-fb72da37f25c49ca70518082ed70a8a1af4866b8.tar.gz sonarqube-fb72da37f25c49ca70518082ed70a8a1af4866b8.zip |
Temporarily remove custom measures from batch
They are being moved to Compute Engine.
Diffstat (limited to 'sonar-batch')
4 files changed, 0 insertions, 144 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java index 1773cd1e7a6..34235ba135b 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java @@ -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 index 94346b30b8f..00000000000 --- a/sonar-batch/src/main/java/org/sonar/batch/compute/ManualMeasureDecorator.java +++ /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 index bd86438ad05..00000000000 --- a/sonar-batch/src/test/java/org/sonar/batch/compute/ManualMeasureDecoratorTest.java +++ /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 index 0307f16e6e3..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/compute/ManualMeasureDecoratorTest/testCopyManualMeasures.xml +++ /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 |