Search in sources :

Example 1 with InProjectDuplicate

use of org.sonar.ce.task.projectanalysis.duplication.InProjectDuplicate in project sonarqube by SonarSource.

the class LoadDuplicationsFromReportStepTest method loads_duplication_with_otherFileRef_as_inProject_duplication.

@Test
public void loads_duplication_with_otherFileRef_as_inProject_duplication() {
    reportReader.putDuplications(FILE_1_REF, createDuplication(singleLineTextRange(LINE), createInProjectDuplicate(FILE_2_REF, LINE + 1)));
    TestComputationStepContext context = new TestComputationStepContext();
    underTest.execute(context);
    assertDuplications(FILE_1_REF, singleLineDetailedTextBlock(1, LINE), new InProjectDuplicate(treeRootHolder.getComponentByRef(FILE_2_REF), singleLineTextBlock(LINE + 1)));
    assertNoDuplication(FILE_2_REF);
    assertNbOfDuplications(context, 1);
}
Also used : InProjectDuplicate(org.sonar.ce.task.projectanalysis.duplication.InProjectDuplicate) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Example 2 with InProjectDuplicate

use of org.sonar.ce.task.projectanalysis.duplication.InProjectDuplicate in project sonarqube by SonarSource.

the class DuplicationLineReaderTest method read_duplication_with_duplicates_on_other_file.

@Test
public void read_duplication_with_duplicates_on_other_file() {
    DuplicationLineReader reader = duplicationLineReader(duplication(1, 2, new InProjectDuplicate(fileComponent(1).build(), new TextBlock(3, 4))));
    assertThat(reader.read(line1)).isEmpty();
    assertThat(reader.read(line2)).isEmpty();
    assertThat(reader.read(line3)).isEmpty();
    assertThat(reader.read(line4)).isEmpty();
    assertThat(line1.getDuplicationList()).containsExactly(1);
    assertThat(line2.getDuplicationList()).containsExactly(1);
    assertThat(line3.getDuplicationList()).isEmpty();
    assertThat(line4.getDuplicationList()).isEmpty();
}
Also used : InProjectDuplicate(org.sonar.ce.task.projectanalysis.duplication.InProjectDuplicate) TextBlock(org.sonar.ce.task.projectanalysis.duplication.TextBlock) Test(org.junit.Test)

Example 3 with InProjectDuplicate

use of org.sonar.ce.task.projectanalysis.duplication.InProjectDuplicate 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)));
    TestComputationStepContext context = new TestComputationStepContext();
    underTest.execute(context);
    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))));
    assertNbOfDuplications(context, 2);
}
Also used : InnerDuplicate(org.sonar.ce.task.projectanalysis.duplication.InnerDuplicate) InProjectDuplicate(org.sonar.ce.task.projectanalysis.duplication.InProjectDuplicate) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Component(org.sonar.ce.task.projectanalysis.component.Component) Test(org.junit.Test)

Example 4 with InProjectDuplicate

use of org.sonar.ce.task.projectanalysis.duplication.InProjectDuplicate 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)));
    TestComputationStepContext context = new TestComputationStepContext();
    underTest.execute(context);
    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))));
    assertNbOfDuplications(context, 3);
}
Also used : InnerDuplicate(org.sonar.ce.task.projectanalysis.duplication.InnerDuplicate) InProjectDuplicate(org.sonar.ce.task.projectanalysis.duplication.InProjectDuplicate) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Component(org.sonar.ce.task.projectanalysis.component.Component) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 InProjectDuplicate (org.sonar.ce.task.projectanalysis.duplication.InProjectDuplicate)4 TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)3 Component (org.sonar.ce.task.projectanalysis.component.Component)2 InnerDuplicate (org.sonar.ce.task.projectanalysis.duplication.InnerDuplicate)2 TextBlock (org.sonar.ce.task.projectanalysis.duplication.TextBlock)1