Search in sources :

Example 51 with ProjectDto

use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.

the class WebhookQGChangeEventListener method buildWebHookPayload.

private WebhookPayload buildWebHookPayload(DbSession dbSession, QGChangeEvent event, @Nullable EvaluatedQualityGate evaluatedQualityGate) {
    ProjectDto project = event.getProject();
    BranchDto branch = event.getBranch();
    SnapshotDto analysis = event.getAnalysis();
    Map<String, String> analysisProperties = dbClient.analysisPropertiesDao().selectByAnalysisUuid(dbSession, analysis.getUuid()).stream().collect(Collectors.toMap(AnalysisPropertyDto::getKey, AnalysisPropertyDto::getValue));
    ProjectAnalysis projectAnalysis = new ProjectAnalysis(new Project(project.getUuid(), project.getKey(), project.getName()), null, new Analysis(analysis.getUuid(), analysis.getCreatedAt(), analysis.getRevision()), new Branch(branch.isMain(), branch.getKey(), Type.valueOf(branch.getBranchType().name())), evaluatedQualityGate, null, analysisProperties);
    return webhookPayloadFactory.create(projectAnalysis);
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) BranchDto(org.sonar.db.component.BranchDto) SnapshotDto(org.sonar.db.component.SnapshotDto)

Example 52 with ProjectDto

use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.

the class IssueIndexSyncProgressCheckerTest method checkIfComponentNeedIssueSync_single_component.

@Test
public void checkIfComponentNeedIssueSync_single_component() {
    ProjectDto projectDto1 = insertProjectWithBranches(true, 0);
    ProjectDto projectDto2 = insertProjectWithBranches(false, 0);
    DbSession session = db.getSession();
    // do nothing when need issue sync false
    underTest.checkIfComponentNeedIssueSync(session, projectDto2.getKey());
    // throws if flag set to TRUE
    String key = projectDto1.getKey();
    assertThatThrownBy(() -> underTest.checkIfComponentNeedIssueSync(session, key)).isInstanceOf(EsIndexSyncInProgressException.class).hasFieldOrPropertyWithValue("httpCode", 503).hasMessage("Results are temporarily unavailable. Indexing of issues is in progress.");
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) DbSession(org.sonar.db.DbSession) Test(org.junit.Test)

Example 53 with ProjectDto

use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.

the class IssueIndexSyncProgressCheckerTest method findProjectUuidsWithIssuesSyncNeed.

@Test
public void findProjectUuidsWithIssuesSyncNeed() {
    ProjectDto projectDto1 = insertProjectWithBranches(false, 0);
    ProjectDto projectDto2 = insertProjectWithBranches(false, 0);
    ProjectDto projectDto3 = insertProjectWithBranches(true, 0);
    ProjectDto projectDto4 = insertProjectWithBranches(true, 0);
    assertThat(underTest.findProjectUuidsWithIssuesSyncNeed(db.getSession(), Arrays.asList(projectDto1.getUuid(), projectDto2.getUuid(), projectDto3.getUuid(), projectDto4.getUuid()))).containsOnly(projectDto3.getUuid(), projectDto4.getUuid());
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) Test(org.junit.Test)

Example 54 with ProjectDto

use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.

the class IssueIndexSyncProgressCheckerTest method checkIfAnyComponentsNeedIssueSync_throws_exception_if_at_least_one_component_has_need_issue_sync_TRUE.

@Test
public void checkIfAnyComponentsNeedIssueSync_throws_exception_if_at_least_one_component_has_need_issue_sync_TRUE() {
    ProjectDto projectDto1 = insertProjectWithBranches(false, 0);
    ProjectDto projectDto2 = insertProjectWithBranches(true, 0);
    DbSession session = db.getSession();
    List<String> projectKeys = Arrays.asList(projectDto1.getKey(), projectDto2.getKey());
    assertThatThrownBy(() -> underTest.checkIfAnyComponentsNeedIssueSync(session, projectKeys)).isInstanceOf(EsIndexSyncInProgressException.class).hasFieldOrPropertyWithValue("httpCode", 503).hasMessage("Results are temporarily unavailable. Indexing of issues is in progress.");
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) DbSession(org.sonar.db.DbSession) Test(org.junit.Test)

Example 55 with ProjectDto

use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.

the class IssueIndexSyncProgressCheckerTest method doProjectNeedIssueSync.

@Test
public void doProjectNeedIssueSync() {
    ProjectDto projectDto1 = insertProjectWithBranches(false, 0);
    assertThat(underTest.doProjectNeedIssueSync(db.getSession(), projectDto1.getUuid())).isFalse();
    ProjectDto projectDto2 = insertProjectWithBranches(true, 0);
    assertThat(underTest.doProjectNeedIssueSync(db.getSession(), projectDto2.getUuid())).isTrue();
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) Test(org.junit.Test)

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