[
https://issues.jboss.org/browse/DROOLS-1404?page=com.atlassian.jira.plugi...
]
Matteo Mortari commented on DROOLS-1404:
----------------------------------------
This issue was partially linked (not caused, not follow-up, simply in some forms of
relations) to:
* [DROOLS-588] as in: we want the expression character-wise-the-same but from different
package could evaluate differently and be aware of that (method
{{MvelConstraint.equals(Object object, InternalKnowledgeBase kbase)}} )
* [JBRULES-3658] ref test case in [
https://github.com/droolsjbpm/drools/commit/0a5659ccf5696176453ffabd7a617... ] as
in: we want to share the alpha node if their FieldValue evaluate to the same value
Attn: not only FieldValue(38) == FieldValue(37+1) but also in the test case above in this
ticket [DROOLS-1404] as: FieldValue(1) == FieldValue( TestStaticUtils.return1() )
which has been implemented as part of [JBRULES-3658]:
{code:java}
public boolean equals(final Object object) {
...
MvelConstraint other = (MvelConstraint) object;
- if (!expression.equals(other.expression)) {
- return false;
+ if (isAlphaHashable()) {
+ if ( !other.isAlphaHashable() ||
+
!getLeftForEqualExpression().equals(other.getLeftForEqualExpression()) ||
+ !fieldValue.equals(other.fieldValue) ) {
+ return false;
+ }
+ } else {
+ if (!expression.equals(other.expression)) {
+ return false;
+ }
}
{code}
Alpha node not shared with static function evaluation
-----------------------------------------------------
Key: DROOLS-1404
URL:
https://issues.jboss.org/browse/DROOLS-1404
Project: Drools
Issue Type: Bug
Components: core engine
Reporter: Matteo Mortari
Assignee: Matteo Mortari
The following code when placed in Misc2Test exhibit the problem
{code:java}
public static class TestStaticUtils {
public static int return1() {
return 1;
}
}
@Test
public void testCheck2() {
String drl = "package c;\n" + // <<- keep this package name
"\n" +
"import " + TestObject.class.getCanonicalName() +
"\n" +
"\n" +
"rule fileBrule1 when\n" +
" TestObject(value == 1)\n" +
"then\n" +
"end"
;
String drl2 = "package iTransiberian;\n" + // <<- keep this
package name
"\n" +
"import " + TestObject.class.getCanonicalName() +
"\n" +
"import " + TestStaticUtils.class.getCanonicalName() +
"\n" +
"\n" +
"rule fileArule1 when\n" +
" $t : String()\n" +
" TestObject(value == TestStaticUtils.return1() )\n" +
"then\n" +
"end\n"+
"rule fileArule2 when\n" + // <<- keep this rule
" $t : String()\n" +
" TestObject(value == 0 )\n" +
"then\n" +
"end\n" +
""
;
KieSession kieSession = new KieHelper()
.addContent(drl2, ResourceType.DRL)
.addContent(drl, ResourceType.DRL)
.build().newKieSession();
ReteDumper.dumpRete(kieSession);
System.out.println(drl);
System.out.println(drl2);
kieSession.addEventListener(new DebugAgendaEventListener());
kieSession.insert("test");
kieSession.insert(new TestObject(1));
assertEquals(2, kieSession.fireAllRules() );
}
{code}
Conducting further analysis...
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)