use of org.sonar.db.source.FileSourceDto in project sonarqube by SonarSource.
the class PersistFileSourcesStepTest method persist_highlighting.
@Test
public void persist_highlighting() {
DbFileSources.Data dbData = DbFileSources.Data.newBuilder().addLines(DbFileSources.Line.newBuilder().setHighlighting("2,4,a").build()).build();
setComputedData(dbData);
underTest.execute(new TestComputationStepContext());
assertThat(dbTester.countRowsOfTable("file_sources")).isOne();
FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectByFileUuid(session, FILE1_UUID);
DbFileSources.Data data = fileSourceDto.getSourceData();
assertThat(data).isEqualTo(dbData);
assertThat(data.getLinesList()).hasSize(1);
assertThat(data.getLines(0).getHighlighting()).isEqualTo("2,4,a");
verify(fileSourceDataWarnings).commitWarnings();
}
use of org.sonar.db.source.FileSourceDto in project sonarqube by SonarSource.
the class ScmInfoDbLoaderTest method addFileSourceInDb.
private void addFileSourceInDb(@Nullable String author, @Nullable Long date, @Nullable String revision, String srcHash, String fileUuid) {
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().setUuid(Uuids.createFast()).setLineHashes(Collections.singletonList("lineHash")).setFileUuid(fileUuid).setProjectUuid("PROJECT_UUID").setSourceData(fileDataBuilder.build()).setSrcHash(srcHash));
dbTester.commit();
}
use of org.sonar.db.source.FileSourceDto in project sonarqube by SonarSource.
the class ExportLineHashesStepTest method createDto.
private FileSourceDto createDto(String fileUuid, String componentUuid, String hashes) {
FileSourceDto fileSourceDto = new FileSourceDto().setUuid(Uuids.createFast()).setFileUuid(fileUuid).setProjectUuid(componentUuid);
fileSourceDto.setRawLineHashes(hashes);
return fileSourceDto;
}
use of org.sonar.db.source.FileSourceDto in project sonarqube by SonarSource.
the class ExportLineHashesStepTest method execute_maps_ref_of_component_and_hashes_from_fileSources.
@Test
public void execute_maps_ref_of_component_and_hashes_from_fileSources() {
int fileRef = 984615;
componentRepository.register(fileRef, FILE_UUID, true);
FileSourceDto dto = createDto(FILE_UUID, PROJECT_MASTER_UUID, "B");
insertFileSource(dto);
underTest.execute(new TestComputationStepContext());
List<ProjectDump.LineHashes> messages = dumpWriter.getWrittenMessagesOf(DumpElement.LINES_HASHES);
assertThat(messages).hasSize(1);
ProjectDump.LineHashes lineHashes = messages.iterator().next();
assertThat(lineHashes.getHashes()).isEqualTo(dto.getRawLineHashes());
assertThat(lineHashes.getComponentRef()).isEqualTo(fileRef);
}
use of org.sonar.db.source.FileSourceDto in project sonarqube by SonarSource.
the class LinesActionTest method pull_request.
@Test
public void pull_request() {
ComponentDto project = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.USER, project);
ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(PULL_REQUEST));
ComponentDto file = db.components().insertComponent(newFileDto(branch));
db.getDbClient().fileSourceDao().insert(db.getSession(), new FileSourceDto().setUuid(Uuids.createFast()).setProjectUuid(branch.uuid()).setFileUuid(file.uuid()).setSourceData(FileSourceTesting.newFakeData(3).build()));
db.commit();
userSession.logIn("login").addProjectPermission(UserRole.CODEVIEWER, project, file);
tester.newRequest().setParam("key", file.getKey()).setParam("pullRequest", file.getPullRequest()).execute().assertJson(getClass(), "show_source.json");
}
Aggregations