0
votes

I am trying to execute below rule in Drools through Talend

    rule "rule1"
    dialect "mvel"
    no-loop true
    when
        trans : row( BUS_AREA_CD == null )
    then

                trans.ACTUAL_PRODUCT_LINE_CODE="06" 

end
rule "rule2"
    dialect "mvel"
    no-loop true
    when
        trans : row( BUS_AREA_CD != null)
    then

                trans.ACTUAL_PRODUCT_LINE_CODE="96" 

end

Below is the data object(row) that I have created.

enter image description here

Below is the test scenario that I have executed

enter image description here

when I execute the test scenario with BUS_AREA_CD = null, it is returning blank value instead of "96".

Can someone help me to resolve this issue?

1
Where is the "blank value" returned and how do you see that? How's class row defined? What facts did you insert? - As it is, the answer is "no".laune
@laune I have updated the required information.Srinu Katta
Do you know that rule "rule1" really fired? What are the "4 rules fired in 1 ms"? Any chance that they might undo the change? -- Add a "throw" statement to the consequence of rule1, to demonstrate its firing if there's no other way. -- Use the modify statement to update WM for Drools.laune
rule1 did not fire at all. I have added rule 2 and add the screenshot of the test scenario.Please take a look.Srinu Katta
What is the code of class "row"? Add things like a System.out.println( trans.BUS_AREA_CD.length() ) to the second rule and see what happens. Read the documentation of the tool creating the "data object" row; maybe it adds code initializing strings to the null string.laune

1 Answers

0
votes

the problem of the Test Scenario you attached is that it assumes null as String value. If you want to crate instance of the row with the attribute BUS_AREA_CD equal to null then your GIVEN part should looks like this:

Insert 'row' [test]