use of org.sonar.db.loadedtemplate.LoadedTemplateDto in project sonarqube by SonarSource.
the class RegisterQualityProfiles method register.
private List<ActiveRuleChange> register(QProfileName name, Collection<RulesProfile> profiles, DbSession session) {
LOGGER.info("Register profile " + name);
List<ActiveRuleChange> changes = new ArrayList<>();
QualityProfileDto profileDto = dbClient.qualityProfileDao().selectByNameAndLanguage(name.getName(), name.getLanguage(), session);
if (profileDto != null) {
changes.addAll(profileFactory.delete(session, profileDto.getKey(), true));
}
profileFactory.create(session, name);
for (RulesProfile profile : profiles) {
for (org.sonar.api.rules.ActiveRule activeRule : profile.getActiveRules()) {
RuleKey ruleKey = RuleKey.of(activeRule.getRepositoryKey(), activeRule.getRuleKey());
RuleActivation activation = new RuleActivation(ruleKey);
activation.setSeverity(activeRule.getSeverity() != null ? activeRule.getSeverity().name() : null);
for (ActiveRuleParam param : activeRule.getActiveRuleParams()) {
activation.setParameter(param.getKey(), param.getValue());
}
changes.addAll(ruleActivator.activate(session, activation, name));
}
}
LoadedTemplateDto template = new LoadedTemplateDto(templateKey(name), LoadedTemplateDto.QUALITY_PROFILE_TYPE);
dbClient.loadedTemplateDao().insert(template, session);
session.commit();
return changes;
}
use of org.sonar.db.loadedtemplate.LoadedTemplateDto in project sonarqube by SonarSource.
the class RegisterQualityGatesTest method does_not_register_default_gate_if_already_executed.
@Test
public void does_not_register_default_gate_if_already_executed() {
String templateType = "QUALITY_GATE";
String templateName = "SonarQube way";
dbClient.loadedTemplateDao().insert(new LoadedTemplateDto(templateName, templateType), dbSession);
dbSession.commit();
task.start();
assertThat(dbClient.qualityGateDao().selectAll(dbSession)).isEmpty();
verifyZeroInteractions(qualityGates);
}
Aggregations