Search in sources :

Example 1 with ProjectDto

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());
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) Test(org.junit.Test)

Example 2 with ProjectDto

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);
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) Test(org.junit.Test)

Example 3 with ProjectDto

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);
    }
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) DbSession(org.sonar.db.DbSession) BranchDto(org.sonar.db.component.BranchDto)

Example 4 with ProjectDto

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();
    }
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) DbSession(org.sonar.db.DbSession)

Example 5 with ProjectDto

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));
        }
    };
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) CeTask(org.sonar.ce.task.CeTask)

Aggregations

ProjectDto (org.sonar.db.project.ProjectDto)283 Test (org.junit.Test)215 DbSession (org.sonar.db.DbSession)49 BranchDto (org.sonar.db.component.BranchDto)42 UserDto (org.sonar.db.user.UserDto)39 AlmSettingDto (org.sonar.db.alm.setting.AlmSettingDto)38 QProfileDto (org.sonar.db.qualityprofile.QProfileDto)31 SnapshotDto (org.sonar.db.component.SnapshotDto)27 QualityGateDto (org.sonar.db.qualitygate.QualityGateDto)26 ComponentDto (org.sonar.db.component.ComponentDto)23 ComponentTesting.newPrivateProjectDto (org.sonar.db.component.ComponentTesting.newPrivateProjectDto)20 NotFoundException (org.sonar.server.exceptions.NotFoundException)17 WebhookDto (org.sonar.db.webhook.WebhookDto)15 ApplicationProjectDto (org.sonar.db.project.ApplicationProjectDto)14 WebService (org.sonar.api.server.ws.WebService)13 DbClient (org.sonar.db.DbClient)12 PortfolioProjectDto (org.sonar.db.portfolio.PortfolioProjectDto)12 TestRequest (org.sonar.server.ws.TestRequest)11 TestResponse (org.sonar.server.ws.TestResponse)10 Projects (org.sonarqube.ws.Projects)10