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_one_for_each_InnerDuplicate.
@Test
public void compute_duplicated_blocks_one_for_original_one_for_each_InnerDuplicate() {
TextBlock original = new TextBlock(1, 1);
duplicationRepository.addDuplication(FILE_1_REF, original, new TextBlock(2, 2), new TextBlock(4, 4), new TextBlock(3, 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 PersistFileSourcesStepTest method persist_duplication.
@Test
public void persist_duplication() {
initBasicReport(1);
duplicationRepository.add(FILE_REF, new Duplication(new TextBlock(1, 2), Arrays.<Duplicate>asList(new InnerDuplicate(new TextBlock(3, 4)))));
underTest.execute();
assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1);
FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID);
DbFileSources.Data data = fileSourceDto.getSourceData();
assertThat(data.getLinesList()).hasSize(1);
assertThat(data.getLines(0).getDuplicationList()).hasSize(1);
}
use of org.sonar.server.computation.task.projectanalysis.duplication.TextBlock in project sonarqube by SonarSource.
the class ReportDuplicationMeasuresStepTest method addDuplicatedBlock.
/**
* Adds duplication blocks of a single line (each line is specific to its block).
*
* This is a very simple use case, convenient for unit tests but more realistic and complex use cases must be tested separately.
*/
private void addDuplicatedBlock(int fileRef, int blockCount) {
checkArgument(blockCount > 1, "BlockCount can not be less than 2");
TextBlock original = new TextBlock(1, 1);
TextBlock[] duplicates = new TextBlock[blockCount - 1];
for (int i = 10; i < blockCount + 9; i++) {
duplicates[i - 10] = new TextBlock(i, i);
}
duplicationRepository.addDuplication(fileRef, original, duplicates);
}
use of org.sonar.server.computation.task.projectanalysis.duplication.TextBlock in project sonarqube by SonarSource.
the class ReportDuplicationMeasuresStepTest method compute_duplicated_blocks_one_for_original_one_for_each_InnerDuplicate.
@Test
public void compute_duplicated_blocks_one_for_original_one_for_each_InnerDuplicate() {
TextBlock original = new TextBlock(1, 1);
duplicationRepository.addDuplication(FILE_1_REF, original, new TextBlock(2, 2), new TextBlock(3, 3), new TextBlock(2, 3));
underTest.execute();
assertRawMeasureValue(FILE_1_REF, DUPLICATED_BLOCKS_KEY, 4);
}
use of org.sonar.server.computation.task.projectanalysis.duplication.TextBlock in project sonarqube by SonarSource.
the class ReportDuplicationMeasuresStepTest 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));
underTest.execute();
assertRawMeasureValue(FILE_1_REF, DUPLICATED_BLOCKS_KEY, 1);
}
Aggregations