use of org.sonar.server.qualityprofile.ActiveRuleChange.Type.UPDATED in project sonarqube by SonarSource.
the class RegisterQualityProfilesNotificationTest method notification_does_not_include_inherited_profiled_when_rule_is_changed.
@Test
public void notification_does_not_include_inherited_profiled_when_rule_is_changed() {
String language = newLanguageKey();
RuleDefinitionDto rule = db.rules().insert(r -> r.setLanguage(language).setSeverity(Severity.MINOR));
QProfileDto builtInProfile = insertProfile(orgQProfile -> orgQProfile.setIsBuiltIn(true).setLanguage(language));
db.qualityProfiles().activateRule(builtInProfile, rule, ar -> ar.setSeverity(Severity.MINOR));
QProfileDto childProfile = insertProfile(orgQProfile -> orgQProfile.setIsBuiltIn(false).setLanguage(language).setParentKee(builtInProfile.getKee()));
db.qualityProfiles().activateRule(childProfile, rule, ar -> ar.setInheritance(ActiveRuleDto.INHERITED).setSeverity(Severity.MINOR));
addPluginProfile(builtInProfile, rule);
builtInQProfileRepositoryRule.initialize();
db.commit();
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(builtInProfile.getName(), builtInProfile.getLanguage()));
assertThat(updatedProfiles.values()).extracting(value -> value.getActiveRule().getRuleUuid(), ActiveRuleChange::getType).containsExactlyInAnyOrder(tuple(rule.getUuid(), UPDATED));
}
Aggregations