The problem is that you are inserting the fact type definition instead of
the facts themselves.
instead of insert *appType* and *incomeType* you should insert *application*and
*income*.
Best Regards,
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Esteban Aliverti
- Blog @
On Mon, Jul 16, 2012 at 3:20 PM, Wolfgang Laun <wolfgang.laun(a)gmail.com>wrote:
Why do you think that you should have a third fact when there are no
insert() calls except the two in your Java code?
-W
On 16/07/2012, Ravikiran <ravikiran.kakarla(a)gmail.com> wrote:
> 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-no...
> Sent from the Drools: User forum mailing list archive at
Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users