use of org.sonar.scanner.protocol.input.FileData in project sonarqube by SonarSource.
the class ProjectDataLoader method addFileData.
private static void addFileData(ProjectRepositories data, List<ComponentDto> moduleChildren, List<FilePathWithHashDto> files) {
Map<String, String> moduleKeysByUuid = newHashMap();
for (ComponentDto module : moduleChildren) {
moduleKeysByUuid.put(module.uuid(), module.key());
}
for (FilePathWithHashDto file : files) {
FileData fileData = new FileData(file.getSrcHash(), file.getRevision());
data.addFileData(moduleKeysByUuid.get(file.getModuleUuid()), file.getPath(), fileData);
}
}
use of org.sonar.scanner.protocol.input.FileData in project sonarqube by SonarSource.
the class ProjectDataLoaderMediumTest method return_file_data_from_single_project.
@Test
public void return_file_data_from_single_project() {
OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
dbClient.organizationDao().insert(dbSession, organizationDto);
ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid());
dbClient.componentDao().insert(dbSession, project);
addDefaultProfile();
ComponentDto file = ComponentTesting.newFileDto(project, null, "file");
dbClient.componentDao().insert(dbSession, file);
tester.get(FileSourceDao.class).insert(dbSession, newFileSourceDto(file).setSrcHash("123456"));
dbSession.commit();
ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()));
assertThat(ref.fileDataByPath(project.key())).hasSize(1);
FileData fileData = ref.fileData(project.key(), file.path());
assertThat(fileData.hash()).isEqualTo("123456");
}
use of org.sonar.scanner.protocol.input.FileData in project sonarqube by SonarSource.
the class ProjectActionTest method do_not_fail_when_a_path_is_null.
/**
* SONAR-7084
*/
@Test
public void do_not_fail_when_a_path_is_null() throws Exception {
String projectKey = "org.codehaus.sonar:sonar";
ProjectRepositories projectRepositories = new ProjectRepositories().addFileData("module-1", null, new FileData(null, null));
when(projectDataLoader.load(any(ProjectDataQuery.class))).thenReturn(projectRepositories);
TestResponse result = ws.newRequest().setMediaType(MediaTypes.PROTOBUF).setParam("key", projectKey).setParam("profile", "Default").execute();
WsProjectResponse wsProjectResponse = WsProjectResponse.parseFrom(result.getInputStream());
assertThat(wsProjectResponse.getFileDataByModuleAndPath()).isEmpty();
}
Aggregations