Search in sources :

Example 11 with TextBlock

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);
}
Also used : TextBlock(org.sonar.server.computation.task.projectanalysis.duplication.TextBlock) Test(org.junit.Test)

Example 12 with TextBlock

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);
}
Also used : TextBlock(org.sonar.server.computation.task.projectanalysis.duplication.TextBlock) Test(org.junit.Test)

Example 13 with TextBlock

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();
}
Also used : CrossProjectDuplicate(org.sonar.server.computation.task.projectanalysis.duplication.CrossProjectDuplicate) TextBlock(org.sonar.server.computation.task.projectanalysis.duplication.TextBlock) Test(org.junit.Test)

Example 14 with TextBlock

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();
}
Also used : InProjectDuplicate(org.sonar.server.computation.task.projectanalysis.duplication.InProjectDuplicate) TextBlock(org.sonar.server.computation.task.projectanalysis.duplication.TextBlock) Test(org.junit.Test)

Example 15 with TextBlock

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();
}
Also used : TextBlock(org.sonar.server.computation.task.projectanalysis.duplication.TextBlock) Test(org.junit.Test)

Aggregations

TextBlock (org.sonar.server.computation.task.projectanalysis.duplication.TextBlock)26 Test (org.junit.Test)24 DbFileSources (org.sonar.db.protobuf.DbFileSources)1 FileSourceDto (org.sonar.db.source.FileSourceDto)1 CrossProjectDuplicate (org.sonar.server.computation.task.projectanalysis.duplication.CrossProjectDuplicate)1 Duplicate (org.sonar.server.computation.task.projectanalysis.duplication.Duplicate)1 Duplication (org.sonar.server.computation.task.projectanalysis.duplication.Duplication)1 InProjectDuplicate (org.sonar.server.computation.task.projectanalysis.duplication.InProjectDuplicate)1 InnerDuplicate (org.sonar.server.computation.task.projectanalysis.duplication.InnerDuplicate)1