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);
}
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.");
}
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());
}
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.");
}
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();
}
Aggregations