use of org.sonar.server.qualityprofile.ActiveRuleChange.Type.ACTIVATED in project sonarqube by SonarSource.
the class RegisterQualityProfilesNotificationTest method send_a_single_notification_when_multiple_rules_are_activated.
@Test
public void send_a_single_notification_when_multiple_rules_are_activated() {
String language = newLanguageKey();
RuleDefinitionDto existingRule1 = db.rules().insert(r -> r.setLanguage(language));
RuleDefinitionDto newRule1 = db.rules().insert(r -> r.setLanguage(language));
RulesProfileDto dbProfile1 = insertBuiltInProfile(language);
activateRuleInDb(dbProfile1, existingRule1, MAJOR);
addPluginProfile(dbProfile1, existingRule1, newRule1);
RuleDefinitionDto existingRule2 = db.rules().insert(r -> r.setLanguage(language));
RuleDefinitionDto newRule2 = db.rules().insert(r -> r.setLanguage(language));
RulesProfileDto dbProfile2 = insertBuiltInProfile(language);
activateRuleInDb(dbProfile2, existingRule2, MAJOR);
addPluginProfile(dbProfile2, existingRule2, newRule2);
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(dbProfile1.getName(), dbProfile1.getLanguage()), tuple(dbProfile2.getName(), dbProfile2.getLanguage()));
assertThat(updatedProfiles.values()).extracting(value -> value.getActiveRule().getRuleUuid(), ActiveRuleChange::getType).containsExactlyInAnyOrder(tuple(newRule1.getUuid(), ACTIVATED), tuple(newRule2.getUuid(), ACTIVATED));
}
use of org.sonar.server.qualityprofile.ActiveRuleChange.Type.ACTIVATED in project sonarqube by SonarSource.
the class RegisterQualityProfilesNotificationTest method notification_does_not_include_inherited_profiles_when_rule_is_added.
@Test
public void notification_does_not_include_inherited_profiles_when_rule_is_added() {
String language = newLanguageKey();
RuleDefinitionDto newRule = db.rules().insert(r -> r.setLanguage(language));
QProfileDto builtInQProfileDto = insertProfile(orgQProfile -> orgQProfile.setIsBuiltIn(true).setLanguage(language));
QProfileDto childQProfileDto = insertProfile(orgQProfile -> orgQProfile.setIsBuiltIn(false).setLanguage(language).setParentKee(builtInQProfileDto.getKee()));
addPluginProfile(builtInQProfileDto, 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(builtInQProfileDto.getName(), builtInQProfileDto.getLanguage()));
assertThat(updatedProfiles.values()).extracting(value -> value.getActiveRule().getRuleUuid(), ActiveRuleChange::getType).containsExactlyInAnyOrder(tuple(newRule.getUuid(), ACTIVATED));
}
use of org.sonar.server.qualityprofile.ActiveRuleChange.Type.ACTIVATED 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));
}
Aggregations