diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-07-24 10:01:58 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-07-24 10:02:08 +0200 |
commit | 3d5c0f21706bd44755de23ead87e833f2a12db6f (patch) | |
tree | b6ed44b1a6bfedeff347987c55406a6e8bd5108e | |
parent | c31cbfe24543d7e7e35380ef941e92cef9aac77c (diff) | |
download | sonarqube-3d5c0f21706bd44755de23ead87e833f2a12db6f.tar.gz sonarqube-3d5c0f21706bd44755de23ead87e833f2a12db6f.zip |
Add @deprecated and all formulas api and remove some decorator usage in test
7 files changed, 14 insertions, 64 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/profiling/PhasesSumUpTimeProfilerTest.java b/sonar-batch/src/test/java/org/sonar/batch/profiling/PhasesSumUpTimeProfilerTest.java index 1ff8b82c9c4..7ef1d23673d 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/profiling/PhasesSumUpTimeProfilerTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/profiling/PhasesSumUpTimeProfilerTest.java @@ -30,7 +30,6 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.api.CoreProperties; import org.sonar.api.batch.Decorator; -import org.sonar.api.batch.DecoratorContext; import org.sonar.api.batch.Initializer; import org.sonar.api.batch.PostJob; import org.sonar.api.batch.Sensor; @@ -48,7 +47,6 @@ import org.sonar.api.batch.events.SensorExecutionHandler.SensorExecutionEvent; import org.sonar.api.batch.events.SensorsPhaseHandler; import org.sonar.api.batch.events.SensorsPhaseHandler.SensorsPhaseEvent; import org.sonar.api.resources.Project; -import org.sonar.api.resources.Resource; import org.sonar.api.utils.System2; import org.sonar.batch.bootstrap.BootstrapProperties; import org.sonar.batch.events.BatchStepEvent; @@ -83,10 +81,8 @@ public class PhasesSumUpTimeProfilerTest { assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.INIT).getProfilingPerItem(new FakeInitializer()).totalTime()).isEqualTo(7L); assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.SENSOR).getProfilingPerItem(new FakeSensor()).totalTime()).isEqualTo(10L); - assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.DECORATOR).getProfilingPerItem(new FakeDecorator1()).totalTime()).isEqualTo(20L); assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.POSTJOB).getProfilingPerItem(new FakePostJob()).totalTime()).isEqualTo(30L); assertThat(profiler.currentModuleProfiling.getProfilingPerBatchStep("Free memory").totalTime()).isEqualTo(9L); - } @Test @@ -102,14 +98,10 @@ public class PhasesSumUpTimeProfilerTest { assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.INIT).getProfilingPerItem(new FakeInitializer()).totalTime()).isEqualTo(7L); assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.SENSOR).getProfilingPerItem(new FakeSensor()).totalTime()).isEqualTo(10L); - assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.DECORATOR).getProfilingPerItem(new FakeDecorator1()).totalTime()).isEqualTo(20L); - assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.DECORATOR).getProfilingPerItem(new FakeDecorator2()).totalTime()).isEqualTo(10L); assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.POSTJOB).getProfilingPerItem(new FakePostJob()).totalTime()).isEqualTo(30L); assertThat(profiler.totalProfiling.getProfilingPerPhase(Phase.INIT).getProfilingPerItem(new FakeInitializer()).totalTime()).isEqualTo(21L); assertThat(profiler.totalProfiling.getProfilingPerPhase(Phase.SENSOR).getProfilingPerItem(new FakeSensor()).totalTime()).isEqualTo(30L); - assertThat(profiler.totalProfiling.getProfilingPerPhase(Phase.DECORATOR).getProfilingPerItem(new FakeDecorator1()).totalTime()).isEqualTo(60L); - assertThat(profiler.totalProfiling.getProfilingPerPhase(Phase.DECORATOR).getProfilingPerItem(new FakeDecorator2()).totalTime()).isEqualTo(30L); assertThat(profiler.totalProfiling.getProfilingPerPhase(Phase.POSTJOB).getProfilingPerItem(new FakePostJob()).totalTime()).isEqualTo(90L); } @@ -156,42 +148,12 @@ public class PhasesSumUpTimeProfilerTest { profiler.onProjectAnalysis(projectEvent(module, true)); initializerPhase(profiler); sensorPhase(profiler); - decoratorPhase(profiler); postJobPhase(profiler); batchStep(profiler); // End of moduleA profiler.onProjectAnalysis(projectEvent(module, false)); } - private void decoratorPhase(PhasesSumUpTimeProfiler profiler) { - Decorator decorator1 = new FakeDecorator1(); - Decorator decorator2 = new FakeDecorator2(); - // Start of decorator phase - profiler.onDecoratorsPhase(decoratorsEvent(true)); - // Start of decorator 1 - profiler.onDecoratorExecution(decoratorEvent(decorator1, true)); - clock.sleep(10); - // End of decorator 1 - profiler.onDecoratorExecution(decoratorEvent(decorator1, false)); - // Start of decorator 2 - profiler.onDecoratorExecution(decoratorEvent(decorator2, true)); - clock.sleep(5); - // End of decorator 2 - profiler.onDecoratorExecution(decoratorEvent(decorator2, false)); - // Start of decorator 1 - profiler.onDecoratorExecution(decoratorEvent(decorator1, true)); - clock.sleep(10); - // End of decorator 1 - profiler.onDecoratorExecution(decoratorEvent(decorator1, false)); - // Start of decorator 2 - profiler.onDecoratorExecution(decoratorEvent(decorator2, true)); - clock.sleep(5); - // End of decorator 2 - profiler.onDecoratorExecution(decoratorEvent(decorator2, false)); - // End of decorator phase - profiler.onDecoratorsPhase(decoratorsEvent(false)); - } - private void batchStep(PhasesSumUpTimeProfiler profiler) { // Start of batch step profiler.onBatchStep(new BatchStepEvent("Free memory", true)); @@ -440,28 +402,6 @@ public class PhasesSumUpTimeProfilerTest { } } - public class FakeDecorator1 implements Decorator { - @Override - public void decorate(Resource resource, DecoratorContext context) { - } - - @Override - public boolean shouldExecuteOnProject(Project project) { - return true; - } - } - - public class FakeDecorator2 implements Decorator { - @Override - public void decorate(Resource resource, DecoratorContext context) { - } - - @Override - public boolean shouldExecuteOnProject(Project project) { - return true; - } - } - public class FakePostJob implements PostJob { @Override public void executeOn(Project project, SensorContext context) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractSumChildrenDecorator.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractSumChildrenDecorator.java index 0a933ad0f09..964d8a3f8b8 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractSumChildrenDecorator.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractSumChildrenDecorator.java @@ -19,19 +19,20 @@ */ package org.sonar.api.batch; +import java.util.List; import org.sonar.api.measures.Measure; import org.sonar.api.measures.MeasureUtils; import org.sonar.api.measures.Metric; import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; -import java.util.List; - /** * Sum measures of child resources. * * @since 1.10 + * @deprecated since 5.2 there's no more decorator on batch side */ +@Deprecated public abstract class AbstractSumChildrenDecorator implements Decorator { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/AverageFormula.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/AverageFormula.java index 976508710d6..f029f438918 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/AverageFormula.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/AverageFormula.java @@ -31,7 +31,9 @@ import static com.google.common.collect.Lists.newArrayList; * For example: to compute the metric "complexity by file", the main metric (A) is "complexity" and the other metric (B) is "file". * * @since 3.0 + * @deprecated since 5.2 decorators are no more executed on batch side */ +@Deprecated public class AverageFormula implements Formula { private Metric mainMetric; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeanAggregationFormula.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeanAggregationFormula.java index ec65d5a730f..f66bf51009d 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeanAggregationFormula.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeanAggregationFormula.java @@ -25,7 +25,9 @@ import java.util.List; /** * @since 2.0 + * @deprecated since 5.2 decorators are no more executed on batch side */ +@Deprecated public class MeanAggregationFormula implements Formula { private boolean forceZeroIfMissingData=false; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/SumChildDistributionFormula.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/SumChildDistributionFormula.java index f00edfad56f..e75a2f3c119 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/SumChildDistributionFormula.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/SumChildDistributionFormula.java @@ -19,17 +19,18 @@ */ package org.sonar.api.measures; -import org.sonar.api.resources.Scopes; - import java.util.Collection; import java.util.Collections; import java.util.List; +import org.sonar.api.resources.Scopes; /** * @since 2.0 * * Used to consolidate a distribution measure throughout the resource tree + * @deprecated since 5.2 decorators are no more executed on batch side */ +@Deprecated public class SumChildDistributionFormula implements Formula { private String minimumScopeToPersist= Scopes.FILE; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/SumChildValuesFormula.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/SumChildValuesFormula.java index a81d7e0bac4..37e7abf6a25 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/SumChildValuesFormula.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/SumChildValuesFormula.java @@ -24,7 +24,9 @@ import java.util.List; /** * @since 1.11 + * @deprecated since 5.2 decorators are no more executed on batch side */ +@Deprecated public class SumChildValuesFormula implements Formula { private boolean saveZeroIfNoChildValues; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/WeightedMeanAggregationFormula.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/WeightedMeanAggregationFormula.java index fc8900d8a94..7be604edaf6 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/WeightedMeanAggregationFormula.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/WeightedMeanAggregationFormula.java @@ -24,7 +24,9 @@ import java.util.List; /** * @since 2.0 + * @deprecated since 5.2 decorators are no more executed on batch side */ +@Deprecated public class WeightedMeanAggregationFormula implements Formula { private Metric weightingMetric; |