RuleActivation activation = new RuleActivation(RuleTesting.XOO_X1);
activation.setSeverity(Severity.BLOCKER);
activation.setParameter("max", "7");
+ activation.setParameter("min", "3");
List<ActiveRuleChange> changes = ruleActivator.activate(dbSession, activation, XOO_P1_KEY);
dbSession.commit();
dbSession.clearCache();
assertThat(countActiveRules(XOO_P1_KEY)).isEqualTo(1);
- verifyHasActiveRule(ActiveRuleKey.of(XOO_P1_KEY, RuleTesting.XOO_X1), Severity.BLOCKER, null, ImmutableMap.of("max", "7"));
+ verifyHasActiveRule(ActiveRuleKey.of(XOO_P1_KEY, RuleTesting.XOO_X1), Severity.BLOCKER, null,
+ ImmutableMap.of("max", "7", "min", "3"));
assertThat(changes).hasSize(1);
assertThat(changes.get(0).getType()).isEqualTo(ActiveRuleChange.Type.ACTIVATED);
}
activate(new RuleActivation(RuleTesting.XOO_X1), XOO_P1_KEY);
assertThat(countActiveRules(XOO_P1_KEY)).isEqualTo(1);
- verifyHasActiveRule(ActiveRuleKey.of(XOO_P1_KEY, RuleTesting.XOO_X1), Severity.MINOR, null, ImmutableMap.of("max", "10"));
+ verifyHasActiveRule(ActiveRuleKey.of(XOO_P1_KEY, RuleTesting.XOO_X1), Severity.MINOR, null,
+ ImmutableMap.of("max", "10"));
}
@Test
}
@Test
- @Ignore
public void update_activation_with_parameter_without_default_value() throws Exception {
- // initial activation
+ // initial activation -> param "max" has a default value
RuleActivation activation = new RuleActivation(RuleTesting.XOO_X1);
activation.setSeverity(Severity.BLOCKER);
activate(activation, XOO_P1_KEY);
+ verifyHasActiveRule(ActiveRuleKey.of(XOO_P1_KEY, RuleTesting.XOO_X1), Severity.BLOCKER, null,
+ ImmutableMap.of("max", "10"));
- // update
+ // update param "min", which has no default value
RuleActivation update = new RuleActivation(RuleTesting.XOO_X1);
- // parameter min has no default value
- update.setParameter("min", "42");
+ update.setParameter("min", "3");
List<ActiveRuleChange> changes = activate(update, XOO_P1_KEY);
-
assertThat(countActiveRules(XOO_P1_KEY)).isEqualTo(1);
- verifyHasActiveRule(ActiveRuleKey.of(XOO_P1_KEY, RuleTesting.XOO_X1), Severity.BLOCKER, null, ImmutableMap.of("min", "42"));
+ verifyHasActiveRule(ActiveRuleKey.of(XOO_P1_KEY, RuleTesting.XOO_X1), Severity.BLOCKER, null,
+ ImmutableMap.of("min", "3", "max", "10"));
assertThat(changes).hasSize(1);
assertThat(changes.get(0).getType()).isEqualTo(ActiveRuleChange.Type.UPDATED);
}