[rules-users] Drools Guvnor-Decison Tables - Rule is not being fired!!! Please help

Ravikiran ravikiran.kakarla at gmail.com
Mon Jul 16 08:14:05 EDT 2012


Hi,
I'm using default Guvnor package "mortgages" decision table as example for
my POC. Below is the rules from the decision table. No rule is being fired
from my JAVA client out of 3 rules given below.

//from row number: 1
rule "Row 3 Pricing loans"
	dialect "mvel"
	when
	             application : LoanApplication( amount > "131000" , amount <=
"200000" , lengthYears == "30" , deposit < "20000" )
		income : IncomeSource( type == "Asset" )
	then
		application.setApproved( true );
		application.setInsuranceCost( 0 );
		application.setApprovedRate( 2 );
end

//from row number: 2
rule "Row 1 Pricing loans"
	dialect "mvel"
	when
		application : LoanApplication( amount > "10000" , amount <= "100000" ,
lengthYears == "20" , deposit < "2000" )
		income : IncomeSource( type == "Job" )
	then
		application.setApproved( true );
		application.setInsuranceCost( 0 );
		application.setApprovedRate( 4 );
end

//from row number: 3
rule "Row 2 Pricing loans"
	dialect "mvel"
	when
		application : LoanApplication( amount > "100001" , amount <= "130000" ,
lengthYears == "20" , deposit < "3000" )
		income : IncomeSource( type == "Job" )
	then
		application.setApproved( true );
		application.setInsuranceCost( 10 );
		application.setApprovedRate( 6 );
end

==> My Java client follows
KnowledgeBase knowledgeBase = createKnowledgeBase(); //Successfully creates
knowledgebase
StatefulKnowledgeSession session =
knowledgeBase.newStatefulKnowledgeSession();

        FactType appType = knowledgeBase.getFactType( "mortgages",
"LoanApplication" );
        FactType incomeType = knowledgeBase.getFactType( "mortgages",
"IncomeSource" );

        Object application = appType.newInstance();
        Object income = incomeType.newInstance();

        appType.set(application, "amount", 100000);
        appType.set(application, "deposit", 1500);
        appType.set(application, "lengthYears", 20);

        incomeType.set(income, "type", "Job");
        incomeType.set(income, "amount", 65000);

        session.insert(appType);
        session.insert(incomeType);

        assertTrue(session.getFactCount() == 2);
        session.fireAllRules();
        assertTrue(session.getFactCount() == 3);

Question: I hope the way i pass the input satisfies "Row 2 Pricing loans"
above. But My assertion is getting failed after calling
fireAllRules()...because the factcount was still 2. Please help what could
be the wrong in above scenario.

thanks a lot.

--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Guvnor-Decison-Tables-Rule-is-not-being-fired-Please-help-tp4018701.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list