use of org.sonar.server.qualityprofile.builtin.QProfileName in project sonarqube by SonarSource.
the class QProfileFactoryImplTest method checkAndCreateCustom_throws_BadRequestException_if_name_empty.
@Test
public void checkAndCreateCustom_throws_BadRequestException_if_name_empty() {
QProfileName name = new QProfileName("xoo", "");
expectBadRequestException(() -> underTest.checkAndCreateCustom(dbSession, name), "quality_profiles.profile_name_cant_be_blank");
}
use of org.sonar.server.qualityprofile.builtin.QProfileName in project sonarqube by SonarSource.
the class QProfileFactoryImplTest method checkAndCreateCustom.
@Test
public void checkAndCreateCustom() {
QProfileDto profile = underTest.checkAndCreateCustom(dbSession, new QProfileName("xoo", "P1"));
assertThat(profile.getKee()).isNotEmpty();
assertThat(profile.getName()).isEqualTo("P1");
assertThat(profile.getLanguage()).isEqualTo("xoo");
assertThat(profile.getRulesProfileUuid()).isNotNull();
assertThat(profile.isBuiltIn()).isFalse();
QProfileDto reloaded = db.getDbClient().qualityProfileDao().selectByNameAndLanguage(dbSession, profile.getName(), profile.getLanguage());
assertEqual(profile, reloaded);
assertThat(db.getDbClient().qualityProfileDao().selectAll(dbSession)).extracting(QProfileDto::getKee).containsExactly(profile.getKee());
}
use of org.sonar.server.qualityprofile.builtin.QProfileName 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