Reputation: 787
I want to do rule verification using declared types. I have two declared types:
declare QoS
time : int
end
declare QoSThreshold
time : int
end
If I write this rule:
rule "Time"
when
$qosThreshold : QoSThreshold()
$qos : QoS(time < 2 )
then
update($qos);
end
I get the expected problem:
Gap: (Field 'time' from object type 'QoS') Operator = '>=' 2 from rule: [Time]
However, if I rewrite the rules as:
rule "Time"
when
$qosThreshold : QoSThreshold()
$qos : QoS(time < $qosThreshold.time )
then
update($qos);
end
I don't get any errors.
Do you know why?
PD: I'm just doing a simple example based on the code we can fin in page 24 of this tutorial or in the Drools Verifier page
Upvotes: 1
Views: 64
Reputation: 31290
In the first case, the verification alerts you to the circumstance that there is no rule covering the case where Qos.time >= 2
, which the verifier can deduct from seeing the constant (2
) in the constraint.
In the second case, the verifier cannot make such a statement since the other value is variable. It might say that it is possible (or even: certain) that some values aren't covered, but the designer of the Verifier has decided not to do so.
Automatic verification of a set of rules is a very iffy matter - it might tell you something useful in simple cases. But note what happens in your second example. (No doubt that the Verifier operates by rules, and you might very well ask whether the Verifier has been able to verify itself, and what came of it.)
Upvotes: 1