My quick example, allows the end-user, running "mvn test", to see that some aspects of his DRL really executed.
rule "Apply 50% discount to VIP customers"
when
$s: Sale( customer.type == CustomerType.VIP )
then
System.out.println("** VIP ** ");
$s.setDiscount(0.50);
System.out.println(" – 50% Discount Approved");
$s.setApproved(true);
end
rule "Apply no discount to Regular customers but approves the Sale"
when
$s: Sale( customer.type == CustomerType.REGULAR )
then
System.out.println("** Regular ** ");
$s.setApproved(true);
end
rule "Deny sales to BAD customers"
when
$s: Sale( customer.type == CustomerType.BAD )
then
System.out.println("** Bad Credit - DENIED ** ");
$s.setApproved(false);
end
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
My quick example, allows the end-user, running "mvn test", to see that some aspects of his DRL really executed.
rule "Apply 50% discount to VIP customers"
when
$s: Sale( customer.type == CustomerType.VIP )
then
System.out.println("** VIP ** ");
$s.setDiscount(0.50);
System.out.println(" – 50% Discount Approved");
$s.setApproved(true);
end
rule "Apply no discount to Regular customers but approves the Sale"
when
$s: Sale( customer.type == CustomerType.REGULAR )
then
System.out.println("** Regular ** ");
$s.setApproved(true);
end
rule "Deny sales to BAD customers"
when
$s: Sale( customer.type == CustomerType.BAD )
then
System.out.println("** Bad Credit - DENIED ** ");
$s.setApproved(false);
end