Hi,
My requirement is to check for same field value from a list of items. in the
test case mentioned below, I want to verify that all the applicants are of
same age.
I am running the rule as mentioned below. The 'then' part does not execute.
Please suggest.
Thanks for your time.
public class Applicant {
private String name;
private int age;
private BigDecimal amount;
// getter and setters
}
rule "age"
when
$list : List();
forall( $app : Applicant( $age : age) from $list
Applicant( this == $app, age == $age ) );
then
System.out.println("success" );
end
// setting data in working memory
Applicant applicant1 = new Applicant("aaaa", 20, new BigDecimal(16.50));
Applicant applicant2 = new Applicant("aaaa", 20, new BigDecimal(16.50));
Applicant applicant3 = new Applicant("aaaa", 20, new BigDecimal(16.50));
List<Applicant> list = Arrays.asList(new Applicant[] { applicant1,
applicant2, applicant3 });
ksession.insert(list);
Regards,
Tushar
--
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/using-forall-to-valid...
Sent from the Drools - User mailing list archive at
Nabble.com.