use of org.sonar.ce.task.projectanalysis.duplication.TextBlock in project sonarqube by SonarSource.
the class NewSizeMeasuresStepTest 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() {
duplicationRepository.addDuplication(FILE_1_REF, new TextBlock(1, 1), new TextBlock(2, 2));
setNewLines(FILE_1);
underTest.execute(new TestComputationStepContext());
assertRawMeasureValueOnPeriod(FILE_1_REF, NEW_DUPLICATED_LINES_KEY, 2d);
}
use of org.sonar.ce.task.projectanalysis.duplication.TextBlock in project sonarqube by SonarSource.
the class NewSizeMeasuresStepTest method compute_duplicated_blocks_one_for_original_and_ignores_CrossProjectDuplicate.
@Test
public void compute_duplicated_blocks_one_for_original_and_ignores_CrossProjectDuplicate() {
duplicationRepository.addCrossProjectDuplication(FILE_1_REF, new TextBlock(1, 1), SOME_FILE_KEY, new TextBlock(2, 2));
setNewLines(FILE_1);
underTest.execute(new TestComputationStepContext());
assertRawMeasureValueOnPeriod(FILE_1_REF, NEW_BLOCKS_DUPLICATED_KEY, 1);
}
use of org.sonar.ce.task.projectanalysis.duplication.TextBlock in project sonarqube by SonarSource.
the class NewSizeMeasuresStepTest method compute_duplicated_lines_counts_lines_from_original_and_ignores_InProjectDuplicate.
@Test
public void compute_duplicated_lines_counts_lines_from_original_and_ignores_InProjectDuplicate() {
TextBlock original = new TextBlock(1, 1);
duplicationRepository.addDuplication(FILE_1_REF, original, FILE_2_REF, new TextBlock(2, 2));
setNewLines(FILE_1);
underTest.execute(new TestComputationStepContext());
assertRawMeasureValueOnPeriod(FILE_1_REF, NEW_DUPLICATED_LINES_KEY, 1d);
}
use of org.sonar.ce.task.projectanalysis.duplication.TextBlock in project sonarqube by SonarSource.
the class PersistDuplicationDataStepTest method compute_duplications_on_different_projects.
@Test
public void compute_duplications_on_different_projects() {
String fileKeyFromOtherProject = "PROJECT2_KEY:file2";
duplicationRepository.addCrossProjectDuplication(FILE_1_REF, new TextBlock(1, 5), fileKeyFromOtherProject, new TextBlock(6, 10));
TestComputationStepContext context = new TestComputationStepContext();
underTest().execute(context);
assertThat(selectMeasureData(FILE_1_UUID)).hasValue("<duplications><g><b s=\"1\" l=\"5\" t=\"false\" r=\"" + FILE_1_KEY + "\"/><b s=\"6\" l=\"5\" t=\"false\" r=\"" + fileKeyFromOtherProject + "\"/></g></duplications>");
assertThat(selectMeasureData(FILE_2_UUID)).isEmpty();
assertThat(selectMeasureData(PROJECT_UUID)).isEmpty();
}
use of org.sonar.ce.task.projectanalysis.duplication.TextBlock in project sonarqube by SonarSource.
the class PersistDuplicationDataStepTest 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));
TestComputationStepContext context = new TestComputationStepContext();
underTest().execute(context);
assertThat(selectMeasureData(FILE_1_UUID)).hasValue("<duplications><g><b s=\"1\" l=\"5\" t=\"false\" r=\"" + FILE_1_KEY + "\"/><b s=\"6\" l=\"5\" t=\"false\" r=\"" + FILE_1_KEY + "\"/></g></duplications>");
assertThat(selectMeasureData(FILE_2_UUID)).isEmpty();
assertThat(selectMeasureData(PROJECT_UUID)).isEmpty();
}
Aggregations