use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class ProjectPersisterTest method dont_update.
@Test
public void dont_update() {
ProjectDto p1 = dbTester.components().insertPublicProjectDto(c -> c.setUuid("PROJECT_UUID").setDbKey(ROOT.getKey()).setName(ROOT.getName()).setDescription(ROOT.getDescription()));
assertProject(ROOT.getDescription(), ROOT.getName(), p1.getUpdatedAt());
underTest.persist(dbTester.getSession());
assertProject(ROOT.getDescription(), ROOT.getName(), p1.getUpdatedAt());
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class ProjectPersisterTest method update_description.
@Test
public void update_description() {
ProjectDto p1 = dbTester.components().insertPublicProjectDto(c -> c.setUuid("PROJECT_UUID").setDbKey(ROOT.getKey()).setName(ROOT.getName()).setDescription("OLD_DESC"));
assertProject("OLD_DESC", ROOT.getName(), p1.getUpdatedAt());
underTest.persist(dbTester.getSession());
assertProject(ROOT.getDescription(), ROOT.getName(), 1000L);
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class LoadProjectStep method execute.
@Override
public void execute(Context context) {
try (DbSession dbSession = dbClient.openSession(false)) {
ProjectDto project = dbClient.projectDao().selectProjectByKey(dbSession, descriptor.getKey()).orElseThrow(() -> MessageException.of(format("Project with key [%s] does not exist", descriptor.getKey())));
definitionHolder.setProjectDto(project);
List<BranchDto> branches = dbClient.branchDao().selectByProject(dbSession, project).stream().collect(toList());
definitionHolder.setBranches(branches);
}
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class LoadReportAnalysisMetadataHolderStep method toProject.
private ProjectDto toProject(String projectKey) {
try (DbSession dbSession = dbClient.openSession(false)) {
Optional<ProjectDto> opt = dbClient.projectDao().selectProjectByKey(dbSession, projectKey);
checkState(opt.isPresent(), "Project with key '%s' can't be found", projectKey);
return opt.get();
}
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class LoadReportAnalysisMetadataHolderStep method loadProject.
/**
* @return a {@link Runnable} to execute some checks on the project at the end of the step
*/
private Runnable loadProject(ScannerReport.Metadata reportMetadata) {
CeTask.Component mainComponent = mandatoryComponent(ceTask.getMainComponent());
String mainComponentKey = mainComponent.getKey().orElseThrow(() -> MessageException.of(format("Compute Engine task main component key is null. Project with UUID %s must have been deleted since report was uploaded. Can not proceed.", mainComponent.getUuid())));
CeTask.Component component = mandatoryComponent(ceTask.getComponent());
if (!component.getKey().isPresent()) {
throw MessageException.of(format("Compute Engine task component key is null. Project with UUID %s must have been deleted since report was uploaded. Can not proceed.", component.getUuid()));
}
ProjectDto dto = toProject(reportMetadata.getProjectKey());
analysisMetadata.setProject(Project.from(dto));
return () -> {
if (!mainComponentKey.equals(reportMetadata.getProjectKey())) {
throw MessageException.of(format("ProjectKey in report (%s) is not consistent with projectKey under which the report has been submitted (%s)", reportMetadata.getProjectKey(), mainComponentKey));
}
};
}
Aggregations