Search in sources :

Example 1 with Duplication

use of org.sonar.server.computation.task.projectanalysis.duplication.Duplication 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)1 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 InnerDuplicate (org.sonar.server.computation.task.projectanalysis.duplication.InnerDuplicate)1 TextBlock (org.sonar.server.computation.task.projectanalysis.duplication.TextBlock)1