use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class RegisterQualityGatesTest method register_default_gate.
@Test
public void register_default_gate() {
MetricDto newReliability = dbClient.metricDao().insert(dbSession, newMetricDto().setKey(NEW_RELIABILITY_RATING_KEY).setValueType(INT.name()).setHidden(false));
MetricDto newSecurity = dbClient.metricDao().insert(dbSession, newMetricDto().setKey(NEW_SECURITY_RATING_KEY).setValueType(INT.name()).setHidden(false));
MetricDto newMaintainability = dbClient.metricDao().insert(dbSession, newMetricDto().setKey(NEW_MAINTAINABILITY_RATING_KEY).setValueType(PERCENT.name()).setHidden(false));
MetricDto newCoverage = dbClient.metricDao().insert(dbSession, newMetricDto().setKey(NEW_COVERAGE_KEY).setValueType(PERCENT.name()).setHidden(false));
dbSession.commit();
task.start();
assertThat(dbClient.loadedTemplateDao().countByTypeAndKey("QUALITY_GATE", "SonarQube way", dbSession)).isEqualTo(1);
QualityGateDto qualityGateDto = dbClient.qualityGateDao().selectByName(dbSession, "SonarQube way");
assertThat(qualityGateDto).isNotNull();
assertThat(dbClient.gateConditionDao().selectForQualityGate(dbSession, qualityGateDto.getId())).extracting(QualityGateConditionDto::getMetricId, QualityGateConditionDto::getOperator, QualityGateConditionDto::getWarningThreshold, QualityGateConditionDto::getErrorThreshold, QualityGateConditionDto::getPeriod).containsOnly(tuple(newReliability.getId().longValue(), OPERATOR_GREATER_THAN, null, "1", 1), tuple(newSecurity.getId().longValue(), OPERATOR_GREATER_THAN, null, "1", 1), tuple(newMaintainability.getId().longValue(), OPERATOR_GREATER_THAN, null, "1", 1), tuple(newCoverage.getId().longValue(), OPERATOR_LESS_THAN, null, "80", 1));
verify(qualityGates).setDefault(any(DbSession.class), anyLong());
task.stop();
}
use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class QualityGateFinderTest method return_default_quality_gate_for_project.
@Test
public void return_default_quality_gate_for_project() {
ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.getDefaultOrganization()));
QualityGateDto dbQualityGate = dbTester.qualityGates().createDefaultQualityGate("Sonar way");
Optional<QualityGateFinder.QualityGateData> result = underTest.getQualityGate(dbSession, project.getId());
assertThat(result).isPresent();
assertThat(result.get().getQualityGate().getId()).isEqualTo(dbQualityGate.getId());
assertThat(result.get().isDefault()).isTrue();
}
use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class QualityGateFinderTest method fail_when_project_qgate_defined_in_properties_does_not_exists.
@Test
public void fail_when_project_qgate_defined_in_properties_does_not_exists() throws Exception {
ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.getDefaultOrganization()));
QualityGateDto dbQualityGate = dbTester.qualityGates().insertQualityGate("My team QG");
dbTester.qualityGates().associateProjectToQualityGate(project, dbQualityGate);
dbTester.getDbClient().qualityGateDao().delete(dbQualityGate, dbSession);
expectedException.expect(NotFoundException.class);
underTest.getQualityGate(dbSession, project.getId());
}
use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class QualityGateUpdaterTest method create_quality_gate.
@Test
public void create_quality_gate() throws Exception {
QualityGateDto result = underTest.create(dbSession, QGATE_NAME);
assertThat(result).isNotNull();
assertThat(result.getName()).isEqualTo(QGATE_NAME);
assertThat(result.getCreatedAt()).isNotNull();
QualityGateDto reloaded = dbClient.qualityGateDao().selectByName(dbSession, QGATE_NAME);
assertThat(reloaded).isNotNull();
}
use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class GetByProjectActionTest method fail_when_insufficient_permission.
@Test
public void fail_when_insufficient_permission() {
ComponentDto project = componentDb.insertComponent(newProjectDto(db.getDefaultOrganization()));
userSession.logIn();
QualityGateDto dbQualityGate = insertQualityGate("Sonar way");
setDefaultQualityGate(dbQualityGate.getId());
expectedException.expect(ForbiddenException.class);
callByUuid(project.uuid());
}
Aggregations