use of org.sonar.server.computation.task.projectanalysis.duplication.TextBlock in project sonarqube by SonarSource.
the class DuplicationDataMeasuresStepTest method compute_duplications_on_same_file.
@Test
public void compute_duplications_on_same_file() {
duplicationRepository.addDuplication(FILE_1_REF, new TextBlock(1, 5), new TextBlock(6, 10));
underTest.execute();
assertThat(measureRepository.getAddedRawMeasure(FILE_1_REF, DUPLICATIONS_DATA_KEY)).isPresent();
assertThat(measureRepository.getAddedRawMeasure(FILE_1_REF, DUPLICATIONS_DATA_KEY).get().getData()).isEqualTo("<duplications><g><b s=\"1\" l=\"5\" r=\"" + FILE_1_KEY + "\"/><b s=\"6\" l=\"5\" r=\"" + FILE_1_KEY + "\"/></g></duplications>");
assertThat(measureRepository.getAddedRawMeasure(FILE_2_REF, DUPLICATIONS_DATA_KEY)).isAbsent();
}
use of org.sonar.server.computation.task.projectanalysis.duplication.TextBlock in project sonarqube by SonarSource.
the class NewSizeMeasuresStepTest method compute_duplicated_blocks_one_for_original_and_ignores_InProjectDuplicate.
@Test
public void compute_duplicated_blocks_one_for_original_and_ignores_InProjectDuplicate() {
duplicationRepository.addDuplication(FILE_1_REF, new TextBlock(1, 1), FILE_2_REF, new TextBlock(2, 2));
setChangesets(FILE_1_REF);
underTest.execute();
assertRawMeasureValueOnPeriod(FILE_1_REF, NEW_BLOCKS_DUPLICATED_KEY, 1);
}
use of org.sonar.server.computation.task.projectanalysis.duplication.TextBlock in project sonarqube by SonarSource.
the class NewSizeMeasuresStepTest method compute_duplicated_blocks_does_not_count_blocks_only_once_it_assumes_consistency_from_duplication_data.
@Test
public void compute_duplicated_blocks_does_not_count_blocks_only_once_it_assumes_consistency_from_duplication_data() {
duplicationRepository.addDuplication(FILE_1_REF, new TextBlock(1, 1), new TextBlock(4, 4));
duplicationRepository.addDuplication(FILE_1_REF, new TextBlock(2, 2), new TextBlock(4, 4));
setChangesets(FILE_1_REF);
underTest.execute();
assertRawMeasureValueOnPeriod(FILE_1_REF, NEW_BLOCKS_DUPLICATED_KEY, 4);
}
use of org.sonar.server.computation.task.projectanalysis.duplication.TextBlock in project sonarqube by SonarSource.
the class NewSizeMeasuresStepTest method compute_duplicated_lines_counts_lines_from_original_and_InnerDuplicate_only_once.
@Test
public void compute_duplicated_lines_counts_lines_from_original_and_InnerDuplicate_only_once() {
TextBlock original = new TextBlock(1, 10);
duplicationRepository.addDuplication(FILE_1_REF, original, new TextBlock(10, 11), new TextBlock(11, 12));
duplicationRepository.addDuplication(FILE_1_REF, new TextBlock(2, 2), new TextBlock(4, 4));
setChangesets(FILE_1_REF);
underTest.execute();
assertRawMeasureValueOnPeriod(FILE_1_REF, NEW_DUPLICATED_LINES_KEY, 11d);
}
use of org.sonar.server.computation.task.projectanalysis.duplication.TextBlock in project sonarqube by SonarSource.
the class NewSizeMeasuresStepTest method compute_duplicated_lines_counts_lines_from_original_and_InnerDuplicate.
@Test
public void compute_duplicated_lines_counts_lines_from_original_and_InnerDuplicate() {
TextBlock original = new TextBlock(1, 5);
duplicationRepository.addDuplication(FILE_1_REF, original, new TextBlock(10, 11));
setChangesets(FILE_1_REF);
underTest.execute();
assertRawMeasureValueOnPeriod(FILE_1_REF, NEW_DUPLICATED_LINES_KEY, 6d);
}
Aggregations