public void system_activates_rule_without_parameters() {
RuleDefinitionDto rule = createRule();
QProfileDto profile = createProfile(rule);
- RuleActivation activation = RuleActivation.create(rule.getKey(), BLOCKER, null);
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey(), BLOCKER, null);
List<ActiveRuleChange> changes = activate(profile, activation);
assertThatRuleIsActivated(profile, rule, changes, BLOCKER, null, emptyMap());
userSession.logIn();
RuleDefinitionDto rule = createRule();
QProfileDto profile = createProfile(rule);
- RuleActivation activation = RuleActivation.create(rule.getKey(), BLOCKER, null);
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey(), BLOCKER, null);
List<ActiveRuleChange> changes = activate(profile, activation);
assertThatRuleIsActivated(profile, rule, changes, BLOCKER, null, emptyMap());
RuleParamDto ruleParam = db.rules().insertRuleParam(rule, p -> p.setName("min").setDefaultValue("10"));
QProfileDto profile = createProfile(rule);
- RuleActivation activation = RuleActivation.create(rule.getKey());
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey());
List<ActiveRuleChange> changes = activate(profile, activation);
assertThatRuleIsActivated(profile, rule, changes, rule.getSeverityString(), null, of("min", "10"));
RuleParamDto ruleParam = db.rules().insertRuleParam(rule, p -> p.setName("min").setDefaultValue("10"));
QProfileDto profile = createProfile(rule);
- RuleActivation activation = RuleActivation.create(rule.getKey(), null, of(ruleParam.getName(), "15"));
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey(), null, of(ruleParam.getName(), "15"));
List<ActiveRuleChange> changes = activate(profile, activation);
assertThatRuleIsActivated(profile, rule, changes, rule.getSeverityString(), null, of("min", "15"));
RuleDefinitionDto rule = createRule();
QProfileDto profile = createProfile(rule);
- RuleActivation activation = RuleActivation.create(rule.getKey());
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey());
List<ActiveRuleChange> changes = activate(profile, activation);
assertThatRuleIsActivated(profile, rule, changes, rule.getSeverityString(), null, emptyMap());
RuleParamDto ruleParam = db.rules().insertRuleParam(rule, p -> p.setName("min").setDefaultValue("10"));
QProfileDto profile = createProfile(rule);
- RuleActivation activation = RuleActivation.create(rule.getKey(), null, of("min", ""));
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey(), null, of("min", ""));
List<ActiveRuleChange> changes = activate(profile, activation);
assertThatRuleIsActivated(profile, rule, changes, rule.getSeverityString(), null, of("min", "10"));
RuleParamDto paramWithDefault = db.rules().insertRuleParam(rule, p -> p.setName("max").setDefaultValue("10"));
QProfileDto profile = createProfile(rule);
- RuleActivation activation = RuleActivation.create(rule.getKey(), null, of(paramWithoutDefault.getName(), "-10"));
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey(), null, of(paramWithoutDefault.getName(), "-10"));
List<ActiveRuleChange> changes = activate(profile, activation);
assertThatRuleIsActivated(profile, rule, changes, rule.getSeverityString(), null,
RuleParamDto param = db.rules().insertRuleParam(rule, p -> p.setName("max").setDefaultValue("10"));
QProfileDto profile = createProfile(rule);
- RuleActivation activation = RuleActivation.create(rule.getKey(), null, of("xxx", "yyy"));
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey(), null, of("xxx", "yyy"));
List<ActiveRuleChange> changes = activate(profile, activation);
assertThatRuleIsActivated(profile, rule, changes, rule.getSeverityString(), null, of(param.getName(), param.getDefaultValue()));
QProfileDto profile = createProfile(rule);
// initial activation
- RuleActivation activation = RuleActivation.create(rule.getKey(), MAJOR, null);
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey(), MAJOR, null);
activate(profile, activation);
// update
- RuleActivation updateActivation = RuleActivation.create(rule.getKey(), CRITICAL, of(param.getName(), "20"));
+ RuleActivation updateActivation = RuleActivation.create(rule.getId(), rule.getKey(), CRITICAL, of(param.getName(), "20"));
List<ActiveRuleChange> changes = activate(profile, updateActivation);
assertThatRuleIsUpdated(profile, rule, CRITICAL, null, of(param.getName(), "20"));
QProfileDto profile = createProfile(rule);
// initial activation -> param "max" has a default value
- RuleActivation activation = RuleActivation.create(rule.getKey());
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey());
activate(profile, activation);
// update param "min", which has no default value
- RuleActivation updateActivation = RuleActivation.create(rule.getKey(), MAJOR, of(paramWithoutDefault.getName(), "3"));
+ RuleActivation updateActivation = RuleActivation.create(rule.getId(), rule.getKey(), MAJOR, of(paramWithoutDefault.getName(), "3"));
List<ActiveRuleChange> changes = activate(profile, updateActivation);
assertThatRuleIsUpdated(profile, rule, MAJOR, null, of(paramWithDefault.getName(), "10", paramWithoutDefault.getName(), "3"));
QProfileDto profile = createProfile(rule);
// initial activation -> param "max" has a default value
- RuleActivation activation = RuleActivation.create(rule.getKey(), null, of(paramWithDefault.getName(), "20"));
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey(), null, of(paramWithDefault.getName(), "20"));
activate(profile, activation);
// reset to default_value
- RuleActivation updateActivation = RuleActivation.create(rule.getKey(), null, of(paramWithDefault.getName(), ""));
+ RuleActivation updateActivation = RuleActivation.create(rule.getId(), rule.getKey(), null, of(paramWithDefault.getName(), ""));
List<ActiveRuleChange> changes = activate(profile, updateActivation);
assertThatRuleIsUpdated(profile, rule, rule.getSeverityString(), null, of(paramWithDefault.getName(), "10"));
QProfileDto profile = createProfile(rule);
// initial activation -> param "max" has a default value
- RuleActivation activation = RuleActivation.create(rule.getKey(), null, of(paramWithoutDefault.getName(), "20"));
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey(), null, of(paramWithoutDefault.getName(), "20"));
activate(profile, activation);
// remove parameter
- RuleActivation updateActivation = RuleActivation.create(rule.getKey(), null, of(paramWithoutDefault.getName(), ""));
+ RuleActivation updateActivation = RuleActivation.create(rule.getId(), rule.getKey(), null, of(paramWithoutDefault.getName(), ""));
List<ActiveRuleChange> changes = activate(profile, updateActivation);
assertThatRuleIsUpdated(profile, rule, rule.getSeverityString(), null, of(paramWithDefault.getName(), paramWithDefault.getDefaultValue()));
QProfileDto profile = createProfile(rule);
// initial activation -> param "max" has a default value
- RuleActivation activation = RuleActivation.create(rule.getKey());
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey());
List<ActiveRuleChange> changes = activate(profile, activation);
db.getDbClient().activeRuleDao().deleteParametersByRuleProfileUuids(db.getSession(), asList(profile.getRulesProfileUuid()));
assertThatRuleIsActivated(profile, rule, changes, rule.getSeverityString(), null, emptyMap());
// contrary to activerule, the param is supposed to be inserted but not updated
- RuleActivation updateActivation = RuleActivation.create(rule.getKey(), null, of(param.getName(), ""));
+ RuleActivation updateActivation = RuleActivation.create(rule.getId(), rule.getKey(), null, of(param.getName(), ""));
changes = activate(profile, updateActivation);
assertThatRuleIsUpdated(profile, rule, rule.getSeverityString(), null, of(param.getName(), param.getDefaultValue()));
QProfileDto profile = createProfile(rule);
// initial activation
- RuleActivation activation = RuleActivation.create(rule.getKey());
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey());
activate(profile, activation);
// update with exactly the same severity and params
- activation = RuleActivation.create(rule.getKey());
+ activation = RuleActivation.create(rule.getId(), rule.getKey());
List<ActiveRuleChange> changes = activate(profile, activation);
assertThat(changes).isEmpty();
QProfileDto profile = createProfile(rule);
// initial activation -> param "max" has a default value
- RuleActivation activation = RuleActivation.create(rule.getKey(), BLOCKER, of(param.getName(), "20"));
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey(), BLOCKER, of(param.getName(), "20"));
activate(profile, activation);
// update without any severity or params => keep
- RuleActivation update = RuleActivation.create(rule.getKey());
+ RuleActivation update = RuleActivation.create(rule.getId(), rule.getKey());
List<ActiveRuleChange> changes = activate(profile, update);
assertThat(changes).isEmpty();
RuleDefinitionDto rule = createRule();
QProfileDto profile = createProfile(rule);
RuleKey ruleKey = RuleKey.parse("unknown:xxx");
- RuleActivation activation = RuleActivation.create(ruleKey);
+ RuleActivation activation = RuleActivation.create(rule.getId(), ruleKey);
expectFailure("Rule not found: " + ruleKey, () -> activate(profile, activation));
}
public void fail_to_activate_rule_if_profile_is_on_different_languages() {
RuleDefinitionDto rule = createJavaRule();
QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage("js"));
- RuleActivation activation = RuleActivation.create(rule.getKey());
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey());
expectFailure("java rule " + rule.getKey() + " cannot be activated on js profile " + profile.getKee(), () -> activate(profile, activation));
}
public void fail_to_activate_rule_if_rule_has_REMOVED_status() {
RuleDefinitionDto rule = db.rules().insert(r -> r.setStatus(RuleStatus.REMOVED));
QProfileDto profile = createProfile(rule);
- RuleActivation activation = RuleActivation.create(rule.getKey());
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey());
expectFailure("Rule was removed: " + rule.getKey(), () -> activate(profile, activation));
}
public void fail_to_activate_if_template() {
RuleDefinitionDto rule = db.rules().insert(r -> r.setIsTemplate(true));
QProfileDto profile = createProfile(rule);
- RuleActivation activation = RuleActivation.create(rule.getKey());
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey());
expectFailure("Rule template can't be activated on a Quality profile: " + rule.getKey(), () -> activate(profile, activation));
}
RuleParamDto param = db.rules().insertRuleParam(rule, p -> p.setName("max").setDefaultValue("10").setType(PropertyType.INTEGER.name()));
QProfileDto profile = createProfile(rule);
- RuleActivation activation = RuleActivation.create(rule.getKey(), null, of(param.getName(), "foo"));
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey(), null, of(param.getName(), "foo"));
expectFailure("Value 'foo' must be an integer.", () -> activate(profile, activation));
}
QProfileDto profile = createProfile(customRule);
// initial activation
- RuleActivation activation = RuleActivation.create(customRule.getKey(), MAJOR, emptyMap());
+ RuleActivation activation = RuleActivation.create(customRule.getId(), customRule.getKey(), MAJOR, emptyMap());
activate(profile, activation);
assertThatRuleIsActivated(profile, customRule, null, MAJOR, null, of("format", "txt"));
// update -> parameter is not changed
- RuleActivation updateActivation = RuleActivation.create(customRule.getKey(), BLOCKER, of("format", "xml"));
+ RuleActivation updateActivation = RuleActivation.create(customRule.getId(), customRule.getKey(), BLOCKER, of("format", "xml"));
activate(profile, updateActivation);
assertThatRuleIsActivated(profile, customRule, null, BLOCKER, null, of("format", "txt"));
}
userSession.logIn();
RuleDefinitionDto rule = createRule();
QProfileDto profile = createProfile(rule);
- RuleActivation activation = RuleActivation.create(rule.getKey());
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey());
activate(profile, activation);
List<ActiveRuleChange> changes = deactivate(profile, rule);
public void system_deactivates_a_rule() {
RuleDefinitionDto rule = createRule();
QProfileDto profile = createProfile(rule);
- RuleActivation activation = RuleActivation.create(rule.getKey());
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey());
activate(profile, activation);
List<ActiveRuleChange> changes = deactivate(profile, rule);
public void deactivate_rule_that_has_REMOVED_status() {
RuleDefinitionDto rule = createRule();
QProfileDto profile = createProfile(rule);
- RuleActivation activation = RuleActivation.create(rule.getKey());
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey());
activate(profile, activation);
rule.setStatus(RuleStatus.REMOVED);
QProfileDto childProfile = createChildProfile(parentProfile);
QProfileDto grandChildProfile = createChildProfile(childProfile);
- List<ActiveRuleChange> changes = activate(childProfile, RuleActivation.create(rule.getKey()));
+ List<ActiveRuleChange> changes = activate(childProfile, RuleActivation.create(rule.getId(), rule.getKey()));
assertThatProfileHasNoActiveRules(parentProfile);
assertThatRuleIsActivated(childProfile, rule, changes, rule.getSeverityString(), null, emptyMap());
assertThatRuleIsActivated(grandChildProfile, rule, changes, rule.getSeverityString(), INHERITED, emptyMap());
QProfileDto childProfile = createChildProfile(parentProfile);
QProfileDto grandChildProfile = createChildProfile(childProfile);
- RuleActivation initialActivation = RuleActivation.create(rule.getKey(), MAJOR, of(param.getName(), "foo"));
+ RuleActivation initialActivation = RuleActivation.create(rule.getId(), rule.getKey(), MAJOR, of(param.getName(), "foo"));
activate(childProfile, initialActivation);
- RuleActivation updateActivation = RuleActivation.create(rule.getKey(), CRITICAL, of(param.getName(), "bar"));
+ RuleActivation updateActivation = RuleActivation.create(rule.getId(), rule.getKey(), CRITICAL, of(param.getName(), "bar"));
List<ActiveRuleChange> changes = activate(childProfile, updateActivation);
assertThatProfileHasNoActiveRules(parentProfile);
QProfileDto childProfile = createChildProfile(parentProfile);
QProfileDto grandChildProfile = createChildProfile(childProfile);
- RuleActivation initialActivation = RuleActivation.create(rule.getKey(), MAJOR, of(param.getName(), "foo"));
+ RuleActivation initialActivation = RuleActivation.create(rule.getId(), rule.getKey(), MAJOR, of(param.getName(), "foo"));
activate(childProfile, initialActivation);
- RuleActivation overrideActivation = RuleActivation.create(rule.getKey(), CRITICAL, of(param.getName(), "bar"));
+ RuleActivation overrideActivation = RuleActivation.create(rule.getId(), rule.getKey(), CRITICAL, of(param.getName(), "bar"));
List<ActiveRuleChange> changes = activate(grandChildProfile, overrideActivation);
assertThatProfileHasNoActiveRules(parentProfile);
QProfileDto childProfile = createChildProfile(parentProfile);
QProfileDto grandChildProfile = createChildProfile(childProfile);
- RuleActivation initialActivation = RuleActivation.create(rule.getKey(), MAJOR, of(param.getName(), "foo"));
+ RuleActivation initialActivation = RuleActivation.create(rule.getId(), rule.getKey(), MAJOR, of(param.getName(), "foo"));
activate(childProfile, initialActivation);
- RuleActivation overrideActivation = RuleActivation.create(rule.getKey(), CRITICAL, of(param.getName(), "bar"));
+ RuleActivation overrideActivation = RuleActivation.create(rule.getId(), rule.getKey(), CRITICAL, of(param.getName(), "bar"));
activate(grandChildProfile, overrideActivation);
// update child --> do not touch grandChild
- RuleActivation updateActivation = RuleActivation.create(rule.getKey(), BLOCKER, of(param.getName(), "baz"));
+ RuleActivation updateActivation = RuleActivation.create(rule.getId(), rule.getKey(), BLOCKER, of(param.getName(), "baz"));
List<ActiveRuleChange> changes = activate(childProfile, updateActivation);
assertThatProfileHasNoActiveRules(parentProfile);
QProfileDto childProfile = createChildProfile(parentProfile);
QProfileDto grandChildProfile = createChildProfile(childProfile);
- RuleActivation initialActivation = RuleActivation.create(rule.getKey(), MAJOR, of(param.getName(), "foo"));
+ RuleActivation initialActivation = RuleActivation.create(rule.getId(), rule.getKey(), MAJOR, of(param.getName(), "foo"));
activate(parentProfile, initialActivation);
- RuleActivation overrideActivation = RuleActivation.create(rule.getKey(), CRITICAL, of(param.getName(), "bar"));
+ RuleActivation overrideActivation = RuleActivation.create(rule.getId(), rule.getKey(), CRITICAL, of(param.getName(), "bar"));
activate(grandChildProfile, overrideActivation);
// reset parent --> touch child but not grandChild
- RuleActivation updateActivation = RuleActivation.createReset(rule.getKey());
+ RuleActivation updateActivation = RuleActivation.createReset(rule.getId(), rule.getKey());
List<ActiveRuleChange> changes = activate(parentProfile, updateActivation);
assertThatRuleIsUpdated(parentProfile, rule, rule.getSeverityString(), null, of(param.getName(), param.getDefaultValue()));
QProfileDto parentProfile = createProfile(rule);
QProfileDto childProfile = createChildProfile(parentProfile);
- RuleActivation childActivation = RuleActivation.create(rule.getKey(), MAJOR, of(param.getName(), "foo"));
+ RuleActivation childActivation = RuleActivation.create(rule.getId(), rule.getKey(), MAJOR, of(param.getName(), "foo"));
activate(childProfile, childActivation);
- RuleActivation parentActivation = RuleActivation.create(rule.getKey(), CRITICAL, of(param.getName(), "bar"));
+ RuleActivation parentActivation = RuleActivation.create(rule.getId(), rule.getKey(), CRITICAL, of(param.getName(), "bar"));
List<ActiveRuleChange> changes = activate(parentProfile, parentActivation);
assertThatRuleIsUpdated(parentProfile, rule, CRITICAL, null, of(param.getName(), "bar"));
QProfileDto parentProfile = createProfile(rule);
QProfileDto childProfile = createChildProfile(parentProfile);
- RuleActivation parentActivation = RuleActivation.create(rule.getKey(), MAJOR, of(param.getName(), "foo"));
+ RuleActivation parentActivation = RuleActivation.create(rule.getId(), rule.getKey(), MAJOR, of(param.getName(), "foo"));
activate(parentProfile, parentActivation);
- RuleActivation overrideActivation = RuleActivation.create(rule.getKey(), MAJOR, of(param.getName(), "foo"));
+ RuleActivation overrideActivation = RuleActivation.create(rule.getId(), rule.getKey(), MAJOR, of(param.getName(), "foo"));
List<ActiveRuleChange> changes = activate(childProfile, overrideActivation);
assertThatRuleIsUpdated(childProfile, rule, MAJOR, INHERITED, of(param.getName(), "foo"));
QProfileDto parentProfile = createProfile(rule);
QProfileDto childProfile = createChildProfile(parentProfile);
- RuleActivation activation = RuleActivation.create(rule.getKey());
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey());
List<ActiveRuleChange> changes = activate(parentProfile, activation);
assertThatRuleIsActivated(parentProfile, rule, changes, rule.getSeverityString(), null, emptyMap());
assertThatRuleIsActivated(childProfile, rule, changes, rule.getSeverityString(), INHERITED, emptyMap());
QProfileDto parentProfile = createProfile(rule);
QProfileDto childProfile = createChildProfile(parentProfile);
- RuleActivation activation = RuleActivation.create(rule.getKey());
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey());
List<ActiveRuleChange> changes = activate(parentProfile, activation);
assertThatRuleIsActivated(parentProfile, rule, changes, rule.getSeverityString(), null, emptyMap());
assertThatRuleIsActivated(childProfile, rule, changes, rule.getSeverityString(), INHERITED, emptyMap());
- activation = RuleActivation.create(rule.getKey(), CRITICAL, null);
+ activation = RuleActivation.create(rule.getId(), rule.getKey(), CRITICAL, null);
activate(childProfile, activation);
changes = deactivate(parentProfile, rule);
QProfileDto parentProfile = createProfile(rule);
QProfileDto childProfile = createChildProfile(parentProfile);
- RuleActivation activation = RuleActivation.create(rule.getKey());
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey());
List<ActiveRuleChange> changes = activate(parentProfile, activation);
assertThatRuleIsActivated(parentProfile, rule, changes, rule.getSeverityString(), null, emptyMap());
assertThatRuleIsActivated(childProfile, rule, changes, rule.getSeverityString(), INHERITED, emptyMap());
QProfileDto parentProfile = createProfile(rule);
QProfileDto childProfile = createChildProfile(parentProfile);
- RuleActivation activation = RuleActivation.create(rule.getKey(), CRITICAL, null);
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey(), CRITICAL, null);
List<ActiveRuleChange> changes = activate(parentProfile, activation);
assertThatRuleIsActivated(parentProfile, rule, changes, CRITICAL, null, emptyMap());
assertThatRuleIsActivated(childProfile, rule, changes, CRITICAL, INHERITED, emptyMap());
assertThat(changes).hasSize(2);
- RuleActivation childActivation = RuleActivation.create(rule.getKey(), BLOCKER, null);
+ RuleActivation childActivation = RuleActivation.create(rule.getId(), rule.getKey(), BLOCKER, null);
changes = activate(childProfile, childActivation);
assertThatRuleIsUpdated(childProfile, rule, BLOCKER, ActiveRule.Inheritance.OVERRIDES, emptyMap());
assertThat(changes).hasSize(1);
- RuleActivation resetActivation = RuleActivation.createReset(rule.getKey());
+ RuleActivation resetActivation = RuleActivation.createReset(rule.getId(), rule.getKey());
changes = activate(childProfile, resetActivation);
assertThatRuleIsUpdated(childProfile, rule, CRITICAL, INHERITED, emptyMap());
assertThatRuleIsUpdated(parentProfile, rule, CRITICAL, null, emptyMap());
QProfileDto childProfile = createChildProfile(baseProfile);
QProfileDto grandChildProfile = createChildProfile(childProfile);
- RuleActivation activation = RuleActivation.create(rule.getKey(), CRITICAL, null);
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey(), CRITICAL, null);
List<ActiveRuleChange> changes = activate(baseProfile, activation);
assertThatRuleIsActivated(baseProfile, rule, changes, CRITICAL, null, emptyMap());
assertThatRuleIsActivated(childProfile, rule, changes, CRITICAL, INHERITED, emptyMap());
assertThatRuleIsActivated(grandChildProfile, rule, changes, CRITICAL, INHERITED, emptyMap());
assertThat(changes).hasSize(3);
- RuleActivation childActivation = RuleActivation.create(rule.getKey(), BLOCKER, null);
+ RuleActivation childActivation = RuleActivation.create(rule.getId(), rule.getKey(), BLOCKER, null);
changes = activate(childProfile, childActivation);
assertThatRuleIsUpdated(childProfile, rule, BLOCKER, ActiveRule.Inheritance.OVERRIDES, emptyMap());
assertThatRuleIsUpdated(grandChildProfile, rule, BLOCKER, INHERITED, emptyMap());
assertThat(changes).hasSize(2);
// Reset on parent do not change child nor grandchild
- RuleActivation resetActivation = RuleActivation.createReset(rule.getKey());
+ RuleActivation resetActivation = RuleActivation.createReset(rule.getId(), rule.getKey());
changes = activate(baseProfile, resetActivation);
assertThatRuleIsUpdated(baseProfile, rule, rule.getSeverityString(), null, emptyMap());
assertThatRuleIsUpdated(childProfile, rule, BLOCKER, ActiveRule.Inheritance.OVERRIDES, emptyMap());
assertThat(changes).hasSize(1);
// Reset on child change grandchild
- resetActivation = RuleActivation.createReset(rule.getKey());
+ resetActivation = RuleActivation.createReset(rule.getId(), rule.getKey());
changes = activate(childProfile, resetActivation);
assertThatRuleIsUpdated(baseProfile, rule, rule.getSeverityString(), null, emptyMap());
assertThatRuleIsUpdated(childProfile, rule, rule.getSeverityString(), INHERITED, emptyMap());
QProfileDto parentProfile = createProfile(rule);
QProfileDto childProfile = createChildProfile(parentProfile);
- RuleActivation resetActivation = RuleActivation.createReset(rule.getKey());
+ RuleActivation resetActivation = RuleActivation.createReset(rule.getId(), rule.getKey());
List<ActiveRuleChange> changes = activate(parentProfile, resetActivation);
verifyNoActiveRules();
assertThat(changes).hasSize(0);
QProfileDto parentProfile = createProfile(rule);
QProfileDto childProfile = createChildProfile(parentProfile);
- List<ActiveRuleChange> changes = activate(parentProfile, RuleActivation.create(rule.getKey()));
+ List<ActiveRuleChange> changes = activate(parentProfile, RuleActivation.create(rule.getId(), rule.getKey()));
assertThatRuleIsActivated(parentProfile, rule, null, rule.getSeverityString(), null, emptyMap());
assertThatRuleIsActivated(childProfile, rule, null, rule.getSeverityString(), INHERITED, emptyMap());
QProfileDto childProfile = createChildProfile(parentProfile);
QProfileDto grandchildProfile = createChildProfile(childProfile);
- activate(parentProfile, RuleActivation.create(rule1.getKey()));
- activate(parentProfile, RuleActivation.create(rule2.getKey()));
+ activate(parentProfile, RuleActivation.create(rule1.getId(), rule1.getKey()));
+ activate(parentProfile, RuleActivation.create(rule2.getId(), rule2.getKey()));
ruleIndexer.indexOnStartup(ruleIndexer.getIndexTypes());
QProfileDto childProfile = createChildProfile(parentProfile);
QProfileDto grandChildProfile = createChildProfile(childProfile);
- RuleActivation activation = RuleActivation.create(rule.getKey(), CRITICAL, null);
+ RuleActivation activation = RuleActivation.create(rule.getId(), rule.getKey(), CRITICAL, null);
activate(parentProfile, activation);
- RuleActivation overrideActivation = RuleActivation.create(rule.getKey(), BLOCKER, null);
+ RuleActivation overrideActivation = RuleActivation.create(rule.getId(), rule.getKey(), BLOCKER, null);
activate(grandChildProfile, overrideActivation);
// Reset on parent do not change child nor grandchild
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("The built-in profile " + builtInProfile.getName() + " is read-only and can't be updated");
- underTest.activateAndCommit(db.getSession(), builtInProfile, singleton(RuleActivation.create(rule.getKey())));
+ underTest.activateAndCommit(db.getSession(), builtInProfile, singleton(RuleActivation.create(rule.getId(), rule.getKey())));
}
private void assertThatProfileHasNoActiveRules(QProfileDto profile) {