use of org.sonar.server.computation.task.projectanalysis.duplication.TextBlock in project sonarqube by SonarSource.
the class ReportDuplicationMeasuresStepTest method compute_duplicated_lines_counts_lines_from_original_and_InnerDuplicate_of_a_single_line.
@Test
public void compute_duplicated_lines_counts_lines_from_original_and_InnerDuplicate_of_a_single_line() {
TextBlock original = new TextBlock(1, 1);
duplicationRepository.addDuplication(FILE_1_REF, original, new TextBlock(2, 2));
underTest.execute();
assertRawMeasureValue(FILE_1_REF, DUPLICATED_LINES_KEY, 2);
}
use of org.sonar.server.computation.task.projectanalysis.duplication.TextBlock in project sonarqube by SonarSource.
the class ReportDuplicationMeasuresStepTest 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));
underTest.execute();
assertRawMeasureValue(FILE_1_REF, DUPLICATED_LINES_KEY, 7);
}
use of org.sonar.server.computation.task.projectanalysis.duplication.TextBlock in project sonarqube by SonarSource.
the class DuplicationLineReaderTest method read_duplication_with_duplicates_on_other_file_from_other_project.
@Test
public void read_duplication_with_duplicates_on_other_file_from_other_project() {
DuplicationLineReader reader = duplicationLineReader(duplication(1, 2, new CrossProjectDuplicate("other-component-key-from-another-project", new TextBlock(3, 4))));
reader.read(line1);
reader.read(line2);
reader.read(line3);
reader.read(line4);
assertThat(line1.getDuplicationList()).containsExactly(1);
assertThat(line2.getDuplicationList()).containsExactly(1);
assertThat(line3.getDuplicationList()).isEmpty();
assertThat(line4.getDuplicationList()).isEmpty();
}
use of org.sonar.server.computation.task.projectanalysis.duplication.TextBlock in project sonarqube by SonarSource.
the class DuplicationLineReaderTest method read_duplication_with_duplicates_on_other_file.
@Test
public void read_duplication_with_duplicates_on_other_file() {
DuplicationLineReader reader = duplicationLineReader(duplication(1, 2, new InProjectDuplicate(fileComponent(1).build(), new TextBlock(3, 4))));
reader.read(line1);
reader.read(line2);
reader.read(line3);
reader.read(line4);
assertThat(line1.getDuplicationList()).containsExactly(1);
assertThat(line2.getDuplicationList()).containsExactly(1);
assertThat(line3.getDuplicationList()).isEmpty();
assertThat(line4.getDuplicationList()).isEmpty();
}
use of org.sonar.server.computation.task.projectanalysis.duplication.TextBlock in project sonarqube by SonarSource.
the class DuplicationDataMeasuresStepTest method compute_duplications_on_different_files.
@Test
public void compute_duplications_on_different_files() {
duplicationRepository.addDuplication(FILE_1_REF, new TextBlock(1, 5), FILE_2_REF, 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_2_KEY + "\"/></g></duplications>");
assertThat(measureRepository.getAddedRawMeasure(FILE_2_REF, DUPLICATIONS_DATA_KEY)).isAbsent();
}
Aggregations