use of org.sonar.core.hash.SourceHashComputer in project sonarqube by SonarSource.
the class SourceHashRepositoryImplTest method getRawSourceHash_returns_hash_of_lines_from_SourceLinesRepository.
@Test
public void getRawSourceHash_returns_hash_of_lines_from_SourceLinesRepository() {
sourceLinesRepository.addLines(FILE_REF, SOME_LINES);
String rawSourceHash = underTest.getRawSourceHash(FILE_COMPONENT);
SourceHashComputer sourceHashComputer = new SourceHashComputer();
for (int i = 0; i < SOME_LINES.length; i++) {
sourceHashComputer.addLine(SOME_LINES[i], i < (SOME_LINES.length - 1));
}
assertThat(rawSourceHash).isEqualTo(sourceHashComputer.getHash());
}
use of org.sonar.core.hash.SourceHashComputer in project sonarqube by SonarSource.
the class ScmInfoRepositoryImplTest method computeSourceHash.
private static String computeSourceHash(int lineCount) {
SourceHashComputer sourceHashComputer = new SourceHashComputer();
Iterator<String> lines = generateLines(lineCount).iterator();
while (lines.hasNext()) {
sourceHashComputer.addLine(lines.next(), lines.hasNext());
}
return sourceHashComputer.getHash();
}
use of org.sonar.core.hash.SourceHashComputer in project sonarqube by SonarSource.
the class FileSourceDataComputerTest method computeSrcHash.
private static String computeSrcHash(List<String> lines) {
SourceHashComputer computer = new SourceHashComputer();
Iterator<String> iterator = lines.iterator();
while (iterator.hasNext()) {
computer.addLine(iterator.next(), iterator.hasNext());
}
return computer.getHash();
}
use of org.sonar.core.hash.SourceHashComputer in project sonarqube by SonarSource.
the class SourceHashRepositoryImpl method computeRawSourceHash.
private String computeRawSourceHash(Component file) {
SourceHashComputer sourceHashComputer = new SourceHashComputer();
CloseableIterator<String> linesIterator = sourceLinesRepository.readLines(file);
try {
while (linesIterator.hasNext()) {
sourceHashComputer.addLine(linesIterator.next(), linesIterator.hasNext());
}
return sourceHashComputer.getHash();
} finally {
linesIterator.close();
}
}
use of org.sonar.core.hash.SourceHashComputer in project sonarqube by SonarSource.
the class SourceHashRepositoryImplTest method getRawSourceHash_returns_hash_of_lines_from_SourceLinesRepository.
@Test
public void getRawSourceHash_returns_hash_of_lines_from_SourceLinesRepository() {
sourceLinesRepository.addLines(FILE_REF, SOME_LINES);
String rawSourceHash = underTest.getRawSourceHash(FILE_COMPONENT);
SourceHashComputer sourceHashComputer = new SourceHashComputer();
for (int i = 0; i < SOME_LINES.length; i++) {
sourceHashComputer.addLine(SOME_LINES[i], i < (SOME_LINES.length - 1));
}
assertThat(rawSourceHash).isEqualTo(sourceHashComputer.getHash());
}
Aggregations