[rules-users] Driving License application

seyfullah seyfullahtikic at outlook.com
Tue Dec 24 04:34:30 EST 2013


Ok, I changed my drl file and main method as follows, and it works. Thank
you.

package MyPackage

import MyPackage.Applicant;

rule "Is of not valid age"
when
	$a : Applicant( age < 18 )
then
	$a.setValid ( false );
end

rule "Is of valid age"
when
	$a : Applicant( age > 17 )
then
	$a.setValid ( true );
end


		KieServices kieServices = KieServices.Factory.get();
		KieContainer kContainer = kieServices.getKieClasspathContainer();
		StatelessKieSession kSession = kContainer.newStatelessKieSession();
		
		Applicant applicant = new Applicant("Mr John Smith", 16);
		assertFalse( applicant.isValid() );
		kSession.execute( applicant ) ;
		assertFalse ( applicant.isValid() );	
		
		Applicant applicant2 = new Applicant("Mr Bill Wayne", 22);
		assertFalse( applicant2.isValid() );
		kSession.execute( applicant2 ) ;
		assertTrue ( applicant2.isValid() );	




--
View this message in context: http://drools.46999.n3.nabble.com/Driving-License-application-tp4027403p4027407.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list