package com.company.license;
import org.drools.builder.*;
import org.drools.io.*;
import org.drools.runtime.*;
import org.drools.*;
public class ruletest
{
public ruletest(){}
public static void main(String args[])
{
ruletest rt = new ruletest();
rt.go();
}
public void go()
{
Applicant dude = new Applicant();
dude.setName("Rufus");
dude.setAge(32);
System.out.println(dude.getName());
System.out.println("test: "+dude.getValid());
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
Resource ruleResource = ResourceFactory.newClassPathResource( "Sample.drl", getClass() );
kbuilder.add( ruleResource, ResourceType.DRL );
if ( kbuilder.hasErrors() )
System.err.println( kbuilder.getErrors().toString() );
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
System.out.println( dude.getValid() ); //should display false
ksession.execute( dude );
if (dude.getValid())
System.out.println("Application approved"); //should display due to hardcoded as of 32
else
System.out.println("Application rejected");
}
}