Search in sources :

Example 1 with InnerDuplicate

use of org.sonar.server.computation.task.projectanalysis.duplication.InnerDuplicate in project sonarqube by SonarSource.

the class LoadDuplicationsFromReportStepTest method loads_multiple_duplications_with_multiple_duplicates.

@Test
public void loads_multiple_duplications_with_multiple_duplicates() {
    reportReader.putDuplications(FILE_2_REF, createDuplication(singleLineTextRange(LINE), createInnerDuplicate(LINE + 1), createInnerDuplicate(LINE + 2), createInProjectDuplicate(FILE_1_REF, LINE), createInProjectDuplicate(FILE_1_REF, LINE + 10)), createDuplication(singleLineTextRange(OTHER_LINE), createInProjectDuplicate(FILE_1_REF, OTHER_LINE)), createDuplication(singleLineTextRange(OTHER_LINE + 80), createInnerDuplicate(LINE), createInnerDuplicate(LINE + 10)));
    underTest.execute();
    Component file1Component = treeRootHolder.getComponentByRef(FILE_1_REF);
    assertThat(duplicationRepository.getDuplications(FILE_2_REF)).containsOnly(duplication(singleLineDetailedTextBlock(1, LINE), new InnerDuplicate(singleLineTextBlock(LINE + 1)), new InnerDuplicate(singleLineTextBlock(LINE + 2)), new InProjectDuplicate(file1Component, singleLineTextBlock(LINE)), new InProjectDuplicate(file1Component, singleLineTextBlock(LINE + 10))), duplication(singleLineDetailedTextBlock(2, OTHER_LINE), new InProjectDuplicate(file1Component, singleLineTextBlock(OTHER_LINE))), duplication(singleLineDetailedTextBlock(3, OTHER_LINE + 80), new InnerDuplicate(singleLineTextBlock(LINE)), new InnerDuplicate(singleLineTextBlock(LINE + 10))));
}
Also used : InnerDuplicate(org.sonar.server.computation.task.projectanalysis.duplication.InnerDuplicate) InProjectDuplicate(org.sonar.server.computation.task.projectanalysis.duplication.InProjectDuplicate) Component(org.sonar.server.computation.task.projectanalysis.component.Component) Test(org.junit.Test)

Example 2 with InnerDuplicate

use of org.sonar.server.computation.task.projectanalysis.duplication.InnerDuplicate in project sonarqube by SonarSource.

the class LoadDuplicationsFromReportStepTest method loads_never_consider_originals_from_batch_on_same_lines_as_the_equals.

@Test
public void loads_never_consider_originals_from_batch_on_same_lines_as_the_equals() {
    reportReader.putDuplications(FILE_2_REF, createDuplication(singleLineTextRange(LINE), createInnerDuplicate(LINE + 1), createInnerDuplicate(LINE + 2), createInProjectDuplicate(FILE_1_REF, LINE + 2)), createDuplication(singleLineTextRange(LINE), createInnerDuplicate(LINE + 2), createInnerDuplicate(LINE + 3), createInProjectDuplicate(FILE_1_REF, LINE + 2)));
    underTest.execute();
    Component file1Component = treeRootHolder.getComponentByRef(FILE_1_REF);
    assertThat(duplicationRepository.getDuplications(FILE_2_REF)).containsOnly(duplication(singleLineDetailedTextBlock(1, LINE), new InnerDuplicate(singleLineTextBlock(LINE + 1)), new InnerDuplicate(singleLineTextBlock(LINE + 2)), new InProjectDuplicate(file1Component, singleLineTextBlock(LINE + 2))), duplication(singleLineDetailedTextBlock(2, LINE), new InnerDuplicate(singleLineTextBlock(LINE + 2)), new InnerDuplicate(singleLineTextBlock(LINE + 3)), new InProjectDuplicate(file1Component, singleLineTextBlock(LINE + 2))));
}
Also used : InnerDuplicate(org.sonar.server.computation.task.projectanalysis.duplication.InnerDuplicate) InProjectDuplicate(org.sonar.server.computation.task.projectanalysis.duplication.InProjectDuplicate) Component(org.sonar.server.computation.task.projectanalysis.component.Component) Test(org.junit.Test)

Example 3 with InnerDuplicate

use of org.sonar.server.computation.task.projectanalysis.duplication.InnerDuplicate in project sonarqube by SonarSource.

the class LoadDuplicationsFromReportStepTest method loads_duplication_without_otherFileRef_as_inner_duplication.

@Test
public void loads_duplication_without_otherFileRef_as_inner_duplication() {
    reportReader.putDuplications(FILE_2_REF, createDuplication(singleLineTextRange(LINE), createInnerDuplicate(LINE + 1)));
    underTest.execute();
    assertNoDuplication(FILE_1_REF);
    assertDuplications(FILE_2_REF, singleLineDetailedTextBlock(1, LINE), new InnerDuplicate(singleLineTextBlock(LINE + 1)));
}
Also used : InnerDuplicate(org.sonar.server.computation.task.projectanalysis.duplication.InnerDuplicate) Test(org.junit.Test)

Example 4 with InnerDuplicate

use of org.sonar.server.computation.task.projectanalysis.duplication.InnerDuplicate 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);
}
Also used : FileSourceDto(org.sonar.db.source.FileSourceDto) Duplication(org.sonar.server.computation.task.projectanalysis.duplication.Duplication) InnerDuplicate(org.sonar.server.computation.task.projectanalysis.duplication.InnerDuplicate) Duplicate(org.sonar.server.computation.task.projectanalysis.duplication.Duplicate) InnerDuplicate(org.sonar.server.computation.task.projectanalysis.duplication.InnerDuplicate) DbFileSources(org.sonar.db.protobuf.DbFileSources) TextBlock(org.sonar.server.computation.task.projectanalysis.duplication.TextBlock) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 InnerDuplicate (org.sonar.server.computation.task.projectanalysis.duplication.InnerDuplicate)4 Component (org.sonar.server.computation.task.projectanalysis.component.Component)2 InProjectDuplicate (org.sonar.server.computation.task.projectanalysis.duplication.InProjectDuplicate)2 DbFileSources (org.sonar.db.protobuf.DbFileSources)1 FileSourceDto (org.sonar.db.source.FileSourceDto)1 Duplicate (org.sonar.server.computation.task.projectanalysis.duplication.Duplicate)1 Duplication (org.sonar.server.computation.task.projectanalysis.duplication.Duplication)1 TextBlock (org.sonar.server.computation.task.projectanalysis.duplication.TextBlock)1