import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryImpl;
import org.sonar.server.computation.task.projectanalysis.measure.MeasureToMeasureDto;
import org.sonar.server.computation.task.projectanalysis.metric.MetricModule;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderImpl;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolderImpl;
import org.sonar.server.computation.task.projectanalysis.qualitygate.EvaluationResultTextConverterImpl;
import org.sonar.server.computation.task.projectanalysis.qualitygate.QualityGateHolderImpl;
import org.sonar.server.computation.task.projectanalysis.qualitygate.QualityGateServiceImpl;
CrossProjectDuplicationStatusHolderImpl.class,
BatchReportDirectoryHolderImpl.class,
TreeRootHolderImpl.class,
- PeriodsHolderImpl.class,
+ PeriodHolderImpl.class,
QualityGateHolderImpl.class,
QualityGateStatusHolderImpl.class,
RatingSettings.class,
import org.sonar.server.computation.task.projectanalysis.metric.Metric;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepository;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolder;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolder;
import static java.util.Objects.requireNonNull;
};
@CheckForNull
- private final PeriodsHolder periodsHolder;
+ private final PeriodHolder periodHolder;
private final MetricRepository metricRepository;
private final MeasureRepository measureRepository;
private final List<Formula> formulas;
private FormulaExecutorComponentVisitor(Builder builder, Iterable<Formula> formulas) {
super(CrawlerDepthLimit.LEAVES, ComponentVisitor.Order.POST_ORDER, COUNTERS_FACTORY);
- this.periodsHolder = builder.periodsHolder;
+ this.periodHolder = builder.periodHolder;
this.measureRepository = builder.measureRepository;
this.metricRepository = builder.metricRepository;
this.formulas = ImmutableList.copyOf(formulas);
private final MetricRepository metricRepository;
private final MeasureRepository measureRepository;
@CheckForNull
- private PeriodsHolder periodsHolder;
+ private PeriodHolder periodHolder;
private Builder(MetricRepository metricRepository, MeasureRepository measureRepository) {
this.metricRepository = requireNonNull(metricRepository);
return new Builder(metricRepository, measureRepository);
}
- public Builder withVariationSupport(PeriodsHolder periodsHolder) {
- this.periodsHolder = requireNonNull(periodsHolder);
+ public Builder withVariationSupport(PeriodHolder periodHolder) {
+ this.periodHolder = requireNonNull(periodHolder);
return this;
}
@Override
public Period getPeriod() {
- return periodsHolder.getPeriod();
+ return periodHolder.getPeriod();
}
@Override
public boolean hasPeriod() {
- return periodsHolder.hasPeriod();
+ return periodHolder.hasPeriod();
}
}
@Override
public Period getPeriod() {
- return periodsHolder.getPeriod();
+ return periodHolder.getPeriod();
}
@Override
public boolean hasPeriod() {
- return periodsHolder.hasPeriod();
+ return periodHolder.hasPeriod();
}
}
}
import org.sonar.server.computation.task.projectanalysis.metric.Metric;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepository;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolder;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolder;
import static org.sonar.api.issue.Issue.RESOLUTION_FALSE_POSITIVE;
import static org.sonar.api.issue.Issue.RESOLUTION_WONT_FIX;
.put(RuleType.VULNERABILITY, CoreMetrics.NEW_VULNERABILITIES_KEY)
.build();
- private final PeriodsHolder periodsHolder;
+ private final PeriodHolder periodHolder;
private final MetricRepository metricRepository;
private final MeasureRepository measureRepository;
private final Map<Integer, Counters> countersByComponentRef = new HashMap<>();
private Counters currentCounters;
- public IssueCounter(PeriodsHolder periodsHolder,
+ public IssueCounter(PeriodHolder periodHolder,
MetricRepository metricRepository, MeasureRepository measureRepository) {
- this.periodsHolder = periodsHolder;
+ this.periodHolder = periodHolder;
this.metricRepository = metricRepository;
this.measureRepository = measureRepository;
}
@Override
public void onIssue(Component component, DefaultIssue issue) {
currentCounters.add(issue);
- if (!periodsHolder.hasPeriod()) {
+ if (!periodHolder.hasPeriod()) {
return;
}
- Period period = periodsHolder.getPeriod();
+ Period period = periodHolder.getPeriod();
// Add one second to not take into account issues created during current analysis
if (issue.creationDate().getTime() >= period.getSnapshotDate() + 1000L) {
currentCounters.addOnPeriod(issue);
}
private void addMeasuresByPeriod(Component component) {
- if (!periodsHolder.hasPeriod()) {
+ if (!periodHolder.hasPeriod()) {
return;
}
Double unresolvedVariations = (double) currentCounters.counterForPeriod().unresolved;
import org.sonar.server.computation.task.projectanalysis.metric.Metric;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepository;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolder;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolder;
import static org.sonar.api.measures.CoreMetrics.NEW_RELIABILITY_REMEDIATION_EFFORT_KEY;
import static org.sonar.api.measures.CoreMetrics.NEW_SECURITY_REMEDIATION_EFFORT_KEY;
public class NewEffortAggregator extends IssueVisitor {
private final NewEffortCalculator calculator;
- private final PeriodsHolder periodsHolder;
+ private final PeriodHolder periodHolder;
private final DbClient dbClient;
private final MeasureRepository measureRepository;
private Map<Integer, NewEffortCounter> counterByComponentRef = new HashMap<>();
private NewEffortCounter counter = null;
- public NewEffortAggregator(NewEffortCalculator calculator, PeriodsHolder periodsHolder, DbClient dbClient,
- MetricRepository metricRepository, MeasureRepository measureRepository) {
+ public NewEffortAggregator(NewEffortCalculator calculator, PeriodHolder periodHolder, DbClient dbClient,
+ MetricRepository metricRepository, MeasureRepository measureRepository) {
this.calculator = calculator;
- this.periodsHolder = periodsHolder;
+ this.periodHolder = periodHolder;
this.dbClient = dbClient;
this.measureRepository = measureRepository;
@Override
public void onIssue(Component component, DefaultIssue issue) {
- if (issue.resolution() == null && issue.effortInMinutes() != null && periodsHolder.hasPeriod()) {
+ if (issue.resolution() == null && issue.effortInMinutes() != null && periodHolder.hasPeriod()) {
List<IssueChangeDto> changelog = changesByIssueUuid.get(issue.key());
- counter.add(issue, periodsHolder.getPeriod(), changelog);
+ counter.add(issue, periodHolder.getPeriod(), changelog);
}
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.server.computation.task.projectanalysis.period;
+
+/**
+ * Repository of period used to compute differential measures.
+ * Here are the steps to retrieve the period :
+ * - Read the period property ${@link org.sonar.core.config.CorePropertyDefinitions#TIMEMACHINE_PERIOD_PREFIX}
+ * - Try to find the matching snapshots from the property
+ * - If a snapshot is found, the period is added to the repository
+ */
+public interface PeriodHolder {
+
+ /**
+ * Finds out whether the holder contains a Period
+ *
+ * @throws IllegalStateException if the periods haven't been initialized
+ */
+ boolean hasPeriod();
+
+ /**
+ * Retrieve the period from the Holder.
+ *
+ * @throws IllegalStateException if the periods haven't been initialized
+ */
+ Period getPeriod();
+
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.server.computation.task.projectanalysis.period;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
+import static com.google.common.base.Preconditions.checkState;
+
+public class PeriodHolderImpl implements PeriodHolder {
+
+ @CheckForNull
+ private Period period = null;
+ private boolean initialized = false;
+
+ /**
+ * Initializes the periods in the holder.
+ *
+ * @throws IllegalStateException if the holder has already been initialized
+ */
+ public void setPeriod(@Nullable Period period) {
+ checkState(!initialized, "Period have already been initialized");
+ this.period = period;
+ this.initialized = true;
+ }
+
+ @Override
+ public boolean hasPeriod() {
+ checkHolderIsInitialized();
+ return period != null;
+ }
+
+ @Override
+ public Period getPeriod() {
+ checkHolderIsInitialized();
+ return period;
+ }
+
+ private void checkHolderIsInitialized() {
+ checkState(initialized, "Period have not been initialized yet");
+ }
+
+}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.server.computation.task.projectanalysis.period;
-
-/**
- * Repository of period used to compute differential measures.
- * Here are the steps to retrieve the period :
- * - Read the period property ${@link org.sonar.core.config.CorePropertyDefinitions#TIMEMACHINE_PERIOD_PREFIX}
- * - Try to find the matching snapshots from the property
- * - If a snapshot is found, the period is added to the repository
- */
-public interface PeriodsHolder {
-
- /**
- * Finds out whether the holder contains a Period
- *
- * @throws IllegalStateException if the periods haven't been initialized
- */
- boolean hasPeriod();
-
- /**
- * Retrieve the period from the Holder.
- *
- * @throws IllegalStateException if the periods haven't been initialized
- */
- Period getPeriod();
-
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.server.computation.task.projectanalysis.period;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import static com.google.common.base.Preconditions.checkState;
-
-public class PeriodsHolderImpl implements PeriodsHolder {
-
- @CheckForNull
- private Period period = null;
- private boolean initialized = false;
-
- /**
- * Initializes the periods in the holder.
- *
- * @throws IllegalStateException if the holder has already been initialized
- */
- public void setPeriod(@Nullable Period period) {
- checkState(!initialized, "Period have already been initialized");
- this.period = period;
- this.initialized = true;
- }
-
- @Override
- public boolean hasPeriod() {
- checkHolderIsInitialized();
- return period != null;
- }
-
- @Override
- public Period getPeriod() {
- checkHolderIsInitialized();
- return period;
- }
-
- private void checkHolderIsInitialized() {
- checkState(initialized, "Period have not been initialized yet");
- }
-
-}
import org.sonar.server.computation.task.projectanalysis.measure.Measure;
import org.sonar.server.computation.task.projectanalysis.metric.Metric;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolder;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolder;
import static java.util.Objects.requireNonNull;
import static org.sonar.server.computation.task.projectanalysis.measure.Measure.Level.ERROR;
private final I18n i18n;
private final Durations durations;
private final Periods periods;
- private final PeriodsHolder periodsHolder;
+ private final PeriodHolder periodHolder;
- public EvaluationResultTextConverterImpl(I18n i18n, Durations durations, Periods periods, PeriodsHolder periodsHolder) {
+ public EvaluationResultTextConverterImpl(I18n i18n, Durations durations, Periods periods, PeriodHolder periodHolder) {
this.i18n = i18n;
this.durations = durations;
this.periods = periods;
- this.periodsHolder = periodsHolder;
+ this.periodHolder = periodHolder;
}
@Override
.append(alertValue(condition, level));
if (hasPeriod) {
- Period period = periodsHolder.getPeriod();
+ Period period = periodHolder.getPeriod();
stringBuilder.append(" ").append(periods.label(period.getMode(), period.getModeParameter(), DateUtils.longToDate(period.getSnapshotDate())));
}
import org.sonar.server.computation.task.projectanalysis.metric.Metric;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepository;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolder;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolder;
import org.sonar.server.computation.task.projectanalysis.scm.Changeset;
import org.sonar.server.computation.task.projectanalysis.scm.ScmInfo;
import org.sonar.server.computation.task.projectanalysis.scm.ScmInfoRepository;
private final ScmInfoRepository scmInfoRepository;
private final MeasureRepository measureRepository;
- private final PeriodsHolder periodsHolder;
+ private final PeriodHolder periodHolder;
private final RatingSettings ratingSettings;
private final RatingGrid ratingGrid;
private final Metric newMaintainabilityRatingMetric;
public NewMaintainabilityMeasuresVisitor(MetricRepository metricRepository, MeasureRepository measureRepository, ScmInfoRepository scmInfoRepository,
- PeriodsHolder periodsHolder, RatingSettings ratingSettings) {
+ PeriodHolder periodHolder, RatingSettings ratingSettings) {
super(CrawlerDepthLimit.FILE, POST_ORDER, CounterFactory.INSTANCE);
this.measureRepository = measureRepository;
this.scmInfoRepository = scmInfoRepository;
- this.periodsHolder = periodsHolder;
+ this.periodHolder = periodHolder;
this.ratingSettings = ratingSettings;
this.ratingGrid = ratingSettings.getRatingGrid();
}
private void computeAndSaveNewDebtRatioMeasure(Component component, Path<Counter> path) {
- if (!periodsHolder.hasPeriod()) {
+ if (!periodHolder.hasPeriod()) {
return;
}
double density = computeDensity(path.current());
private void initNewDebtRatioCounter(Component file, Path<Counter> path) {
// first analysis, no period, no differential value to compute, save processing time and return now
- if (!periodsHolder.hasPeriod()) {
+ if (!periodHolder.hasPeriod()) {
return;
}
long lineDevCost = ratingSettings.getDevCost(file.getFileAttributes().getLanguageKey());
for (Integer nclocLineIndex : nclocLineIndexes(nclocDataMeasure)) {
Changeset changeset = scmInfo.getChangesetForLine(nclocLineIndex);
- Period period = periodsHolder.getPeriod();
+ Period period = periodHolder.getPeriod();
if (isLineInPeriod(changeset.getDate(), period)) {
devCostCounter.incrementDevCost(lineDevCost);
hasDevCost = true;
import org.sonar.server.computation.task.projectanalysis.metric.Metric;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepository;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolder;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolder;
import static org.sonar.api.measures.CoreMetrics.NEW_RELIABILITY_RATING_KEY;
import static org.sonar.api.measures.CoreMetrics.NEW_SECURITY_RATING_KEY;
private final MeasureRepository measureRepository;
private final ComponentIssuesRepository componentIssuesRepository;
- private final PeriodsHolder periodsHolder;
+ private final PeriodHolder periodHolder;
private final Map<String, Metric> metricsByKey;
public NewReliabilityAndSecurityRatingMeasuresVisitor(MetricRepository metricRepository, MeasureRepository measureRepository, ComponentIssuesRepository componentIssuesRepository,
- PeriodsHolder periodsHolder) {
+ PeriodHolder periodHolder) {
super(LEAVES, POST_ORDER, CounterFactory.INSTANCE);
this.measureRepository = measureRepository;
this.componentIssuesRepository = componentIssuesRepository;
- this.periodsHolder = periodsHolder;
+ this.periodHolder = periodHolder;
// Output metrics
this.metricsByKey = ImmutableMap.of(
}
private void computeAndSaveMeasures(Component component, Path<Counter> path) {
- if (!periodsHolder.hasPeriod()) {
+ if (!periodHolder.hasPeriod()) {
return;
}
initRatingsToA(path);
.stream()
.filter(issue -> issue.resolution() == null)
.filter(issue -> issue.type().equals(BUG) || issue.type().equals(VULNERABILITY))
- .forEach(issue -> path.current().processIssue(issue, periodsHolder.getPeriod()));
+ .forEach(issue -> path.current().processIssue(issue, periodHolder.getPeriod()));
}
private static void addToParent(Path<Counter> path) {
import org.sonar.server.computation.task.projectanalysis.metric.Metric;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepository;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolder;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolder;
import org.sonar.server.computation.task.step.ComputationStep;
import static com.google.common.base.Preconditions.checkArgument;
private final DbClient dbClient;
private final TreeRootHolder treeRootHolder;
- private final PeriodsHolder periodsHolder;
+ private final PeriodHolder periodHolder;
private final MetricRepository metricRepository;
private final MeasureRepository measureRepository;
- public ComputeMeasureVariationsStep(DbClient dbClient, TreeRootHolder treeRootHolder, PeriodsHolder periodsHolder, MetricRepository metricRepository,
+ public ComputeMeasureVariationsStep(DbClient dbClient, TreeRootHolder treeRootHolder, PeriodHolder periodHolder, MetricRepository metricRepository,
MeasureRepository measureRepository) {
this.dbClient = dbClient;
this.treeRootHolder = treeRootHolder;
- this.periodsHolder = periodsHolder;
+ this.periodHolder = periodHolder;
this.metricRepository = metricRepository;
this.measureRepository = measureRepository;
}
private MeasuresWithVariationRepository computeMeasuresWithVariations(Component component) {
MeasuresWithVariationRepository measuresWithVariationRepository = new MeasuresWithVariationRepository();
- if (periodsHolder.hasPeriod()) {
- Period period = periodsHolder.getPeriod();
+ if (periodHolder.hasPeriod()) {
+ Period period = periodHolder.getPeriod();
List<PastMeasureDto> pastMeasures = dbClient.measureDao()
.selectPastMeasures(session, component.getUuid(), period.getAnalysisUuid(), metricIds);
setVariationMeasures(component, pastMeasures, measuresWithVariationRepository);
import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolder;
import org.sonar.server.computation.task.projectanalysis.component.TypeAwareVisitorAdapter;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderImpl;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolder;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolderImpl;
import org.sonar.server.computation.task.step.ComputationStep;
import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.PROJECT;
import static org.sonar.server.computation.task.projectanalysis.component.CrawlerDepthLimit.reportMaxDepth;
/**
- * Populates the {@link org.sonar.server.computation.task.projectanalysis.period.PeriodsHolder}
+ * Populates the {@link PeriodHolder}
* <p/>
* Here is how these periods are computed :
* - Read the 5 period properties ${@link org.sonar.core.config.CorePropertyDefinitions#TIMEMACHINE_PERIOD_PREFIX}
private final SettingsRepository settingsRepository;
private final TreeRootHolder treeRootHolder;
private final AnalysisMetadataHolder analysisMetadataHolder;
- private final PeriodsHolderImpl periodsHolder;
+ private final PeriodHolderImpl periodsHolder;
public LoadPeriodsStep(DbClient dbClient, SettingsRepository settingsRepository, TreeRootHolder treeRootHolder, AnalysisMetadataHolder analysisMetadataHolder,
- PeriodsHolderImpl periodsHolder) {
+ PeriodHolderImpl periodsHolder) {
this.dbClient = dbClient;
this.settingsRepository = settingsRepository;
this.treeRootHolder = treeRootHolder;
import org.sonar.server.computation.task.projectanalysis.metric.Metric;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepository;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolder;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolder;
import org.sonar.server.computation.task.projectanalysis.scm.ScmInfo;
import org.sonar.server.computation.task.projectanalysis.scm.ScmInfoRepository;
import org.sonar.server.computation.task.step.ComputationStep;
new NewLineCoverageFormula());
private final TreeRootHolder treeRootHolder;
- private final PeriodsHolder periodsHolder;
+ private final PeriodHolder periodHolder;
private final MetricRepository metricRepository;
private final MeasureRepository measureRepository;
@CheckForNull
/**
* Constructor used when processing a Report (ie. a {@link BatchReportReader} instance is available in the container)
*/
- public NewCoverageMeasuresStep(TreeRootHolder treeRootHolder, PeriodsHolder periodsHolder,
+ public NewCoverageMeasuresStep(TreeRootHolder treeRootHolder, PeriodHolder periodHolder,
MeasureRepository measureRepository, final MetricRepository metricRepository, ScmInfoRepository scmInfoRepository) {
this.treeRootHolder = treeRootHolder;
- this.periodsHolder = periodsHolder;
+ this.periodHolder = periodHolder;
this.metricRepository = metricRepository;
this.measureRepository = measureRepository;
this.scmInfoRepository = scmInfoRepository;
/**
* Constructor used when processing Views (ie. no {@link BatchReportReader} instance is available in the container)
*/
- public NewCoverageMeasuresStep(TreeRootHolder treeRootHolder, PeriodsHolder periodsHolder,
+ public NewCoverageMeasuresStep(TreeRootHolder treeRootHolder, PeriodHolder periodHolder,
MeasureRepository measureRepository, final MetricRepository metricRepository) {
this.treeRootHolder = treeRootHolder;
- this.periodsHolder = periodsHolder;
+ this.periodHolder = periodHolder;
this.metricRepository = metricRepository;
this.measureRepository = measureRepository;
this.scmInfoRepository = null;
public void execute() {
new PathAwareCrawler<>(
FormulaExecutorComponentVisitor.newBuilder(metricRepository, measureRepository)
- .withVariationSupport(periodsHolder)
+ .withVariationSupport(periodHolder)
.buildFor(
Iterables.concat(NewLinesAndConditionsCoverageFormula.from(scmInfoRepository), FORMULAS)))
.visit(treeRootHolder.getRoot());
import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepository;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepository;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolder;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolder;
import org.sonar.server.computation.task.projectanalysis.scm.Changeset;
import org.sonar.server.computation.task.projectanalysis.scm.ScmInfo;
import org.sonar.server.computation.task.projectanalysis.scm.ScmInfoRepository;
public class NewSizeMeasuresStep implements ComputationStep {
private final TreeRootHolder treeRootHolder;
- private final PeriodsHolder periodsHolder;
+ private final PeriodHolder periodHolder;
private final MetricRepository metricRepository;
private final MeasureRepository measureRepository;
private final NewDuplicationFormula duplicationFormula;
- public NewSizeMeasuresStep(TreeRootHolder treeRootHolder, PeriodsHolder periodsHolder, MetricRepository metricRepository, MeasureRepository measureRepository,
- ScmInfoRepository scmInfoRepository, DuplicationRepository duplicationRepository) {
+ public NewSizeMeasuresStep(TreeRootHolder treeRootHolder, PeriodHolder periodHolder, MetricRepository metricRepository, MeasureRepository measureRepository,
+ ScmInfoRepository scmInfoRepository, DuplicationRepository duplicationRepository) {
this.treeRootHolder = treeRootHolder;
- this.periodsHolder = periodsHolder;
+ this.periodHolder = periodHolder;
this.metricRepository = metricRepository;
this.measureRepository = measureRepository;
this.duplicationFormula = new NewDuplicationFormula(scmInfoRepository, duplicationRepository);
public void execute() {
new PathAwareCrawler<>(
FormulaExecutorComponentVisitor.newBuilder(metricRepository, measureRepository)
- .withVariationSupport(periodsHolder)
+ .withVariationSupport(periodHolder)
.buildFor(ImmutableList.of(duplicationFormula)))
.visit(treeRootHolder.getRoot());
}
import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolder;
import org.sonar.server.computation.task.projectanalysis.component.TypeAwareVisitorAdapter;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolder;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolder;
import org.sonar.server.computation.task.step.ComputationStep;
/**
private final DbClient dbClient;
private final TreeRootHolder treeRootHolder;
private final AnalysisMetadataHolder analysisMetadataHolder;
- private final PeriodsHolder periodsHolder;
+ private final PeriodHolder periodHolder;
public PersistAnalysisStep(System2 system2, DbClient dbClient, TreeRootHolder treeRootHolder,
- AnalysisMetadataHolder analysisMetadataHolder, PeriodsHolder periodsHolder) {
+ AnalysisMetadataHolder analysisMetadataHolder, PeriodHolder periodHolder) {
this.system2 = system2;
this.dbClient = dbClient;
this.treeRootHolder = treeRootHolder;
this.analysisMetadataHolder = analysisMetadataHolder;
- this.periodsHolder = periodsHolder;
+ this.periodHolder = periodHolder;
}
@Override
}
private void updateSnapshotPeriods(SnapshotDto snapshotDto) {
- if (!periodsHolder.hasPeriod()) {
+ if (!periodHolder.hasPeriod()) {
return;
}
- Period period = periodsHolder.getPeriod();
+ Period period = periodHolder.getPeriod();
snapshotDto.setPeriodMode(period.getMode());
snapshotDto.setPeriodParam(period.getModeParameter());
snapshotDto.setPeriodDate(period.getSnapshotDate());
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.measures.CoreMetrics;
-import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
import org.sonar.server.computation.task.projectanalysis.component.Component;
import org.sonar.server.computation.task.projectanalysis.component.PathAwareCrawler;
import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
+import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderRule;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolderRule;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.guava.api.Assertions.assertThat;
@Rule
public MeasureRepositoryRule measureRepository = MeasureRepositoryRule.create(treeRootHolder, metricRepository);
@Rule
- public PeriodsHolderRule periodsHolder = new PeriodsHolderRule();
+ public PeriodHolderRule periodsHolder = new PeriodHolderRule();
FormulaExecutorComponentVisitor underTest;
import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
import org.sonar.server.computation.task.projectanalysis.measure.Measure;
import org.sonar.server.computation.task.projectanalysis.metric.Metric;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolder;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolder;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.anyString;
CounterInitializationContext counterInitializationContext = mock(CounterInitializationContext.class);
CreateMeasureContext createMeasureContext = new DumbCreateMeasureContext(
- ReportComponent.builder(Component.Type.PROJECT, 1).build(), mock(Metric.class), mock(PeriodsHolder.class));
+ ReportComponent.builder(Component.Type.PROJECT, 1).build(), mock(Metric.class), mock(PeriodHolder.class));
@Rule
public ExpectedException thrown = ExpectedException.none();
import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
import org.sonar.server.computation.task.projectanalysis.measure.Measure;
import org.sonar.server.computation.task.projectanalysis.metric.Metric;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolder;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolder;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
CounterInitializationContext counterInitializationContext = mock(CounterInitializationContext.class);
CreateMeasureContext projectCreateMeasureContext = new DumbCreateMeasureContext(
- ReportComponent.builder(Component.Type.PROJECT, 1).build(), mock(Metric.class), mock(PeriodsHolder.class));
+ ReportComponent.builder(Component.Type.PROJECT, 1).build(), mock(Metric.class), mock(PeriodHolder.class));
CreateMeasureContext fileCreateMeasureContext = new DumbCreateMeasureContext(
- ReportComponent.builder(Component.Type.FILE, 1).build(), mock(Metric.class), mock(PeriodsHolder.class));
+ ReportComponent.builder(Component.Type.FILE, 1).build(), mock(Metric.class), mock(PeriodHolder.class));
@Test
public void check_new_counter_class() {
import org.sonar.server.computation.task.projectanalysis.component.Component;
import org.sonar.server.computation.task.projectanalysis.metric.Metric;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolder;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolder;
public class DumbCreateMeasureContext implements CreateMeasureContext {
private final Component component;
private final Metric metric;
- private final PeriodsHolder periodsHolder;
+ private final PeriodHolder periodHolder;
- public DumbCreateMeasureContext(Component component, Metric metric, PeriodsHolder periodsHolder) {
+ public DumbCreateMeasureContext(Component component, Metric metric, PeriodHolder periodHolder) {
this.component = component;
this.metric = metric;
- this.periodsHolder = periodsHolder;
+ this.periodHolder = periodHolder;
}
@Override
@Override
public Period getPeriod() {
- return periodsHolder.getPeriod();
+ return periodHolder.getPeriod();
}
@Override
public boolean hasPeriod() {
- return periodsHolder.hasPeriod();
+ return periodHolder.hasPeriod();
}
}
import org.sonar.server.computation.task.projectanalysis.formula.counter.IntSumCounter;
import org.sonar.server.computation.task.projectanalysis.measure.Measure;
import org.sonar.server.computation.task.projectanalysis.metric.Metric;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolder;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolder;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
public ExpectedException thrown = ExpectedException.none();
CreateMeasureContext projectCreateMeasureContext = new DumbCreateMeasureContext(
- ReportComponent.builder(Component.Type.PROJECT, 1).build(), mock(Metric.class), mock(PeriodsHolder.class));
+ ReportComponent.builder(Component.Type.PROJECT, 1).build(), mock(Metric.class), mock(PeriodHolder.class));
CreateMeasureContext fileCreateMeasureContext = new DumbCreateMeasureContext(
- ReportComponent.builder(Component.Type.FILE, 2).build(), mock(Metric.class), mock(PeriodsHolder.class));
+ ReportComponent.builder(Component.Type.FILE, 2).build(), mock(Metric.class), mock(PeriodHolder.class));
@Test
public void check_create_new_counter_class() {
import org.sonar.server.computation.task.projectanalysis.formula.counter.LongSumCounter;
import org.sonar.server.computation.task.projectanalysis.measure.Measure;
import org.sonar.server.computation.task.projectanalysis.metric.Metric;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolder;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolder;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
public ExpectedException thrown = ExpectedException.none();
CreateMeasureContext projectCreateMeasureContext = new DumbCreateMeasureContext(
- ReportComponent.builder(Component.Type.PROJECT, 1).build(), mock(Metric.class), mock(PeriodsHolder.class));
+ ReportComponent.builder(Component.Type.PROJECT, 1).build(), mock(Metric.class), mock(PeriodHolder.class));
CreateMeasureContext fileCreateMeasureContext = new DumbCreateMeasureContext(
- ReportComponent.builder(Component.Type.FILE, 2).build(), mock(Metric.class), mock(PeriodsHolder.class));
+ ReportComponent.builder(Component.Type.FILE, 2).build(), mock(Metric.class), mock(PeriodHolder.class));
@Test
public void check_create_new_counter_class() {
import org.sonar.server.computation.task.projectanalysis.metric.Metric;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderRule;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolderRule;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.api.measures.CoreMetrics.LINES_KEY;
@Rule
public MeasureRepositoryRule measureRepository = MeasureRepositoryRule.create(treeRootHolder, metricRepository);
@Rule
- public PeriodsHolderRule periodsHolder = new PeriodsHolderRule().setPeriod(new Period("some mode", null, 95l, "756l"));
+ public PeriodHolderRule periodsHolder = new PeriodHolderRule().setPeriod(new Period("some mode", null, 95l, "756l"));
@Test
public void verify_aggregation_on_value() throws Exception {
import org.sonar.server.computation.task.projectanalysis.metric.Metric;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderRule;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolderRule;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.guava.api.Assertions.assertThat;
@Rule
public MeasureRepositoryRule measureRepository = MeasureRepositoryRule.create(treeRootHolder, metricRepository);
@Rule
- public PeriodsHolderRule periodsHolder = new PeriodsHolderRule().setPeriod(new Period("some mode", null, 95l, "u1"));
+ public PeriodHolderRule periodsHolder = new PeriodHolderRule().setPeriod(new Period("some mode", null, 95l, "u1"));
@Test
public void verify_aggregation_on_value() throws Exception {
import org.sonar.server.computation.task.projectanalysis.metric.MetricImpl;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderRule;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolderRule;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.api.issue.Issue.RESOLUTION_FALSE_POSITIVE;
public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule();
@Rule
- public PeriodsHolderRule periodsHolder = new PeriodsHolderRule();
+ public PeriodHolderRule periodsHolder = new PeriodHolderRule();
@Rule
public MetricRepositoryRule metricRepository = new MetricRepositoryRule()
import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderRule;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolderRule;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.guava.api.Assertions.assertThat;
private NewEffortCalculator calculator = mock(NewEffortCalculator.class);
@org.junit.Rule
- public PeriodsHolderRule periodsHolder = new PeriodsHolderRule();
+ public PeriodHolderRule periodsHolder = new PeriodHolderRule();
@org.junit.Rule
public MetricRepositoryRule metricRepository = new MetricRepositoryRule()
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.server.computation.task.projectanalysis.period;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class PeriodHolderImplTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private PeriodHolderImpl underTest = new PeriodHolderImpl();
+
+ @Test
+ public void get_period() {
+ Period period = createPeriod();
+ underTest.setPeriod(period);
+
+ assertThat(underTest.getPeriod()).isEqualTo(period);
+ }
+
+ @Test
+ public void get_period_throws_illegal_state_exception_if_not_initialized() {
+ thrown.expect(IllegalStateException.class);
+ thrown.expectMessage("Period have not been initialized yet");
+
+ new PeriodHolderImpl().getPeriod();
+ }
+
+ @Test
+ public void setPeriod_throws_ISE_if_already_initialized() {
+ thrown.expect(IllegalStateException.class);
+ thrown.expectMessage("Period have already been initialized");
+
+ underTest.setPeriod(createPeriod());
+ underTest.setPeriod(createPeriod());
+ }
+
+ @Test
+ public void hasPeriod_returns_false_if_holder_is_empty() {
+ underTest.setPeriod(null);
+ assertThat(underTest.hasPeriod()).isFalse();
+ }
+
+ @Test
+ public void hasPeriod_returns_true_only_if_period_exists_in_holder() {
+ underTest.setPeriod(createPeriod());
+ assertThat(underTest.hasPeriod()).isTrue();
+ }
+
+ @Test
+ public void hasPeriod_throws_ISE_if_not_initialized() {
+ thrown.expect(IllegalStateException.class);
+ thrown.expectMessage("Period have not been initialized yet");
+
+ underTest.hasPeriod();
+ }
+
+ private static Period createPeriod() {
+ return new Period(1 + "mode", null, 1000L, "U1");
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.server.computation.task.projectanalysis.period;
+
+import javax.annotation.Nullable;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+public class PeriodHolderRule implements TestRule, PeriodHolder {
+ private PeriodHolderImpl delegate = new PeriodHolderImpl();
+
+ @Override
+ public Statement apply(final Statement statement, Description description) {
+ return new Statement() {
+ @Override
+ public void evaluate() throws Throwable {
+ try {
+ statement.evaluate();
+ } finally {
+ clear();
+ }
+ }
+ };
+ }
+
+ private void clear() {
+ this.delegate = new PeriodHolderImpl();
+ }
+
+ public PeriodHolderRule setPeriod(@Nullable Period period) {
+ delegate = new PeriodHolderImpl();
+ delegate.setPeriod(period);
+ return this;
+ }
+
+ @Override
+ public boolean hasPeriod() {
+ return delegate.hasPeriod();
+ }
+
+ @Override
+ public Period getPeriod() {
+ return delegate.getPeriod();
+ }
+}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.server.computation.task.projectanalysis.period;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class PeriodsHolderImplTest {
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- private PeriodsHolderImpl underTest = new PeriodsHolderImpl();
-
- @Test
- public void get_period() {
- Period period = createPeriod();
- underTest.setPeriod(period);
-
- assertThat(underTest.getPeriod()).isEqualTo(period);
- }
-
- @Test
- public void get_period_throws_illegal_state_exception_if_not_initialized() {
- thrown.expect(IllegalStateException.class);
- thrown.expectMessage("Period have not been initialized yet");
-
- new PeriodsHolderImpl().getPeriod();
- }
-
- @Test
- public void setPeriod_throws_ISE_if_already_initialized() {
- thrown.expect(IllegalStateException.class);
- thrown.expectMessage("Period have already been initialized");
-
- underTest.setPeriod(createPeriod());
- underTest.setPeriod(createPeriod());
- }
-
- @Test
- public void hasPeriod_returns_false_if_holder_is_empty() {
- underTest.setPeriod(null);
- assertThat(underTest.hasPeriod()).isFalse();
- }
-
- @Test
- public void hasPeriod_returns_true_only_if_period_exists_in_holder() {
- underTest.setPeriod(createPeriod());
- assertThat(underTest.hasPeriod()).isTrue();
- }
-
- @Test
- public void hasPeriod_throws_ISE_if_not_initialized() {
- thrown.expect(IllegalStateException.class);
- thrown.expectMessage("Period have not been initialized yet");
-
- underTest.hasPeriod();
- }
-
- private static Period createPeriod() {
- return new Period(1 + "mode", null, 1000L, "U1");
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.server.computation.task.projectanalysis.period;
-
-import javax.annotation.Nullable;
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-public class PeriodsHolderRule implements TestRule, PeriodsHolder {
- private PeriodsHolderImpl delegate = new PeriodsHolderImpl();
-
- @Override
- public Statement apply(final Statement statement, Description description) {
- return new Statement() {
- @Override
- public void evaluate() throws Throwable {
- try {
- statement.evaluate();
- } finally {
- clear();
- }
- }
- };
- }
-
- private void clear() {
- this.delegate = new PeriodsHolderImpl();
- }
-
- public PeriodsHolderRule setPeriod(@Nullable Period period) {
- delegate = new PeriodsHolderImpl();
- delegate.setPeriod(period);
- return this;
- }
-
- @Override
- public boolean hasPeriod() {
- return delegate.hasPeriod();
- }
-
- @Override
- public Period getPeriod() {
- return delegate.getPeriod();
- }
-}
import org.sonar.server.computation.task.projectanalysis.metric.Metric;
import org.sonar.server.computation.task.projectanalysis.metric.MetricImpl;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderRule;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolderRule;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
private static final String SOME_ANALYSIS_UUID = "u1";
@Rule
- public PeriodsHolderRule periodsHolder = new PeriodsHolderRule();
+ public PeriodHolderRule periodsHolder = new PeriodHolderRule();
private I18n i18n = mock(I18n.class);
private Durations durations = mock(Durations.class);
import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderRule;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolderRule;
import org.sonar.server.computation.task.projectanalysis.qualitymodel.RatingGrid.Rating;
import org.sonar.server.computation.task.projectanalysis.scm.Changeset;
import org.sonar.server.computation.task.projectanalysis.scm.ScmInfoRepositoryRule;
@Rule
public MeasureRepositoryRule measureRepository = MeasureRepositoryRule.create(treeRootHolder, metricRepository);
@Rule
- public PeriodsHolderRule periodsHolder = new PeriodsHolderRule();
+ public PeriodHolderRule periodsHolder = new PeriodHolderRule();
private RatingSettings ratingSettings = mock(RatingSettings.class);
import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderRule;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolderRule;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.api.issue.Issue.RESOLUTION_FIXED;
public MeasureRepositoryRule measureRepository = MeasureRepositoryRule.create(treeRootHolder, metricRepository);
@Rule
- public PeriodsHolderRule periodsHolder = new PeriodsHolderRule().setPeriod(new Period("mode", null, LEAK_PERIOD_SNAPSHOT_IN_MILLISEC, "UUID"));
+ public PeriodHolderRule periodsHolder = new PeriodHolderRule().setPeriod(new Period("mode", null, LEAK_PERIOD_SNAPSHOT_IN_MILLISEC, "UUID"));
@Rule
public ComponentIssuesRepositoryRule componentIssuesRepositoryRule = new ComponentIssuesRepositoryRule(treeRootHolder);
import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
import org.sonar.server.computation.task.projectanalysis.component.ViewsComponent;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderImpl;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolderImpl;
import org.sonar.server.computation.task.step.ComputationStep;
import static org.assertj.core.api.Assertions.assertThat;
@Rule
public LogTester logTester = new LogTester();
- private PeriodsHolderImpl periodsHolder = new PeriodsHolderImpl();
+ private PeriodHolderImpl periodsHolder = new PeriodHolderImpl();
private DbClient dbClient = dbTester.getDbClient();
private Settings settings = new MapSettings();
private SettingsRepository settingsRepository = mock(SettingsRepository.class);
import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderRule;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolderRule;
import org.sonar.server.computation.task.projectanalysis.scm.Changeset;
import org.sonar.server.computation.task.projectanalysis.scm.ScmInfoRepositoryRule;
.build());
@Rule
- public PeriodsHolderRule periodsHolder = new PeriodsHolderRule().setPeriod(
+ public PeriodHolderRule periodsHolder = new PeriodHolderRule().setPeriod(
new Period("mode_p_1", null, parseDate("2009-12-25").getTime(), "u1"));
@Rule
import org.sonar.server.computation.task.projectanalysis.metric.MetricImpl;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderRule;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolderRule;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.db.component.SnapshotTesting.newAnalysis;
@Rule
public BatchReportReaderRule reportReader = new BatchReportReaderRule();
@Rule
- public PeriodsHolderRule periodsHolder = new PeriodsHolderRule();
+ public PeriodHolderRule periodsHolder = new PeriodHolderRule();
@Rule
public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule();
@Rule
import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderRule;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolderRule;
import org.sonar.server.computation.task.projectanalysis.scm.Changeset;
import org.sonar.server.computation.task.projectanalysis.scm.ScmInfoRepositoryRule;
@Rule
public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule();
@Rule
- public PeriodsHolderRule periodsHolder = new PeriodsHolderRule();
+ public PeriodHolderRule periodsHolder = new PeriodHolderRule();
@Rule
public MetricRepositoryRule metricRepository = new MetricRepositoryRule()
.add(CoreMetrics.COVERAGE_LINE_HITS_DATA)
import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderRule;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolderRule;
import org.sonar.server.computation.task.step.ComputationStep;
import static org.assertj.core.api.Assertions.assertThat;
@Rule
public AnalysisMetadataHolderRule analysisMetadataHolder = new AnalysisMetadataHolderRule();
@Rule
- public PeriodsHolderRule periodsHolder = new PeriodsHolderRule();
+ public PeriodHolderRule periodsHolder = new PeriodHolderRule();
private System2 system2 = mock(System2.class);
import org.sonar.server.computation.task.projectanalysis.metric.MetricImpl;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderRule;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolderRule;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.db.component.SnapshotTesting.newAnalysis;
public BatchReportReaderRule reportReader = new BatchReportReaderRule();
@Rule
- public PeriodsHolderRule periodsHolder = new PeriodsHolderRule();
+ public PeriodHolderRule periodsHolder = new PeriodHolderRule();
@Rule
public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule();
import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderRule;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolderRule;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.guava.api.Assertions.assertThat;
@Rule
public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule();
@Rule
- public PeriodsHolderRule periodsHolder = new PeriodsHolderRule();
+ public PeriodHolderRule periodsHolder = new PeriodHolderRule();
@Rule
public MetricRepositoryRule metricRepository = new MetricRepositoryRule()
.add(CoreMetrics.COVERAGE_LINE_HITS_DATA)
import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
import org.sonar.server.computation.task.projectanalysis.component.ViewsComponent;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderRule;
+import org.sonar.server.computation.task.projectanalysis.period.PeriodHolderRule;
import org.sonar.server.computation.task.step.ComputationStep;
import static org.assertj.core.api.Assertions.assertThat;
@Rule
public AnalysisMetadataHolderRule analysisMetadataHolder = new AnalysisMetadataHolderRule();
@Rule
- public PeriodsHolderRule periodsHolder = new PeriodsHolderRule();
+ public PeriodHolderRule periodsHolder = new PeriodHolderRule();
private System2 system2 = mock(System2.class);