3 * Copyright (C) 2009-2016 SonarSource SA
4 * mailto:contact AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.server.computation.task.projectanalysis.qualitymodel;
22 import com.google.common.collect.ImmutableMap;
23 import com.google.common.collect.ImmutableSet;
24 import com.google.common.collect.Ordering;
25 import java.util.Arrays;
27 import org.assertj.core.data.Offset;
28 import org.junit.Before;
29 import org.junit.Rule;
30 import org.junit.Test;
31 import org.sonar.api.utils.KeyValueFormat;
32 import org.sonar.server.computation.task.projectanalysis.component.Component;
33 import org.sonar.server.computation.task.projectanalysis.component.FileAttributes;
34 import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
35 import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
36 import org.sonar.server.computation.task.projectanalysis.component.VisitorsCrawler;
37 import org.sonar.server.computation.task.projectanalysis.measure.Measure;
38 import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule;
39 import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
40 import org.sonar.server.computation.task.projectanalysis.period.Period;
41 import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderRule;
42 import org.sonar.server.computation.task.projectanalysis.qualitymodel.RatingGrid.Rating;
43 import org.sonar.server.computation.task.projectanalysis.scm.Changeset;
44 import org.sonar.server.computation.task.projectanalysis.scm.ScmInfoRepositoryRule;
46 import static com.google.common.base.Preconditions.checkArgument;
47 import static org.mockito.Mockito.mock;
48 import static org.mockito.Mockito.when;
49 import static org.sonar.api.measures.CoreMetrics.NCLOC_DATA;
50 import static org.sonar.api.measures.CoreMetrics.NCLOC_DATA_KEY;
51 import static org.sonar.api.measures.CoreMetrics.NEW_MAINTAINABILITY_RATING;
52 import static org.sonar.api.measures.CoreMetrics.NEW_MAINTAINABILITY_RATING_KEY;
53 import static org.sonar.api.measures.CoreMetrics.NEW_SQALE_DEBT_RATIO;
54 import static org.sonar.api.measures.CoreMetrics.NEW_SQALE_DEBT_RATIO_KEY;
55 import static org.sonar.api.measures.CoreMetrics.NEW_TECHNICAL_DEBT;
56 import static org.sonar.api.measures.CoreMetrics.NEW_TECHNICAL_DEBT_KEY;
57 import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.DIRECTORY;
58 import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.FILE;
59 import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.MODULE;
60 import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.PROJECT;
61 import static org.sonar.server.computation.task.projectanalysis.measure.Measure.newMeasureBuilder;
62 import static org.sonar.server.computation.task.projectanalysis.measure.MeasureAssert.assertThat;
63 import static org.sonar.server.computation.task.projectanalysis.qualitymodel.RatingGrid.Rating.A;
64 import static org.sonar.server.computation.task.projectanalysis.qualitymodel.RatingGrid.Rating.D;
66 public class NewMaintainabilityMeasuresVisitorTest {
68 private static final double[] RATING_GRID = new double[] {0.1, 0.2, 0.5, 1};
70 private static final String LANGUAGE_1_KEY = "language 1 key";
71 private static final long LANGUAGE_1_DEV_COST = 30l;
72 private static final long PERIOD_SNAPSHOT_DATE = 12323l;
73 private static final String SOME_ANALYSIS_UUID = "9993l";
74 private static final String SOME_PERIOD_MODE = "some mode";
75 private static final int ROOT_REF = 1;
76 private static final int LANGUAGE_1_FILE_REF = 11111;
77 private static final Offset<Double> VARIATION_COMPARISON_OFFSET = Offset.offset(0.01);
80 public ScmInfoRepositoryRule scmInfoRepository = new ScmInfoRepositoryRule();
82 public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule();
84 public MetricRepositoryRule metricRepository = new MetricRepositoryRule()
85 .add(NEW_TECHNICAL_DEBT)
87 .add(NEW_SQALE_DEBT_RATIO)
88 .add(NEW_MAINTAINABILITY_RATING);
90 public MeasureRepositoryRule measureRepository = MeasureRepositoryRule.create(treeRootHolder, metricRepository);
92 public PeriodsHolderRule periodsHolder = new PeriodsHolderRule();
94 private RatingSettings ratingSettings = mock(RatingSettings.class);
96 private VisitorsCrawler underTest;
99 public void setUp() throws Exception {
100 when(ratingSettings.getRatingGrid()).thenReturn(new RatingGrid(RATING_GRID));
101 underTest = new VisitorsCrawler(Arrays.asList(new NewMaintainabilityMeasuresVisitor(metricRepository, measureRepository, scmInfoRepository,
102 periodsHolder, ratingSettings)));
106 public void project_has_new_measures_for_each_defined_period() {
108 treeRootHolder.setRoot(builder(PROJECT, ROOT_REF).build());
110 underTest.visit(treeRootHolder.getRoot());
112 assertNewDebtRatioValues(ROOT_REF, 0);
113 assertNewMaintainability(ROOT_REF, A);
117 public void project_has_no_measure_if_there_is_no_period() {
118 periodsHolder.setPeriod(null);
119 treeRootHolder.setRoot(builder(PROJECT, ROOT_REF).build());
121 underTest.visit(treeRootHolder.getRoot());
123 assertNoNewDebtRatioMeasure(ROOT_REF);
124 assertNoNewMaintainability(ROOT_REF);
128 public void file_has_no_new_debt_ratio_variation_if_there_is_no_period() {
129 periodsHolder.setPeriod(null);
130 when(ratingSettings.getDevCost(LANGUAGE_1_KEY)).thenReturn(LANGUAGE_1_DEV_COST);
131 setupOneFileAloneInAProject(50, Flag.SRC_FILE, Flag.WITH_NCLOC, Flag.WITH_CHANGESET);
132 measureRepository.addRawMeasure(ROOT_REF, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(50));
134 underTest.visit(treeRootHolder.getRoot());
136 assertNoNewDebtRatioMeasure(LANGUAGE_1_FILE_REF);
137 assertNoNewDebtRatioMeasure(ROOT_REF);
141 public void file_has_0_new_debt_ratio_if_all_scm_dates_are_before_snapshot_dates() {
143 treeRootHolder.setRoot(
144 builder(PROJECT, ROOT_REF)
146 builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY, 1)).build())
148 measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(50));
149 measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NCLOC_DATA_KEY, createNclocDataMeasure(2, 3, 4));
150 scmInfoRepository.setScmInfo(LANGUAGE_1_FILE_REF, createChangesets(PERIOD_SNAPSHOT_DATE - 100, 4));
152 underTest.visit(treeRootHolder.getRoot());
154 assertNewDebtRatioValues(LANGUAGE_1_FILE_REF, 0);
155 assertNewDebtRatioValues(ROOT_REF, 0);
159 public void file_has_new_debt_ratio_if_some_scm_dates_are_after_snapshot_dates() {
161 when(ratingSettings.getDevCost(LANGUAGE_1_KEY)).thenReturn(LANGUAGE_1_DEV_COST);
162 setupOneFileAloneInAProject(50, Flag.SRC_FILE, Flag.WITH_NCLOC, Flag.WITH_CHANGESET);
163 measureRepository.addRawMeasure(ROOT_REF, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(50));
165 underTest.visit(treeRootHolder.getRoot());
167 assertNewDebtRatioValues(LANGUAGE_1_FILE_REF, 83.33);
168 assertNewDebtRatioValues(ROOT_REF, 83.33);
172 public void new_debt_ratio_changes_with_language_cost() {
174 when(ratingSettings.getDevCost(LANGUAGE_1_KEY)).thenReturn(LANGUAGE_1_DEV_COST * 10);
175 setupOneFileAloneInAProject(50, Flag.SRC_FILE, Flag.WITH_NCLOC, Flag.WITH_CHANGESET);
176 measureRepository.addRawMeasure(ROOT_REF, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(50));
178 underTest.visit(treeRootHolder.getRoot());
180 assertNewDebtRatioValues(LANGUAGE_1_FILE_REF, 8.33);
181 assertNewDebtRatioValues(ROOT_REF, 8.33);
185 public void new_debt_ratio_changes_with_new_technical_debt() {
187 when(ratingSettings.getDevCost(LANGUAGE_1_KEY)).thenReturn(LANGUAGE_1_DEV_COST);
188 setupOneFileAloneInAProject(500, Flag.SRC_FILE, Flag.WITH_NCLOC, Flag.WITH_CHANGESET);
189 measureRepository.addRawMeasure(ROOT_REF, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(500));
191 underTest.visit(treeRootHolder.getRoot());
193 assertNewDebtRatioValues(LANGUAGE_1_FILE_REF, 833.33);
194 assertNewDebtRatioValues(ROOT_REF, 833.33);
198 public void new_debt_ratio_on_non_file_level_is_based_on_new_technical_debt_of_that_level() {
200 when(ratingSettings.getDevCost(LANGUAGE_1_KEY)).thenReturn(LANGUAGE_1_DEV_COST);
201 setupOneFileAloneInAProject(500, Flag.SRC_FILE, Flag.WITH_NCLOC, Flag.WITH_CHANGESET);
202 measureRepository.addRawMeasure(ROOT_REF, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(1200));
204 underTest.visit(treeRootHolder.getRoot());
206 assertNewDebtRatioValues(LANGUAGE_1_FILE_REF, 833.33);
207 assertNewDebtRatioValues(ROOT_REF, 833.33);
211 public void new_debt_ratio_when_file_is_unit_test() {
213 when(ratingSettings.getDevCost(LANGUAGE_1_KEY)).thenReturn(LANGUAGE_1_DEV_COST);
214 setupOneFileAloneInAProject(500, Flag.UT_FILE, Flag.WITH_NCLOC, Flag.WITH_CHANGESET);
215 measureRepository.addRawMeasure(ROOT_REF, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(1200));
217 underTest.visit(treeRootHolder.getRoot());
219 assertNewDebtRatioValues(LANGUAGE_1_FILE_REF, 833.33);
220 assertNewDebtRatioValues(ROOT_REF, 833.33);
224 public void new_debt_ratio_is_0_when_file_has_no_changesets() {
226 when(ratingSettings.getDevCost(LANGUAGE_1_KEY)).thenReturn(LANGUAGE_1_DEV_COST);
227 setupOneFileAloneInAProject(50, Flag.SRC_FILE, Flag.WITH_NCLOC, Flag.NO_CHANGESET);
228 measureRepository.addRawMeasure(ROOT_REF, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(50));
230 underTest.visit(treeRootHolder.getRoot());
232 assertNewDebtRatioValues(LANGUAGE_1_FILE_REF, 0);
233 assertNewDebtRatioValues(ROOT_REF, 0);
237 public void new_debt_ratio_is_0_on_non_file_level_when_no_file_has_changesets() {
239 when(ratingSettings.getDevCost(LANGUAGE_1_KEY)).thenReturn(LANGUAGE_1_DEV_COST);
240 setupOneFileAloneInAProject(50, Flag.SRC_FILE, Flag.WITH_NCLOC, Flag.NO_CHANGESET);
241 measureRepository.addRawMeasure(ROOT_REF, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(200));
243 underTest.visit(treeRootHolder.getRoot());
245 assertNewDebtRatioValues(LANGUAGE_1_FILE_REF, 0);
246 assertNewDebtRatioValues(ROOT_REF, 0);
250 public void new_debt_ratio_is_0_when_there_is_no_ncloc_in_file() {
252 when(ratingSettings.getDevCost(LANGUAGE_1_KEY)).thenReturn(LANGUAGE_1_DEV_COST);
253 setupOneFileAloneInAProject(50, Flag.SRC_FILE, Flag.NO_NCLOC, Flag.WITH_CHANGESET);
254 measureRepository.addRawMeasure(ROOT_REF, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(50));
256 underTest.visit(treeRootHolder.getRoot());
258 assertNewDebtRatioValues(LANGUAGE_1_FILE_REF, 0);
259 assertNewDebtRatioValues(ROOT_REF, 0);
263 public void new_debt_ratio_is_0_on_non_file_level_when_one_file_has_zero_new_debt_because_of_no_changeset() {
265 when(ratingSettings.getDevCost(LANGUAGE_1_KEY)).thenReturn(LANGUAGE_1_DEV_COST);
266 setupOneFileAloneInAProject(50, Flag.SRC_FILE, Flag.NO_NCLOC, Flag.WITH_CHANGESET);
267 measureRepository.addRawMeasure(ROOT_REF, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(200));
269 underTest.visit(treeRootHolder.getRoot());
271 assertNewDebtRatioValues(LANGUAGE_1_FILE_REF, 0);
272 assertNewDebtRatioValues(ROOT_REF, 0);
276 public void new_debt_ratio_is_0_when_ncloc_measure_is_missing() {
278 when(ratingSettings.getDevCost(LANGUAGE_1_KEY)).thenReturn(LANGUAGE_1_DEV_COST);
279 setupOneFileAloneInAProject(50, Flag.SRC_FILE, Flag.MISSING_MEASURE_NCLOC, Flag.WITH_CHANGESET);
280 measureRepository.addRawMeasure(ROOT_REF, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(50));
282 underTest.visit(treeRootHolder.getRoot());
284 assertNewDebtRatioValues(LANGUAGE_1_FILE_REF, 0);
285 assertNewDebtRatioValues(ROOT_REF, 0);
289 public void leaf_components_always_have_a_measure_when_at_least_one_period_exist_and_ratio_is_computed_from_current_level_new_debt() {
291 when(ratingSettings.getDevCost(LANGUAGE_1_KEY)).thenReturn(LANGUAGE_1_DEV_COST);
292 treeRootHolder.setRoot(
293 builder(PROJECT, ROOT_REF)
297 builder(DIRECTORY, 111)
299 builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY, 1)).build())
304 Measure newDebtMeasure = createNewDebtMeasure(50);
305 measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NEW_TECHNICAL_DEBT_KEY, newDebtMeasure);
306 measureRepository.addRawMeasure(111, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(150));
307 measureRepository.addRawMeasure(11, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(200));
308 measureRepository.addRawMeasure(ROOT_REF, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(250));
309 // 4 lines file, only first one is not ncloc
310 measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NCLOC_DATA_KEY, createNclocDataMeasure(2, 3, 4));
311 // first 2 lines are before all snapshots, 2 last lines are after PERIOD 2's snapshot date
312 scmInfoRepository.setScmInfo(LANGUAGE_1_FILE_REF, createChangesets(PERIOD_SNAPSHOT_DATE - 100, 2, PERIOD_SNAPSHOT_DATE + 100, 2));
314 underTest.visit(treeRootHolder.getRoot());
316 assertNewDebtRatioValues(LANGUAGE_1_FILE_REF, 83.33);
317 assertNewDebtRatioValues(111, 83.33);
318 assertNewDebtRatioValues(11, 83.33);
319 assertNewDebtRatioValues(ROOT_REF, 83.33);
323 public void compute_new_maintainability_rating() throws Exception {
325 when(ratingSettings.getDevCost(LANGUAGE_1_KEY)).thenReturn(LANGUAGE_1_DEV_COST);
326 treeRootHolder.setRoot(
327 builder(PROJECT, ROOT_REF)
331 builder(DIRECTORY, 111)
333 builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY, 1)).build())
338 Measure newDebtMeasure = createNewDebtMeasure(50);
339 measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NEW_TECHNICAL_DEBT_KEY, newDebtMeasure);
340 measureRepository.addRawMeasure(111, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(150));
341 measureRepository.addRawMeasure(11, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(200));
342 measureRepository.addRawMeasure(ROOT_REF, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(250));
343 // 4 lines file, only first one is not ncloc
344 measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NCLOC_DATA_KEY, createNclocDataMeasure(2, 3, 4));
345 // first 2 lines are before all snapshots, 2 last lines are after PERIOD 2's snapshot date
346 scmInfoRepository.setScmInfo(LANGUAGE_1_FILE_REF, createChangesets(PERIOD_SNAPSHOT_DATE - 100, 2, PERIOD_SNAPSHOT_DATE + 100, 2));
348 underTest.visit(treeRootHolder.getRoot());
350 assertNewMaintainability(LANGUAGE_1_FILE_REF, D);
351 assertNewMaintainability(111, D);
352 assertNewMaintainability(11, D);
353 assertNewMaintainability(ROOT_REF, D);
357 public void compute_new_maintainability_rating_to_A_when_no_debt() throws Exception {
359 when(ratingSettings.getDevCost(LANGUAGE_1_KEY)).thenReturn(LANGUAGE_1_DEV_COST);
360 treeRootHolder.setRoot(
361 builder(PROJECT, ROOT_REF)
365 builder(DIRECTORY, 111)
367 builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY, 1)).build())
372 underTest.visit(treeRootHolder.getRoot());
374 assertNewMaintainability(LANGUAGE_1_FILE_REF, A);
375 assertNewMaintainability(111, A);
376 assertNewMaintainability(11, A);
377 assertNewMaintainability(ROOT_REF, A);
380 private void setupOneFileAloneInAProject(int newDebt, Flag isUnitTest, Flag withNclocLines, Flag withChangeSets) {
381 checkArgument(isUnitTest == Flag.UT_FILE || isUnitTest == Flag.SRC_FILE);
382 checkArgument(withNclocLines == Flag.WITH_NCLOC || withNclocLines == Flag.NO_NCLOC || withNclocLines == Flag.MISSING_MEASURE_NCLOC);
383 checkArgument(withChangeSets == Flag.WITH_CHANGESET || withChangeSets == Flag.NO_CHANGESET);
385 treeRootHolder.setRoot(
386 builder(PROJECT, ROOT_REF)
388 builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(isUnitTest == Flag.UT_FILE, LANGUAGE_1_KEY, 1)).build())
391 Measure newDebtMeasure = createNewDebtMeasure(newDebt);
392 measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NEW_TECHNICAL_DEBT_KEY, newDebtMeasure);
393 if (withNclocLines == Flag.WITH_NCLOC) {
394 // 4 lines file, only first one is not ncloc
395 measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NCLOC_DATA_KEY, createNclocDataMeasure(2, 3, 4));
396 } else if (withNclocLines == Flag.NO_NCLOC) {
397 // 4 lines file, none of which is ncloc
398 measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NCLOC_DATA_KEY, createNoNclocDataMeasure(4));
400 if (withChangeSets == Flag.WITH_CHANGESET) {
401 // first 2 lines are before all snapshots, 2 last lines are after PERIOD 2's snapshot date
402 scmInfoRepository.setScmInfo(LANGUAGE_1_FILE_REF, createChangesets(PERIOD_SNAPSHOT_DATE - 100, 2, PERIOD_SNAPSHOT_DATE + 100, 2));
407 UT_FILE, SRC_FILE, NO_CHANGESET, WITH_CHANGESET, WITH_NCLOC, NO_NCLOC, MISSING_MEASURE_NCLOC
410 public static ReportComponent.Builder builder(Component.Type type, int ref) {
411 return ReportComponent.builder(type, ref).setKey(String.valueOf(ref));
414 private Measure createNewDebtMeasure(double variation) {
415 return newMeasureBuilder().setVariation(variation).createNoValue();
418 private static Measure createNclocDataMeasure(Integer... nclocLines) {
419 Set<Integer> nclocLinesSet = ImmutableSet.copyOf(nclocLines);
420 int max = Ordering.<Integer>natural().max(nclocLinesSet);
421 ImmutableMap.Builder<Integer, Integer> builder = ImmutableMap.builder();
422 for (int i = 1; i <= max; i++) {
423 builder.put(i, nclocLinesSet.contains(i) ? 1 : 0);
425 return newMeasureBuilder().create(KeyValueFormat.format(builder.build(), KeyValueFormat.newIntegerConverter(), KeyValueFormat.newIntegerConverter()));
428 private static Measure createNoNclocDataMeasure(int lineCount) {
429 ImmutableMap.Builder<Integer, Integer> builder = ImmutableMap.builder();
430 for (int i = 1; i <= lineCount; i++) {
433 return newMeasureBuilder().create(KeyValueFormat.format(builder.build(), KeyValueFormat.newIntegerConverter(), KeyValueFormat.newIntegerConverter()));
437 * Creates changesets of {@code lines} lines which all have the same date {@code scmDate}.
439 private static Changeset[] createChangesets(long scmDate, int lines) {
440 Changeset changetset = Changeset.newChangesetBuilder().setDate(scmDate).setRevision("rev-1").build();
441 Changeset[] changesets = new Changeset[lines];
442 for (int i = 0; i < lines; i++) {
443 changesets[i] = changetset;
449 * Creates a changeset of {@code lineCount} lines which have the date {@code scmDate} and {@code otherLineCount} lines which
450 * have the date {@code otherScmDate}.
452 private static Changeset[] createChangesets(long scmDate, int lineCount, long otherScmDate, int otherLineCount) {
453 Changeset[] changesets = new Changeset[lineCount + otherLineCount];
454 Changeset changetset1 = Changeset.newChangesetBuilder().setDate(scmDate).setRevision("rev-1").build();
455 for (int i = 0; i < lineCount; i++) {
456 changesets[i] = changetset1;
458 Changeset changetset2 = Changeset.newChangesetBuilder().setDate(otherScmDate).setRevision("rev-2").build();
459 for (int i = lineCount; i < lineCount + otherLineCount; i++) {
460 changesets[i] = changetset2;
465 private void assertNoNewDebtRatioMeasure(int componentRef) {
466 assertThat(measureRepository.getAddedRawMeasure(componentRef, NEW_SQALE_DEBT_RATIO_KEY))
470 private void assertNewDebtRatioValues(int componentRef, double expectedVariation) {
471 assertThat(measureRepository.getAddedRawMeasure(componentRef, NEW_SQALE_DEBT_RATIO_KEY)).hasVariation(expectedVariation, VARIATION_COMPARISON_OFFSET);
474 private void assertNewMaintainability(int componentRef, Rating expectedVariation) {
475 assertThat(measureRepository.getAddedRawMeasure(componentRef, NEW_MAINTAINABILITY_RATING_KEY)).hasVariation(expectedVariation.getIndex());
478 private void assertNoNewMaintainability(int componentRef) {
479 assertThat(measureRepository.getAddedRawMeasure(componentRef, NEW_MAINTAINABILITY_RATING_KEY))
483 private void setPeriod() {
484 periodsHolder.setPeriod(new Period(SOME_PERIOD_MODE, null, PERIOD_SNAPSHOT_DATE, SOME_ANALYSIS_UUID));