use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class GetByProjectActionTest method insertQualityGate.
private QualityGateDto insertQualityGate(String name) {
QualityGateDto qualityGate = dbClient.qualityGateDao().insert(dbSession, new QualityGateDto().setName(name));
db.commit();
return qualityGate;
}
use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class GetByProjectActionTest method get_with_project_admin_permission.
@Test
public void get_with_project_admin_permission() {
ComponentDto project = componentDb.insertProject();
userSession.logIn().addProjectUuidPermissions(UserRole.ADMIN, project.uuid());
QualityGateDto dbQualityGate = insertQualityGate("Sonar way");
setDefaultQualityGate(dbQualityGate.getId());
GetByProjectWsResponse result = callByUuid(project.uuid());
assertThat(result.getQualityGate().getName()).isEqualTo(dbQualityGate.getName());
}
use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class QualityGateFinderTest method fail_when_default_qgate_defined_in_properties_does_not_exists.
@Test
public void fail_when_default_qgate_defined_in_properties_does_not_exists() throws Exception {
ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.organizations().insert()));
QualityGateDto dbQualityGate = dbTester.qualityGates().createDefaultQualityGate("Sonar way");
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 QualityGateFinderTest method return_project_quality_gate_over_default.
@Test
public void return_project_quality_gate_over_default() {
ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.organizations().insert()));
dbTester.qualityGates().createDefaultQualityGate("Sonar way");
QualityGateDto dbQualityGate = dbTester.qualityGates().insertQualityGate("My team QG");
dbTester.qualityGates().associateProjectToQualityGate(project, dbQualityGate);
Optional<QualityGateFinder.QualityGateData> result = underTest.getQualityGate(dbSession, project.getId());
assertThat(result).isPresent();
assertThat(result.get().getQualityGate().getId()).isEqualTo(dbQualityGate.getId());
assertThat(result.get().isDefault()).isFalse();
}
use of org.sonar.db.qualitygate.QualityGateDto in project sonarqube by SonarSource.
the class QualityGatesTest method should_select_default_qgate.
@Test
public void should_select_default_qgate() {
long defaultId = QUALITY_GATE_ID;
String defaultName = "Default Name";
when(dao.selectById(dbSession, defaultId)).thenReturn(new QualityGateDto().setId(defaultId).setName(defaultName));
underTest.setDefault(defaultId);
verify(dao).selectById(dbSession, defaultId);
ArgumentCaptor<PropertyDto> propertyCaptor = ArgumentCaptor.forClass(PropertyDto.class);
verify(propertiesDao).saveProperty(any(DbSession.class), propertyCaptor.capture());
assertThat(propertyCaptor.getValue().getKey()).isEqualTo("sonar.qualitygate");
assertThat(propertyCaptor.getValue().getValue()).isEqualTo("42");
}
Aggregations