use of org.sonar.db.source.FileSourceDto in project sonarqube by SonarSource.
the class FileMoveDetectionStep method getFile.
@CheckForNull
private File getFile(DbSession dbSession, DbComponent dbComponent) {
if (dbComponent.getPath() == null) {
return null;
}
FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(dbSession, dbComponent.getUuid());
if (fileSourceDto == null) {
return null;
}
String lineHashes = firstNonNull(fileSourceDto.getLineHashes(), "");
return new File(dbComponent.getPath(), LINES_HASHES_SPLITTER.splitToList(lineHashes));
}
use of org.sonar.db.source.FileSourceDto in project sonarqube by SonarSource.
the class FileMoveDetectionStepTest method mockContentOfFileInDb.
private void mockContentOfFileInDb(String key, @Nullable String[] content) {
FileSourceDto dto = new FileSourceDto();
if (content != null) {
SourceLinesHashesComputer linesHashesComputer = new SourceLinesHashesComputer();
stream(content).forEach(linesHashesComputer::addLine);
dto.setLineHashes(on('\n').join(linesHashesComputer.getLineHashes()));
}
when(fileSourceDao.selectSourceByFileUuid(dbSession, componentUuidOf(key))).thenReturn(dto);
}
use of org.sonar.db.source.FileSourceDto in project sonarqube by SonarSource.
the class ScmInfoRepositoryImplTest method addFileSourceInDb.
private void addFileSourceInDb(@Nullable String author, @Nullable Long date, @Nullable String revision, String srcHash) {
DbFileSources.Data.Builder fileDataBuilder = DbFileSources.Data.newBuilder();
DbFileSources.Line.Builder builder = fileDataBuilder.addLinesBuilder().setLine(1);
if (author != null) {
builder.setScmAuthor(author);
}
if (date != null) {
builder.setScmDate(date);
}
if (revision != null) {
builder.setScmRevision(revision);
}
dbTester.getDbClient().fileSourceDao().insert(dbTester.getSession(), new FileSourceDto().setFileUuid(FILE.getUuid()).setProjectUuid("PROJECT_UUID").setSourceData(fileDataBuilder.build()).setSrcHash(srcHash));
dbTester.commit();
}
use of org.sonar.db.source.FileSourceDto in project sonarqube by SonarSource.
the class PersistFileSourcesStepTest method not_save_revision.
@Test
public void not_save_revision() {
initBasicReport(1);
underTest.execute();
FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID);
assertThat(fileSourceDto.getRevision()).isNull();
}
use of org.sonar.db.source.FileSourceDto in project sonarqube by SonarSource.
the class PersistTestsStepTest method aggregate_coverage_details.
@Test
public void aggregate_coverage_details() {
reportReader.putTests(TEST_FILE_REF_1, Arrays.asList(newTest(1)));
reportReader.putCoverageDetails(TEST_FILE_REF_1, Arrays.asList(newCoverageDetailWithLines(1, MAIN_FILE_REF_1, 1, 3), newCoverageDetailWithLines(1, MAIN_FILE_REF_1, 2, 4)));
underTest.execute();
FileSourceDto dto = dbClient.fileSourceDao().selectTest(db.getSession(), TEST_FILE_UUID_1);
List<Integer> coveredLines = dto.getTestData().get(0).getCoveredFile(0).getCoveredLineList();
assertThat(coveredLines).containsOnly(1, 2, 3, 4);
}
Aggregations