I have a whole bunch of rules and I am trying to write some unit tests for them. In my tests, I am using this:
int rulesFired = kSession.fireAllRules(new RuleNameEqualsAgendaFilter("rule name 1"));
The thing I have noticed is that although the amount of rules fired returned is 1, Drools still tries to validate against any other rule where the conditions are met. I sometimes receive error messages from other rules that are not defined in my rule name equals agenda filter because the conditions match based on what I am inserting in my kSession for the unit test.
For example I have:
rule "test1"
when
$var : Map(this["key"] == "gold")
then
do something
end
rule "test2"
when
$var : Map(this["key"] == "gold" && this["other"] == "silver")
then
do something
end
and in my test for rule1 I have a map with just "key". When I run the test with a filter for "test1", I will receive a null pointer because I do not have a value for "other" in my map, even though the rule I am filtering for does not care about "other"
Why does this happen? I can't find any documentation on it anywhere. It's as if Drools has to validate all the rules and syntax in my DRL file before filtering.
Aucun commentaire:
Enregistrer un commentaire