]> source.dussan.org Git - sonarqube.git/blob
227b7b6c0edada0a48088d3aa42602c5d666ed8d
[sonarqube.git] /
1 /*
2  * SonarQube
3  * Copyright (C) 2009-2016 SonarSource SA
4  * mailto:contact AT sonarsource DOT com
5  *
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.
10  *
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.
15  *
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.
19  */
20
21 package org.sonar.server.computation.task.projectanalysis.step;
22
23 import java.util.Arrays;
24 import javax.annotation.Nullable;
25 import org.assertj.core.data.Offset;
26 import org.junit.Rule;
27 import org.junit.Test;
28 import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
29 import org.sonar.server.computation.task.projectanalysis.duplication.DuplicationRepositoryRule;
30 import org.sonar.server.computation.task.projectanalysis.duplication.TextBlock;
31 import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule;
32 import org.sonar.server.computation.task.projectanalysis.measure.MeasureVariations;
33 import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
34 import org.sonar.server.computation.task.projectanalysis.period.Period;
35 import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolderRule;
36 import org.sonar.server.computation.task.projectanalysis.scm.Changeset;
37 import org.sonar.server.computation.task.projectanalysis.scm.ScmInfoRepositoryRule;
38
39 import static com.google.common.base.Preconditions.checkArgument;
40 import static org.assertj.core.api.Assertions.assertThat;
41 import static org.assertj.guava.api.Assertions.assertThat;
42 import static org.sonar.api.measures.CoreMetrics.NEW_BLOCKS_DUPLICATED;
43 import static org.sonar.api.measures.CoreMetrics.NEW_BLOCKS_DUPLICATED_KEY;
44 import static org.sonar.api.measures.CoreMetrics.NEW_DUPLICATED_LINES;
45 import static org.sonar.api.measures.CoreMetrics.NEW_DUPLICATED_LINES_DENSITY;
46 import static org.sonar.api.measures.CoreMetrics.NEW_DUPLICATED_LINES_DENSITY_KEY;
47 import static org.sonar.api.measures.CoreMetrics.NEW_DUPLICATED_LINES_KEY;
48 import static org.sonar.api.measures.CoreMetrics.NEW_LINES;
49 import static org.sonar.api.measures.CoreMetrics.NEW_LINES_KEY;
50 import static org.sonar.api.utils.DateUtils.parseDate;
51 import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.DIRECTORY;
52 import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.FILE;
53 import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.MODULE;
54 import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.PROJECT;
55 import static org.sonar.server.computation.task.projectanalysis.component.ReportComponent.builder;
56
57 public class NewSizeMeasuresStepTest {
58
59   private static final Offset<Double> DEFAULT_OFFSET = Offset.offset(0.1d);
60
61   private static final int ROOT_REF = 1;
62   private static final int MODULE_REF = 12;
63   private static final int SUB_MODULE_1_REF = 123;
64   private static final int SUB_MODULE_2_REF = 126;
65   private static final int DIRECTORY_REF = 1234;
66   private static final int DIRECTORY_2_REF = 1235;
67   private static final int FILE_1_REF = 12341;
68   private static final int FILE_2_REF = 12342;
69   private static final int FILE_3_REF = 1261;
70   private static final int FILE_4_REF = 1262;
71   private static final String SOME_FILE_KEY = "some file key";
72
73   @Rule
74   public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule()
75     .setRoot(
76       builder(PROJECT, ROOT_REF)
77         .addChildren(
78           builder(MODULE, MODULE_REF)
79             .addChildren(
80               builder(MODULE, SUB_MODULE_1_REF)
81                 .addChildren(
82                   builder(DIRECTORY, DIRECTORY_REF)
83                     .addChildren(
84                       builder(FILE, FILE_1_REF).build(),
85                       builder(FILE, FILE_2_REF).build())
86                     .build(),
87                   builder(DIRECTORY, DIRECTORY_2_REF).build())
88                 .build(),
89               builder(MODULE, SUB_MODULE_2_REF)
90                 .addChildren(
91                   builder(FILE, FILE_3_REF).build(),
92                   builder(FILE, FILE_4_REF).build())
93                 .build())
94             .build())
95         .build());
96
97   @Rule
98   public PeriodsHolderRule periodsHolder = new PeriodsHolderRule().setPeriods(
99     new Period(2, "mode_p_1", null, parseDate("2009-12-25").getTime(), "u1"),
100     new Period(5, "mode_p_5", null, parseDate("2011-02-18").getTime(), "u2"));
101
102   @Rule
103   public ScmInfoRepositoryRule scmInfoRepository = new ScmInfoRepositoryRule();
104
105   @Rule
106   public MetricRepositoryRule metricRepository = new MetricRepositoryRule()
107     .add(NEW_LINES)
108     .add(NEW_DUPLICATED_LINES)
109     .add(NEW_DUPLICATED_LINES_DENSITY)
110     .add(NEW_BLOCKS_DUPLICATED);
111
112   @Rule
113   public MeasureRepositoryRule measureRepository = MeasureRepositoryRule.create(treeRootHolder, metricRepository);
114
115   @Rule
116   public DuplicationRepositoryRule duplicationRepository = DuplicationRepositoryRule.create(treeRootHolder);
117
118   NewSizeMeasuresStep underTest = new NewSizeMeasuresStep(treeRootHolder, periodsHolder, metricRepository, measureRepository, scmInfoRepository,
119     duplicationRepository);
120
121   @Test
122   public void compute_new_lines() {
123     setChangesets(FILE_1_REF, FILE_2_REF, FILE_4_REF);
124
125     underTest.execute();
126
127     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_LINES_KEY, 11);
128     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_2_REF, NEW_LINES_KEY, 11);
129     assertNoRawMeasure(FILE_3_REF, NEW_LINES_KEY);
130     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_4_REF, NEW_LINES_KEY, 11);
131     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(DIRECTORY_REF, NEW_LINES_KEY, 22);
132     assertNoRawMeasure(DIRECTORY_2_REF, NEW_LINES_KEY);
133     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(SUB_MODULE_1_REF, NEW_LINES_KEY, 22);
134     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(SUB_MODULE_2_REF, NEW_LINES_KEY, 11);
135     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(MODULE_REF, NEW_LINES_KEY, 33);
136     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(ROOT_REF, NEW_LINES_KEY, 33);
137   }
138
139   @Test
140   public void does_not_compute_new_lines_when_no_changeset() {
141     underTest.execute();
142
143     assertNoRawMeasures(NEW_LINES_KEY);
144   }
145
146   @Test
147   public void compute_duplicated_lines_counts_lines_from_original_and_InnerDuplicate_of_a_single_line() {
148     duplicationRepository.addDuplication(FILE_1_REF, new TextBlock(1, 1), new TextBlock(2, 2));
149     setChangesets(FILE_1_REF);
150
151     underTest.execute();
152
153     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_DUPLICATED_LINES_KEY, 2d);
154   }
155
156   @Test
157   public void compute_duplicated_lines_counts_lines_from_original_and_ignores_InProjectDuplicate() {
158     TextBlock original = new TextBlock(1, 1);
159     duplicationRepository.addDuplication(FILE_1_REF, original, FILE_2_REF, new TextBlock(2, 2));
160     setChangesets(FILE_1_REF);
161
162     underTest.execute();
163
164     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_DUPLICATED_LINES_KEY, 1d);
165   }
166
167   @Test
168   public void compute_duplicated_lines_counts_lines_from_original_and_ignores_CrossProjectDuplicate() {
169     TextBlock original = new TextBlock(1, 1);
170     duplicationRepository.addDuplication(FILE_1_REF, original, SOME_FILE_KEY, new TextBlock(2, 2));
171     setChangesets(FILE_1_REF);
172
173     underTest.execute();
174
175     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_DUPLICATED_LINES_KEY, 1d);
176   }
177
178   @Test
179   public void compute_duplicated_lines_counts_lines_from_original_and_InnerDuplicate() {
180     TextBlock original = new TextBlock(1, 5);
181     duplicationRepository.addDuplication(FILE_1_REF, original, new TextBlock(10, 11));
182     setChangesets(FILE_1_REF);
183
184     underTest.execute();
185
186     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_DUPLICATED_LINES_KEY, 6d);
187   }
188
189   @Test
190   public void compute_duplicated_lines_counts_lines_from_original_and_InnerDuplicate_only_once() {
191     TextBlock original = new TextBlock(1, 10);
192     duplicationRepository.addDuplication(FILE_1_REF, original, new TextBlock(10, 11), new TextBlock(11, 12));
193     duplicationRepository.addDuplication(FILE_1_REF, new TextBlock(2, 2), new TextBlock(4, 4));
194     setChangesets(FILE_1_REF);
195
196     underTest.execute();
197
198     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_DUPLICATED_LINES_KEY, 11d);
199   }
200
201   @Test
202   public void compute_new_duplicated_lines_on_different_periods() {
203     TextBlock original = new TextBlock(1, 1);
204     duplicationRepository.addDuplication(FILE_1_REF, original, new TextBlock(2, 2));
205     scmInfoRepository.setScmInfo(FILE_1_REF,
206       Changeset.newChangesetBuilder().setDate(parseDate("2012-01-01").getTime()).setRevision("rev-1").build(),
207       Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-2").build());
208
209     underTest.execute();
210
211     assertRawMeasureValue(FILE_1_REF, NEW_DUPLICATED_LINES_KEY, 2d, 1d);
212   }
213
214   @Test
215   public void compute_and_aggregate_duplicated_lines() {
216     addDuplicatedBlock(FILE_1_REF, 2);
217     addDuplicatedBlock(FILE_3_REF, 10);
218     addDuplicatedBlock(FILE_4_REF, 12);
219     setChangesets(FILE_1_REF);
220     setChangesets(FILE_2_REF);
221     setChangesets(FILE_3_REF);
222     setChangesets(FILE_4_REF);
223
224     underTest.execute();
225
226     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_DUPLICATED_LINES_KEY, 2d);
227     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_2_REF, NEW_DUPLICATED_LINES_KEY, 0d);
228     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_3_REF, NEW_DUPLICATED_LINES_KEY, 9d);
229     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_4_REF, NEW_DUPLICATED_LINES_KEY, 11d);
230     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(DIRECTORY_REF, NEW_DUPLICATED_LINES_KEY, 2d);
231     assertNoRawMeasure(DIRECTORY_2_REF, NEW_DUPLICATED_LINES_KEY);
232     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(SUB_MODULE_1_REF, NEW_DUPLICATED_LINES_KEY, 2d);
233     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(SUB_MODULE_2_REF, NEW_DUPLICATED_LINES_KEY, 20d);
234     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(MODULE_REF, NEW_DUPLICATED_LINES_KEY, 22d);
235     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(ROOT_REF, NEW_DUPLICATED_LINES_KEY, 22d);
236   }
237
238   @Test
239   public void compute_and_aggregate_zero_duplicated_line_when_no_duplication() {
240     setChangesets(FILE_1_REF);
241     setChangesets(FILE_2_REF);
242     setChangesets(FILE_3_REF);
243     setChangesets(FILE_4_REF);
244
245     underTest.execute();
246
247     assertComputedAndAggregatedToZeroInt(NEW_DUPLICATED_LINES_KEY);
248   }
249
250   @Test
251   public void compute_duplicated_blocks_one_for_original_one_for_each_InnerDuplicate() {
252     TextBlock original = new TextBlock(1, 1);
253     duplicationRepository.addDuplication(FILE_1_REF, original, new TextBlock(2, 2), new TextBlock(4, 4), new TextBlock(3, 4));
254     setChangesets(FILE_1_REF);
255
256     underTest.execute();
257
258     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_BLOCKS_DUPLICATED_KEY, 4);
259   }
260
261   @Test
262   public void compute_duplicated_blocks_does_not_count_blocks_only_once_it_assumes_consistency_from_duplication_data() {
263     duplicationRepository.addDuplication(FILE_1_REF, new TextBlock(1, 1), new TextBlock(4, 4));
264     duplicationRepository.addDuplication(FILE_1_REF, new TextBlock(2, 2), new TextBlock(4, 4));
265     setChangesets(FILE_1_REF);
266
267     underTest.execute();
268
269     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_BLOCKS_DUPLICATED_KEY, 4);
270   }
271
272   @Test
273   public void compute_duplicated_blocks_one_for_original_and_ignores_InProjectDuplicate() {
274     duplicationRepository.addDuplication(FILE_1_REF, new TextBlock(1, 1), FILE_2_REF, new TextBlock(2, 2));
275     setChangesets(FILE_1_REF);
276
277     underTest.execute();
278
279     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_BLOCKS_DUPLICATED_KEY, 1);
280   }
281
282   @Test
283   public void compute_duplicated_blocks_one_for_original_and_ignores_CrossProjectDuplicate() {
284     duplicationRepository.addDuplication(FILE_1_REF, new TextBlock(1, 1), SOME_FILE_KEY, new TextBlock(2, 2));
285     setChangesets(FILE_1_REF);
286
287     underTest.execute();
288
289     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_BLOCKS_DUPLICATED_KEY, 1);
290   }
291
292   @Test
293   public void compute_and_aggregate_duplicated_blocks_from_single_duplication() {
294     addDuplicatedBlock(FILE_1_REF, 11);
295     addDuplicatedBlock(FILE_2_REF, 2);
296     addDuplicatedBlock(FILE_4_REF, 7);
297     setChangesets(FILE_1_REF, FILE_2_REF, FILE_3_REF, FILE_4_REF);
298
299     underTest.execute();
300
301     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_BLOCKS_DUPLICATED_KEY, 10);
302     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_2_REF, NEW_BLOCKS_DUPLICATED_KEY, 2);
303     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_3_REF, NEW_BLOCKS_DUPLICATED_KEY, 0);
304     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_4_REF, NEW_BLOCKS_DUPLICATED_KEY, 6);
305     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(DIRECTORY_REF, NEW_BLOCKS_DUPLICATED_KEY, 12);
306     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(SUB_MODULE_1_REF, NEW_BLOCKS_DUPLICATED_KEY, 12);
307     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(SUB_MODULE_2_REF, NEW_BLOCKS_DUPLICATED_KEY, 6);
308     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(MODULE_REF, NEW_BLOCKS_DUPLICATED_KEY, 18);
309     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(ROOT_REF, NEW_BLOCKS_DUPLICATED_KEY, 18);
310   }
311
312   @Test
313   public void compute_and_aggregate_duplicated_blocks_to_zero_when_no_duplication() {
314     setChangesets(FILE_1_REF, FILE_2_REF, FILE_3_REF, FILE_4_REF);
315
316     underTest.execute();
317
318     assertComputedAndAggregatedToZeroInt(NEW_BLOCKS_DUPLICATED_KEY);
319   }
320
321   @Test
322   public void compute_new_duplicated_lines_density() {
323     setChangesets(FILE_1_REF, FILE_2_REF, FILE_4_REF);
324     addDuplicatedBlock(FILE_1_REF, 2);
325     addDuplicatedBlock(FILE_3_REF, 10);
326     addDuplicatedBlock(FILE_4_REF, 12);
327
328     underTest.execute();
329
330     assertRawMeasureValue(FILE_1_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 18.2d, null);
331     assertRawMeasureValue(FILE_2_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 0d, null);
332     assertNoRawMeasure(FILE_3_REF, NEW_DUPLICATED_LINES_DENSITY_KEY);
333     assertRawMeasureValue(FILE_4_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 100d, null);
334     assertRawMeasureValue(DIRECTORY_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 9.1d, null);
335     assertNoRawMeasure(DIRECTORY_2_REF, NEW_DUPLICATED_LINES_DENSITY_KEY);
336     assertRawMeasureValue(SUB_MODULE_1_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 9.1d, null);
337     assertRawMeasureValue(SUB_MODULE_2_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 100d, null);
338     assertRawMeasureValue(MODULE_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 39.4d, null);
339     assertRawMeasureValue(ROOT_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 39.4d, null);
340   }
341
342   @Test
343   public void compute_no_new_duplicated_lines_density_when_no_lines() {
344     underTest.execute();
345
346     assertNoRawMeasures(NEW_DUPLICATED_LINES_DENSITY_KEY);
347   }
348
349   /**
350    * Adds duplication blocks of a single line (each line is specific to its block).
351    *
352    * This is a very simple use case, convenient for unit tests but more realistic and complex use cases must be tested separately.
353    */
354   private void addDuplicatedBlock(int fileRef, int blockCount) {
355     checkArgument(blockCount > 1, "BlockCount can not be less than 2");
356     TextBlock original = new TextBlock(1, 1);
357     TextBlock[] duplicates = new TextBlock[blockCount - 1];
358     for (int i = 2; i < blockCount + 1; i++) {
359       duplicates[i - 2] = new TextBlock(i, i);
360     }
361     duplicationRepository.addDuplication(fileRef, original, duplicates);
362   }
363
364   private void setChangesets(int... componentRefs) {
365     Arrays.stream(componentRefs)
366       .forEach(componentRef -> scmInfoRepository.setScmInfo(componentRef,
367         Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build(),
368         Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build(),
369         // line 3 is older, part of no period
370         Changeset.newChangesetBuilder().setDate(parseDate("2007-01-15").getTime()).setRevision("rev-2").build(),
371         Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build(),
372         Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build(),
373         Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build(),
374         Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build(),
375         Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build(),
376         Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build(),
377         Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build(),
378         Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build(),
379         Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build()));
380   }
381
382   private void assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(int componentRef, String metricKey, double period2Value) {
383     assertRawMeasureValue(componentRef, metricKey, period2Value, 0d);
384   }
385
386   private void assertRawMeasureValue(int componentRef, String metricKey, double period2Value, @Nullable Double period5Value) {
387     MeasureVariations variations = measureRepository.getAddedRawMeasure(componentRef, metricKey).get().getVariations();
388     assertThat(variations.getVariation2()).isEqualTo(period2Value, DEFAULT_OFFSET);
389     if (period5Value != null) {
390       assertThat(variations.getVariation5()).isEqualTo(period5Value, DEFAULT_OFFSET);
391     } else {
392       assertThat(variations.hasVariation5()).isFalse();
393     }
394   }
395
396   private void assertComputedAndAggregatedToZeroInt(String metricKey) {
397     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, metricKey, 0);
398     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_2_REF, metricKey, 0);
399     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_3_REF, metricKey, 0);
400     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_4_REF, metricKey, 0);
401     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(DIRECTORY_REF, metricKey, 0);
402     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(SUB_MODULE_1_REF, metricKey, 0);
403     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(SUB_MODULE_2_REF, metricKey, 0);
404     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(MODULE_REF, metricKey, 0);
405     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(ROOT_REF, metricKey, 0);
406   }
407
408   private void assertNoRawMeasure(int componentRef, String metricKey) {
409     assertThat(measureRepository.getAddedRawMeasure(componentRef, metricKey)).isAbsent();
410   }
411
412   private void assertNoRawMeasures(String metricKey) {
413     assertThat(measureRepository.getAddedRawMeasures(FILE_1_REF).get(metricKey)).isEmpty();
414     assertThat(measureRepository.getAddedRawMeasures(FILE_2_REF).get(metricKey)).isEmpty();
415     assertThat(measureRepository.getAddedRawMeasures(FILE_3_REF).get(metricKey)).isEmpty();
416     assertThat(measureRepository.getAddedRawMeasures(FILE_4_REF).get(metricKey)).isEmpty();
417     assertThat(measureRepository.getAddedRawMeasures(DIRECTORY_REF).get(metricKey)).isEmpty();
418     assertThat(measureRepository.getAddedRawMeasures(SUB_MODULE_1_REF).get(metricKey)).isEmpty();
419     assertThat(measureRepository.getAddedRawMeasures(SUB_MODULE_2_REF).get(metricKey)).isEmpty();
420     assertThat(measureRepository.getAddedRawMeasures(MODULE_REF).get(metricKey)).isEmpty();
421     assertThat(measureRepository.getAddedRawMeasures(ROOT_REF).get(metricKey)).isEmpty();
422   }
423 }