Search in sources :

Example 16 with TextBlock

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

Example 17 with TextBlock

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

Example 18 with TextBlock

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

Example 19 with TextBlock

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

Example 20 with TextBlock

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);
}
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