Hi again,
I developed this test case
@Test
public void testBigDecimalCompareTo() {
String drl =
"import " + BigDecimal.class.getCanonicalName() + ";\n" +
"rule R1 when\n" +
" $bd1 : BigDecimal()\n" +
" $bd2 : BigDecimal( this.compareTo($bd1) > 0 )\n" +
"then \n" +
"end\n";
KieSession kieSession = new KieHelper().addContent( drl, ResourceType.DRL )
.build().newKieSession();
kieSession.insert(new BigDecimal( 1.0 ));
kieSession.insert(new BigDecimal( 2.0 ));
assertEquals( 1, kieSession.fireAllRules() );
}
and also this one that is more similar to your use case
@Test
public void testBigDecimalCompareTo2() {
String drl =
"import " + Mortgage.class.getCanonicalName() + ";\n" +
"import " + BigDecimal.class.getCanonicalName() + ";\n" +
"rule R1 when\n" +
" $mortgage: Mortgage()\n" +
" $anotherBigDecimal: BigDecimal() from $mortgage.amount\n" +
" BigDecimal( this.compareTo($anotherBigDecimal) > 0 )\n" +
"then \n" +
"end\n";
KieSession kieSession = new KieHelper().addContent( drl, ResourceType.DRL )
.build().newKieSession();
kieSession.insert(new Mortgage(new BigDecimal( 1.0 )));
kieSession.insert(new BigDecimal( 2.0 ));
assertEquals( 1, kieSession.fireAllRules() );
}
public static class Mortgage {
private final BigDecimal amount;
public Mortgage( BigDecimal amount ) {
this.amount = amount;
}
public BigDecimal getAmount() {
return amount;
}
}
and they both works for me.
If you still have this problem, please provide a complete reproducer so I could investigate it.