use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class QProfileRuleImplTest method ignore_reset_if_not_activated.
@Test
public void ignore_reset_if_not_activated() {
RuleDefinitionDto rule = createRule();
QProfileDto parentProfile = createProfile(rule);
createChildProfile(parentProfile);
RuleActivation resetActivation = RuleActivation.createReset(rule.getUuid());
List<ActiveRuleChange> changes = activate(parentProfile, resetActivation);
verifyNoActiveRules();
assertThat(changes).isEmpty();
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class QProfileBackuperImplTest method copy_profile.
@Test
public void copy_profile() {
RuleDefinitionDto rule = createRule();
RuleParamDto param = db.rules().insertRuleParam(rule);
QProfileDto from = createProfile(rule.getLanguage());
ActiveRuleDto activeRule = activate(from, rule, param);
QProfileDto to = createProfile(rule.getLanguage());
underTest.copy(db.getSession(), from, to);
assertThat(reset.calledActivations).extracting(RuleActivation::getRuleUuid).containsOnly(activeRule.getRuleUuid());
assertThat(reset.calledActivations.get(0).getParameter(param.getName())).isEqualTo("20");
assertThat(reset.calledProfile).isEqualTo(to);
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class QProfileCopierTest method create_target_profile_with_same_parent_than_source_profile.
@Test
public void create_target_profile_with_same_parent_than_source_profile() {
QProfileDto parent = db.qualityProfiles().insert();
QProfileDto source = db.qualityProfiles().insert(p -> p.setParentKee(parent.getKee()));
QProfileDto target = underTest.copyToName(db.getSession(), source, "foo");
assertThat(target.getLanguage()).isEqualTo(source.getLanguage());
assertThat(target.getName()).isEqualTo("foo");
assertThat(target.getParentKee()).isEqualTo(parent.getKee());
verify(backuper).copy(db.getSession(), source, target);
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class QProfileCopierTest method fail_to_copy_on_self.
@Test
public void fail_to_copy_on_self() {
QProfileDto source = db.qualityProfiles().insert();
try {
underTest.copyToName(db.getSession(), source, source.getName());
fail();
} catch (IllegalArgumentException e) {
assertThat(e).hasMessage("Source and target profiles are equal: " + source.getName());
verifyZeroInteractions(backuper);
}
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class QProfileRuleImplTest method update_activation_with_new_parameter.
@Test
public void update_activation_with_new_parameter() {
RuleDefinitionDto rule = createRule();
RuleParamDto param = db.rules().insertRuleParam(rule, p -> p.setName("max").setDefaultValue("10"));
QProfileDto profile = createProfile(rule);
// initial activation -> param "max" has a default value
RuleActivation activation = RuleActivation.create(rule.getUuid());
List<ActiveRuleChange> changes = activate(profile, activation);
db.getDbClient().activeRuleDao().deleteParametersByRuleProfileUuids(db.getSession(), asList(profile.getRulesProfileUuid()));
assertThatRuleIsActivated(profile, rule, changes, rule.getSeverityString(), null, emptyMap());
verify(qualityProfileChangeEventService).distributeRuleChangeEvent(any(), eq(changes), eq(profile.getLanguage()));
// contrary to activerule, the param is supposed to be inserted but not updated
RuleActivation updateActivation = RuleActivation.create(rule.getUuid(), null, of(param.getName(), ""));
changes = activate(profile, updateActivation);
assertThatRuleIsUpdated(profile, rule, rule.getSeverityString(), null, of(param.getName(), param.getDefaultValue()));
assertThat(changes).hasSize(1);
verify(qualityProfileChangeEventService).distributeRuleChangeEvent(any(), eq(changes), eq(profile.getLanguage()));
}
Aggregations