use of org.sonar.db.qualityprofile.RulesProfileDto in project sonarqube by SonarSource.
the class QProfileFactoryImplTest method delete_builtin_profile.
@Test
public void delete_builtin_profile() {
RulesProfileDto builtInProfile = createBuiltInProfile();
QProfileDto profile = associateBuiltInProfile(builtInProfile);
underTest.delete(dbSession, asList(profile));
verifyNoCallsActiveRuleIndexerDelete();
// remove only from org_qprofiles
assertThat(db.getDbClient().qualityProfileDao().selectAll(dbSession)).isEmpty();
assertThatRulesProfileExists(builtInProfile);
}
use of org.sonar.db.qualityprofile.RulesProfileDto in project sonarqube by SonarSource.
the class RuleActivator method updateProfileDates.
private void updateProfileDates(DbSession dbSession, RuleActivationContext context) {
RulesProfileDto ruleProfile = context.getRulesProfile();
ruleProfile.setRulesUpdatedAtAsDate(new Date(context.getDate()));
db.qualityProfileDao().update(dbSession, ruleProfile);
if (userSession.isLoggedIn()) {
context.getProfiles().forEach(p -> db.qualityProfileDao().update(dbSession, OrgQProfileDto.from(p).setUserUpdatedAt(context.getDate())));
}
}
use of org.sonar.db.qualityprofile.RulesProfileDto in project sonarqube by SonarSource.
the class RuleActivationContext method selectChild.
/**
* Moves cursor to a child profile
*/
void selectChild(QProfileDto to) {
checkState(!to.isBuiltIn());
QProfileDto qp = requireNonNull(this.profilesByUuid.get(to.getKee()), () -> "No profile with uuid " + to.getKee());
RulesProfileDto ruleProfile = RulesProfileDto.from(qp);
doSwitch(ruleProfile, getRule().get().getUuid());
}
use of org.sonar.db.qualityprofile.RulesProfileDto in project sonarqube by SonarSource.
the class RegisterQualityProfilesNotificationTest method send_notification_when_a_new_rule_is_activated.
@Test
public void send_notification_when_a_new_rule_is_activated() {
String language = newLanguageKey();
RuleDefinitionDto existingRule = db.rules().insert(r -> r.setLanguage(language));
RulesProfileDto dbProfile = insertBuiltInProfile(language);
activateRuleInDb(dbProfile, existingRule, MAJOR);
RuleDefinitionDto newRule = db.rules().insert(r -> r.setLanguage(language));
addPluginProfile(dbProfile, existingRule, newRule);
builtInQProfileRepositoryRule.initialize();
underTest.start();
ArgumentCaptor<Multimap> captor = ArgumentCaptor.forClass(Multimap.class);
verify(builtInQualityProfilesNotification).onChange(captor.capture(), anyLong(), anyLong());
Multimap<QProfileName, ActiveRuleChange> updatedProfiles = captor.getValue();
assertThat(updatedProfiles.keySet()).extracting(QProfileName::getName, QProfileName::getLanguage).containsExactlyInAnyOrder(tuple(dbProfile.getName(), dbProfile.getLanguage()));
assertThat(updatedProfiles.values()).extracting(value -> value.getActiveRule().getRuleUuid(), ActiveRuleChange::getType).containsExactlyInAnyOrder(tuple(newRule.getUuid(), ACTIVATED));
}
use of org.sonar.db.qualityprofile.RulesProfileDto in project sonarqube by SonarSource.
the class RegisterQualityProfilesNotificationTest method insertBuiltInProfile.
private RulesProfileDto insertBuiltInProfile(String language) {
RulesProfileDto ruleProfileDto = newRuleProfileDto(rp -> rp.setIsBuiltIn(true).setLanguage(language));
db.getDbClient().qualityProfileDao().insert(db.getSession(), ruleProfileDto);
db.commit();
return ruleProfileDto;
}
Aggregations