use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.
the class QualityGatesTest method should_delete_qgate_even_if_default.
@Test
public void should_delete_qgate_even_if_default() {
long idToDelete = QUALITY_GATE_ID;
String name = "To Delete";
QualityGateDto toDelete = new QualityGateDto().setId(idToDelete).setName(name);
when(dao.selectById(dbSession, idToDelete)).thenReturn(toDelete);
when(propertiesDao.selectGlobalProperty("sonar.qualitygate")).thenReturn(new PropertyDto().setValue("42"));
when(dbClient.openSession(false)).thenReturn(dbSession);
underTest.delete(idToDelete);
verify(dao).selectById(dbSession, idToDelete);
verify(propertiesDao).deleteGlobalProperty("sonar.qualitygate", dbSession);
verify(propertiesDao).deleteProjectProperties("sonar.qualitygate", "42", dbSession);
verify(dao).delete(toDelete, dbSession);
}
use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.
the class QualityGateDbTester method setDefaultQualityGate.
public void setDefaultQualityGate(QualityGateDto qualityGate) {
dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.qualitygate").setValue(String.valueOf(qualityGate.getId())));
db.commit();
}
use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.
the class UserDaoTest method insertProperty.
private PropertyDto insertProperty(UserDto user) {
PropertyDto dto = new PropertyDto().setKey(randomAlphanumeric(100)).setUserId(user.getId());
dbClient.propertiesDao().saveProperty(session, dto);
return dto;
}
use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.
the class AppAction method appendComponent.
private void appendComponent(JsonWriter json, ComponentDto component, UserSession userSession, DbSession session) {
List<PropertyDto> propertyDtos = dbClient.propertiesDao().selectByQuery(PropertyQuery.builder().setKey("favourite").setComponentId(component.getId()).setUserId(userSession.getUserId()).build(), session);
boolean isFavourite = propertyDtos.size() == 1;
json.prop("key", component.key());
json.prop("uuid", component.uuid());
json.prop("path", component.path());
json.prop("name", component.name());
json.prop("longName", component.longName());
json.prop("q", component.qualifier());
ComponentDto parentProject = retrieveRootIfNotCurrentComponent(component, session);
ComponentDto project = dbClient.componentDao().selectOrFailByUuid(session, component.projectUuid());
// Do not display parent project if parent project and project are the same
boolean displayParentProject = parentProject != null && !parentProject.uuid().equals(project.uuid());
json.prop("subProject", displayParentProject ? parentProject.key() : null);
json.prop("subProjectName", displayParentProject ? parentProject.longName() : null);
json.prop("project", project.key());
json.prop("projectName", project.longName());
json.prop("fav", isFavourite);
}
use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.
the class ProjectDataLoader method getPropertiesMap.
private static Map<String, String> getPropertiesMap(List<PropertyDto> propertyDtos, boolean hasScanPerm) {
Map<String, String> properties = newHashMap();
for (PropertyDto propertyDto : propertyDtos) {
String key = propertyDto.getKey();
String value = propertyDto.getValue();
if (isPropertyAllowed(key, hasScanPerm)) {
properties.put(key, value);
}
}
return properties;
}
Aggregations