Search in sources :

Example 1 with SignificantCodeLineHashesComputer

use of org.sonar.ce.task.projectanalysis.source.SourceLinesHashRepositoryImpl.SignificantCodeLineHashesComputer in project sonarqube by SonarSource.

the class SourceLinesHashRepositoryImplTest method SignificantCodeLineHashesComputer_delegates_after_taking_ranges_into_account.

@Test
public void SignificantCodeLineHashesComputer_delegates_after_taking_ranges_into_account() {
    LineRange[] lineRanges = { new LineRange(0, 1), null, new LineRange(1, 5), new LineRange(2, 7), new LineRange(4, 5) };
    SourceLineHashesComputer lineHashComputer = mock(SourceLineHashesComputer.class);
    SignificantCodeLineHashesComputer computer = new SignificantCodeLineHashesComputer(lineHashComputer, lineRanges);
    computer.addLine("testline");
    computer.addLine("testline");
    computer.addLine("testline");
    computer.addLine("testline");
    computer.addLine("testline");
    computer.addLine("testline");
    verify(lineHashComputer).addLine("t");
    // there is an extra line at the end which will be ignored since there is no range for it
    verify(lineHashComputer, times(2)).addLine("");
    verify(lineHashComputer).addLine("estl");
    verify(lineHashComputer).addLine("stlin");
    verify(lineHashComputer).addLine("l");
    verifyNoMoreInteractions(lineHashComputer);
}
Also used : SourceLineHashesComputer(org.sonar.core.hash.SourceLineHashesComputer) LineRange(org.sonar.core.hash.LineRange) SignificantCodeLineHashesComputer(org.sonar.ce.task.projectanalysis.source.SourceLinesHashRepositoryImpl.SignificantCodeLineHashesComputer) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 SignificantCodeLineHashesComputer (org.sonar.ce.task.projectanalysis.source.SourceLinesHashRepositoryImpl.SignificantCodeLineHashesComputer)1 LineRange (org.sonar.core.hash.LineRange)1 SourceLineHashesComputer (org.sonar.core.hash.SourceLineHashesComputer)1