]> source.dussan.org Git - sonarqube.git/blob
3a2794242cfef6f747b6f2a3c4ce00bb7a37f30a
[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     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_3_REF, NEW_LINES_KEY, 0);
130     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_4_REF, NEW_LINES_KEY, 11);
131     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(DIRECTORY_REF, NEW_LINES_KEY, 22);
132     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(DIRECTORY_2_REF, NEW_LINES_KEY, 0);
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 compute_new_lines_with_no_changeset() {
141     underTest.execute();
142
143     assertComputedAndAggregatedToZeroInt(NEW_LINES_KEY);
144   }
145
146   @Test
147   public void compute_new_lines_with_no_ncloc_data() {
148     underTest.execute();
149
150     assertComputedAndAggregatedToZeroInt(NEW_LINES_KEY);
151   }
152
153   @Test
154   public void compute_duplicated_lines_counts_lines_from_original_and_InnerDuplicate_of_a_single_line() {
155     duplicationRepository.addDuplication(FILE_1_REF, new TextBlock(1, 1), new TextBlock(2, 2));
156     setChangesets(FILE_1_REF);
157
158     underTest.execute();
159
160     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_DUPLICATED_LINES_KEY, 2d);
161   }
162
163   @Test
164   public void compute_duplicated_lines_counts_lines_from_original_and_ignores_InProjectDuplicate() {
165     TextBlock original = new TextBlock(1, 1);
166     duplicationRepository.addDuplication(FILE_1_REF, original, FILE_2_REF, new TextBlock(2, 2));
167     setChangesets(FILE_1_REF);
168
169     underTest.execute();
170
171     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_DUPLICATED_LINES_KEY, 1d);
172   }
173
174   @Test
175   public void compute_duplicated_lines_counts_lines_from_original_and_ignores_CrossProjectDuplicate() {
176     TextBlock original = new TextBlock(1, 1);
177     duplicationRepository.addDuplication(FILE_1_REF, original, SOME_FILE_KEY, new TextBlock(2, 2));
178     setChangesets(FILE_1_REF);
179
180     underTest.execute();
181
182     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_DUPLICATED_LINES_KEY, 1d);
183   }
184
185   @Test
186   public void compute_duplicated_lines_counts_lines_from_original_and_InnerDuplicate() {
187     TextBlock original = new TextBlock(1, 5);
188     duplicationRepository.addDuplication(FILE_1_REF, original, new TextBlock(10, 11));
189     setChangesets(FILE_1_REF);
190
191     underTest.execute();
192
193     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_DUPLICATED_LINES_KEY, 6d);
194   }
195
196   @Test
197   public void compute_duplicated_lines_counts_lines_from_original_and_InnerDuplicate_only_once() {
198     TextBlock original = new TextBlock(1, 10);
199     duplicationRepository.addDuplication(FILE_1_REF, original, new TextBlock(10, 11), new TextBlock(11, 12));
200     duplicationRepository.addDuplication(FILE_1_REF, new TextBlock(2, 2), new TextBlock(4, 4));
201     setChangesets(FILE_1_REF);
202
203     underTest.execute();
204
205     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_DUPLICATED_LINES_KEY, 11d);
206   }
207
208   @Test
209   public void compute_new_duplicated_lines_on_different_periods() {
210     TextBlock original = new TextBlock(1, 1);
211     duplicationRepository.addDuplication(FILE_1_REF, original, new TextBlock(2, 2));
212     scmInfoRepository.setScmInfo(FILE_1_REF,
213       Changeset.newChangesetBuilder().setDate(parseDate("2012-01-01").getTime()).setRevision("rev-1").build(),
214       Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-2").build());
215
216     underTest.execute();
217
218     assertRawMeasureValue(FILE_1_REF, NEW_DUPLICATED_LINES_KEY, 2d, 1d);
219   }
220
221   @Test
222   public void compute_and_aggregate_duplicated_lines() {
223     addDuplicatedBlock(FILE_1_REF, 2);
224     addDuplicatedBlock(FILE_3_REF, 10);
225     addDuplicatedBlock(FILE_4_REF, 12);
226     setChangesets(FILE_1_REF);
227     setChangesets(FILE_2_REF);
228     setChangesets(FILE_3_REF);
229     setChangesets(FILE_4_REF);
230
231     underTest.execute();
232
233     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_DUPLICATED_LINES_KEY, 2d);
234     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_2_REF, NEW_DUPLICATED_LINES_KEY, 0d);
235     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_3_REF, NEW_DUPLICATED_LINES_KEY, 9d);
236     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_4_REF, NEW_DUPLICATED_LINES_KEY, 11d);
237     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(DIRECTORY_REF, NEW_DUPLICATED_LINES_KEY, 2d);
238     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(DIRECTORY_2_REF, NEW_DUPLICATED_LINES_KEY, 0d);
239     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(SUB_MODULE_1_REF, NEW_DUPLICATED_LINES_KEY, 2d);
240     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(SUB_MODULE_2_REF, NEW_DUPLICATED_LINES_KEY, 20d);
241     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(MODULE_REF, NEW_DUPLICATED_LINES_KEY, 22d);
242     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(ROOT_REF, NEW_DUPLICATED_LINES_KEY, 22d);
243   }
244
245   @Test
246   public void compute_and_aggregate_zero_duplicated_line_when_no_duplication() {
247     setChangesets(FILE_1_REF);
248     setChangesets(FILE_2_REF);
249     setChangesets(FILE_3_REF);
250     setChangesets(FILE_4_REF);
251
252     underTest.execute();
253
254     assertComputedAndAggregatedToZeroInt(NEW_DUPLICATED_LINES_KEY);
255   }
256
257   @Test
258   public void compute_duplicated_blocks_one_for_original_one_for_each_InnerDuplicate() {
259     TextBlock original = new TextBlock(1, 1);
260     duplicationRepository.addDuplication(FILE_1_REF, original, new TextBlock(2, 2), new TextBlock(4, 4), new TextBlock(3, 4));
261     setChangesets(FILE_1_REF);
262
263     underTest.execute();
264
265     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_BLOCKS_DUPLICATED_KEY, 4);
266   }
267
268   @Test
269   public void compute_duplicated_blocks_does_not_count_blocks_only_once_it_assumes_consistency_from_duplication_data() {
270     duplicationRepository.addDuplication(FILE_1_REF, new TextBlock(1, 1), new TextBlock(4, 4));
271     duplicationRepository.addDuplication(FILE_1_REF, new TextBlock(2, 2), new TextBlock(4, 4));
272     setChangesets(FILE_1_REF);
273
274     underTest.execute();
275
276     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_BLOCKS_DUPLICATED_KEY, 4);
277   }
278
279   @Test
280   public void compute_duplicated_blocks_one_for_original_and_ignores_InProjectDuplicate() {
281     duplicationRepository.addDuplication(FILE_1_REF, new TextBlock(1, 1), FILE_2_REF, new TextBlock(2, 2));
282     setChangesets(FILE_1_REF);
283
284     underTest.execute();
285
286     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_BLOCKS_DUPLICATED_KEY, 1);
287   }
288
289   @Test
290   public void compute_duplicated_blocks_one_for_original_and_ignores_CrossProjectDuplicate() {
291     duplicationRepository.addDuplication(FILE_1_REF, new TextBlock(1, 1), SOME_FILE_KEY, new TextBlock(2, 2));
292     setChangesets(FILE_1_REF);
293
294     underTest.execute();
295
296     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_BLOCKS_DUPLICATED_KEY, 1);
297   }
298
299   @Test
300   public void compute_and_aggregate_duplicated_blocks_from_single_duplication() {
301     addDuplicatedBlock(FILE_1_REF, 11);
302     addDuplicatedBlock(FILE_2_REF, 2);
303     addDuplicatedBlock(FILE_4_REF, 7);
304     setChangesets(FILE_1_REF, FILE_2_REF, FILE_3_REF, FILE_4_REF);
305
306     underTest.execute();
307
308     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, NEW_BLOCKS_DUPLICATED_KEY, 10);
309     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_2_REF, NEW_BLOCKS_DUPLICATED_KEY, 2);
310     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_3_REF, NEW_BLOCKS_DUPLICATED_KEY, 0);
311     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_4_REF, NEW_BLOCKS_DUPLICATED_KEY, 6);
312     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(DIRECTORY_REF, NEW_BLOCKS_DUPLICATED_KEY, 12);
313     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(SUB_MODULE_1_REF, NEW_BLOCKS_DUPLICATED_KEY, 12);
314     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(SUB_MODULE_2_REF, NEW_BLOCKS_DUPLICATED_KEY, 6);
315     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(MODULE_REF, NEW_BLOCKS_DUPLICATED_KEY, 18);
316     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(ROOT_REF, NEW_BLOCKS_DUPLICATED_KEY, 18);
317   }
318
319   @Test
320   public void compute_and_aggregate_duplicated_blocks_to_zero_when_no_duplication() {
321     setChangesets(FILE_1_REF, FILE_2_REF, FILE_3_REF, FILE_4_REF);
322
323     underTest.execute();
324
325     assertComputedAndAggregatedToZeroInt(NEW_BLOCKS_DUPLICATED_KEY);
326   }
327
328   @Test
329   public void compute_new_duplicated_lines_density() {
330     setChangesets(FILE_1_REF, FILE_2_REF, FILE_4_REF);
331     addDuplicatedBlock(FILE_1_REF, 2);
332     addDuplicatedBlock(FILE_3_REF, 10);
333     addDuplicatedBlock(FILE_4_REF, 12);
334
335     underTest.execute();
336
337     assertRawMeasureValue(FILE_1_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 18.2d, null);
338     assertRawMeasureValue(FILE_2_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 0d, null);
339     assertNoRawMeasure(FILE_3_REF, NEW_DUPLICATED_LINES_DENSITY_KEY);
340     assertRawMeasureValue(FILE_4_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 100d, null);
341     assertRawMeasureValue(DIRECTORY_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 9.1d, null);
342     assertNoRawMeasure(DIRECTORY_2_REF, NEW_DUPLICATED_LINES_DENSITY_KEY);
343     assertRawMeasureValue(SUB_MODULE_1_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 9.1d, null);
344     assertRawMeasureValue(SUB_MODULE_2_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 100d, null);
345     assertRawMeasureValue(MODULE_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 39.4d, null);
346     assertRawMeasureValue(ROOT_REF, NEW_DUPLICATED_LINES_DENSITY_KEY, 39.4d, null);
347   }
348
349   @Test
350   public void compute_no_new_duplicated_lines_density_when_no_lines() {
351     underTest.execute();
352
353     assertNoRawMeasures(NEW_DUPLICATED_LINES_DENSITY_KEY);
354   }
355
356   /**
357    * Adds duplication blocks of a single line (each line is specific to its block).
358    *
359    * This is a very simple use case, convenient for unit tests but more realistic and complex use cases must be tested separately.
360    */
361   private void addDuplicatedBlock(int fileRef, int blockCount) {
362     checkArgument(blockCount > 1, "BlockCount can not be less than 2");
363     TextBlock original = new TextBlock(1, 1);
364     TextBlock[] duplicates = new TextBlock[blockCount - 1];
365     for (int i = 2; i < blockCount + 1; i++) {
366       duplicates[i - 2] = new TextBlock(i, i);
367     }
368     duplicationRepository.addDuplication(fileRef, original, duplicates);
369   }
370
371   private void setChangesets(int... componentRefs) {
372     Arrays.stream(componentRefs)
373       .forEach(componentRef -> scmInfoRepository.setScmInfo(componentRef,
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         // line 3 is older, part of no period
377         Changeset.newChangesetBuilder().setDate(parseDate("2007-01-15").getTime()).setRevision("rev-2").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         Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build(),
381         Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build(),
382         Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build(),
383         Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build(),
384         Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build(),
385         Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build(),
386         Changeset.newChangesetBuilder().setDate(parseDate("2011-01-01").getTime()).setRevision("rev-1").build()));
387   }
388
389   private void assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(int componentRef, String metricKey, double period2Value) {
390     assertRawMeasureValue(componentRef, metricKey, period2Value, 0d);
391   }
392
393   private void assertRawMeasureValue(int componentRef, String metricKey, double period2Value, @Nullable Double period5Value) {
394     MeasureVariations variations = measureRepository.getAddedRawMeasure(componentRef, metricKey).get().getVariations();
395     assertThat(variations.getVariation2()).isEqualTo(period2Value, DEFAULT_OFFSET);
396     if (period5Value != null) {
397       assertThat(variations.getVariation5()).isEqualTo(period5Value, DEFAULT_OFFSET);
398     } else {
399       assertThat(variations.hasVariation5()).isFalse();
400     }
401   }
402
403   private void assertComputedAndAggregatedToZeroInt(String metricKey) {
404     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_1_REF, metricKey, 0);
405     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_2_REF, metricKey, 0);
406     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_3_REF, metricKey, 0);
407     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(FILE_4_REF, metricKey, 0);
408     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(DIRECTORY_REF, metricKey, 0);
409     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(SUB_MODULE_1_REF, metricKey, 0);
410     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(SUB_MODULE_2_REF, metricKey, 0);
411     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(MODULE_REF, metricKey, 0);
412     assertRawMeasureValueOnPeriod2AndZeroOnPeriod5(ROOT_REF, metricKey, 0);
413   }
414
415   private void assertNoRawMeasure(int componentRef, String metricKey) {
416     assertThat(measureRepository.getAddedRawMeasure(componentRef, metricKey)).isAbsent();
417   }
418
419   private void assertNoRawMeasures(String metricKey) {
420     assertThat(measureRepository.getAddedRawMeasures(FILE_1_REF).get(metricKey)).isEmpty();
421     assertThat(measureRepository.getAddedRawMeasures(FILE_2_REF).get(metricKey)).isEmpty();
422     assertThat(measureRepository.getAddedRawMeasures(FILE_3_REF).get(metricKey)).isEmpty();
423     assertThat(measureRepository.getAddedRawMeasures(FILE_4_REF).get(metricKey)).isEmpty();
424     assertThat(measureRepository.getAddedRawMeasures(DIRECTORY_REF).get(metricKey)).isEmpty();
425     assertThat(measureRepository.getAddedRawMeasures(SUB_MODULE_1_REF).get(metricKey)).isEmpty();
426     assertThat(measureRepository.getAddedRawMeasures(SUB_MODULE_2_REF).get(metricKey)).isEmpty();
427     assertThat(measureRepository.getAddedRawMeasures(MODULE_REF).get(metricKey)).isEmpty();
428     assertThat(measureRepository.getAddedRawMeasures(ROOT_REF).get(metricKey)).isEmpty();
429   }
430 }