[JBoss JIRA] (JBRULES-2800) Issue with literals in Drools Verifier 5.1.1
by Toni Rikkola (Jira)
[ https://issues.jboss.org/browse/JBRULES-2800?page=com.atlassian.jira.plug... ]
Toni Rikkola updated JBRULES-2800:
----------------------------------
Labels: verifier (was: )
> Issue with literals in Drools Verifier 5.1.1
> --------------------------------------------
>
> Key: JBRULES-2800
> URL: https://issues.jboss.org/browse/JBRULES-2800
> Project: JBRULES
> Issue Type: Bug
> Components: drools-verifier
> Affects Versions: 5.1.1.FINAL
> Reporter: Nathan Bell
> Assignee: Toni Rikkola
> Priority: Minor
> Labels: verifier
> Fix For: 5.2.1.Final
>
> Attachments: JBRULES-2800-testProject.zip
>
>
> I posted this to the "rules-users" list, and did not get a response. That leads me to believe it is a bug, so I'm submitting it here. Below is the text of my email.
> Using org.drools.verifier found in "drools-verifier-5.1.1.jar" I get an org.drools.RuntimeDroolsException if a pattern in a rule LHS contains a comparison to a literal value using the equals operator.
> Please consider the following rule I created solely for the purposes of isolating this issue.
> package com.simple.test.rule
> import com.p1s.mps.rulevalidator.TestFact;
> rule "TestRule"
> when
> $fact : TestFact(value == 1)
> then
> System.out.println($fact.getValue());
> end
> The following class definition for the TestFact.
> package com.p1s.mps.rulevalidator;
> public class TestFact
> {
> private int value;
> public TestFact(int value) {
> this.value = value;
> }
>
> public int getValue() {
> return value;
> }
> public void setValue(int value) {
> this.value = value;
> }
> @Override
> public int hashCode() {
> final int prime = 31;
> int result = 1;
> result = prime * result + value;
> return result;
> }
> @Override
> public boolean equals(Object obj) {
> if (this == obj)
> return true;
> if (obj == null)
> return false;
> if (getClass() != obj.getClass())
> return false;
> TestFact other = (TestFact) obj;
> if (value != other.value)
> return false;
> return true;
> }
> }
> The following unit test which attempts to use Verifier.
> @Test
> public final void testVerifierOnLiteral()
> {
> VerifierBuilder verBuilder = VerifierBuilderFactory.newVerifierBuilder();
> Verifier ver = verBuilder.newVerifier();
> String ruleText = getRuleFromResource(TEST_RULE);
> ver.addResourcesToVerify( ResourceFactory.newReaderResource(
> new StringReader( ruleText ) ), ResourceType.DRL );
>
> Assert.assertTrue(ver.fireAnalysis());
> }
> Running the test with JUnit produces the following exception.
> java.lang.RuntimeException: org.drools.RuntimeDroolsException: Exception executing ReturnValue constraint org.drools.rule.ReturnValueRestriction@589f81 : [Error: cannot convert <1> to a numeric type: class java.lang.Integer [0]]
> [Near : {... Unknown ....}]
> ^
> [Line: 1, Column: 0]
> at org.drools.verifier.builder.VerifierImpl.analyse(VerifierImpl.java:148)
> at org.drools.verifier.builder.VerifierImpl.fireAnalysis(VerifierImpl.java:117)
> at com.p1s.mps.rulevalidator.NumericConversionTest.testVerifierOnLiteral(NumericConversionTest.java:64)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
> at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
> at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
> at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
> at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
> at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
> at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
> at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
> at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
> at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> Caused by: org.drools.RuntimeDroolsException: Exception executing ReturnValue constraint org.drools.rule.ReturnValueRestriction@589f81 : [Error: cannot convert <1> to a numeric type: class java.lang.Integer [0]]
> [Near : {... Unknown ....}]
> ^
> [Line: 1, Column: 0]
> at org.drools.rule.ReturnValueConstraint.isAllowedCachedRight(ReturnValueConstraint.java:168)
> at org.drools.common.TripleBetaConstraints.isAllowedCachedRight(TripleBetaConstraints.java:211)
> at org.drools.reteoo.NotNode.assertObject(NotNode.java:140)
> at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
> at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:145)
> at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:450)
> at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:378)
> at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:190)
> at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:145)
> at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1174)
> at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1123)
> at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:917)
> at org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:251)
> at org.drools.verifier.builder.VerifierImpl.analyse(VerifierImpl.java:136)
> ... 26 more
> Caused by: org.drools.RuntimeDroolsException: [Error: cannot convert <1> to a numeric type: class java.lang.Integer [0]]
> [Near : {... Unknown ....}]
> ^
> [Line: 1, Column: 0]
> at org.drools.rule.ReturnValueRestriction.isAllowed(ReturnValueRestriction.java:236)
> at org.drools.rule.ReturnValueConstraint.isAllowedCachedRight(ReturnValueConstraint.java:162)
> ... 39 more
> Caused by: [Error: cannot convert <1> to a numeric type: class java.lang.Integer [0]]
> [Near : {... Unknown ....}]
> ^
> [Line: 1, Column: 0]
> at org.mvel2.math.MathProcessor.getInternalNumberFromType(MathProcessor.java:577)
> at org.mvel2.math.MathProcessor._doOperations(MathProcessor.java:155)
> at org.mvel2.math.MathProcessor.doOperations(MathProcessor.java:79)
> at org.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:102)
> at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
> at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:104)
> at org.mvel2.MVEL.executeExpression(MVEL.java:978)
> at org.drools.base.mvel.MVELReturnValueExpression.evaluate(MVELReturnValueExpression.java:92)
> at org.drools.rule.ReturnValueRestriction.isAllowed(ReturnValueRestriction.java:226)
> ... 40 more
> However, if I use the following version of the same rule where I have added parentheses it works.
> package com.simple.test.rule
> import com.p1s.mps.rulevalidator.TestFact;
> rule "TestRule"
> when
> $fact : TestFact(value == (1))
> then
> System.out.println($fact.getValue());
> end
> Note that both versions of the DRL file compile, run, and produce the correct results.
--
This message was sent by Atlassian Jira
(v7.12.1#712002)
7 years, 6 months
[JBoss JIRA] (JBRULES-3484) Redundancy check option not working in Drools Verifier
by Toni Rikkola (Jira)
[ https://issues.jboss.org/browse/JBRULES-3484?page=com.atlassian.jira.plug... ]
Toni Rikkola updated JBRULES-3484:
----------------------------------
Labels: new_and_noteworthy not verifier (was: new_and_noteworthy not)
> Redundancy check option not working in Drools Verifier
> ------------------------------------------------------
>
> Key: JBRULES-3484
> URL: https://issues.jboss.org/browse/JBRULES-3484
> Project: JBRULES
> Issue Type: Bug
> Components: drools-verifier
> Affects Versions: 5.3.0.Final
> Environment: Apache Tomcat 7.0, Windows 7
> Reporter: Prasanna Venkataraman
> Assignee: Toni Rikkola
> Priority: Major
> Labels: new_and_noteworthy, not, verifier
>
> I am using Drools-Verifier to validate the rules for any redundancy. I have explicitly given the redundant rule to test it. But I didn t get any warning stated that there are duplicate rules.
> I did some research and found that the dependent rules "Find Literal restriction" and "Find Variable restriction" are being removed (file org/drools/redundancy/restriction.drl).
> Kindly fix the issue so that we can continue with Drools-Verifier.
> Thanks,
> Prasanna.
--
This message was sent by Atlassian Jira
(v7.12.1#712002)
7 years, 6 months
[JBoss JIRA] (JBRULES-2926) Split Verifier to 3 parts: Assistant/Verifier/Reporting
by Toni Rikkola (Jira)
[ https://issues.jboss.org/browse/JBRULES-2926?page=com.atlassian.jira.plug... ]
Toni Rikkola updated JBRULES-2926:
----------------------------------
Labels: verifier (was: )
> Split Verifier to 3 parts: Assistant/Verifier/Reporting
> -------------------------------------------------------
>
> Key: JBRULES-2926
> URL: https://issues.jboss.org/browse/JBRULES-2926
> Project: JBRULES
> Issue Type: Task
> Components: drools-verifier
> Reporter: Toni Rikkola
> Assignee: Toni Rikkola
> Priority: Major
> Labels: verifier
>
> Assistant
> * Saves the information about fact type, field, function, query usages
> * Saves the more detailed info for the verifier part
> Verifier
> * The part that runs the verification rules
> * Finds redundancy, overlaps, gaps etc
> Reporting
> * Creates DroolsDocs based on Assistant data
> * Creates Verifier report based on Verifier data
--
This message was sent by Atlassian Jira
(v7.12.1#712002)
7 years, 6 months
[JBoss JIRA] (DROOLS-2845) Extend the existing verifier to support DMN tables
by Toni Rikkola (Jira)
[ https://issues.jboss.org/browse/DROOLS-2845?page=com.atlassian.jira.plugi... ]
Toni Rikkola updated DROOLS-2845:
---------------------------------
Labels: UX drools-tools verifier (was: UX drools-tools)
> Extend the existing verifier to support DMN tables
> --------------------------------------------------
>
> Key: DROOLS-2845
> URL: https://issues.jboss.org/browse/DROOLS-2845
> Project: Drools
> Issue Type: Epic
> Components: DMN Editor, verifier
> Reporter: Toni Rikkola
> Assignee: Toni Rikkola
> Priority: Major
> Labels: UX, drools-tools, verifier
>
> h1. Goal
> Reuse the V&V created for Guided Decision Tables on the DMN tables.
> h1. Workload divided to steps
> I propose the work goes in the following steps. After each step I should be able to merge into master.
> Steps:
> # Move Verifier core to kie-wb-common
> # Move V&V reporting UI to kie-wb-common
> # Make the web worker connector reusable for different V&V types
> # Make a servlet module for DMN that allows the download of the Web Worker.
> # Create an adapter for DMN tables
> # Add support for ranges ( these are given in DMN so no need to use JSR303 )
> # Duplicate i18n of the V&V for DMN or unify the reports so that the terms make sense
> h1. Time and risks
> h2. #1, #2, #3, #4 and #7 moving, copying code or doing refactoring
> Most of the work items are just about moving, copying code or doing refactoring. These are easy to estimate and I think they are doable in one sprint along with everything else I do. Already started few of these so it is easier for me to estimate how long they take.
> h2. 5. Create an adapter for DMN tables
> Adapters job is to take the model ( DMN or dtable ) and tear it down into smaller bits that the Verifier actually inspects. The core Verifier basically only sees rules or rows as collections of conditions and actions. This is why I feel once the adapter is done, the verifier will automatically work for DMN tables. This adapter also keeps track of the cell to action/condition connections.
> This area is where most of the work is that is hard to estimate, since there is some unknowns here. In theory DMN adapter is a lot easier to do than the DTable adapter was. Due to the unknown I will have to say 3 weeks.
> h2. 6. Add support for ranges
> Mario helped to get the range checks in order. The V&V now works with unlimited ranges, but adding known range limitation is in a way just about adding in the data of a mock rule that checks for the area that is outside of the range. I’ll play it safe here and say one week, but at the moment this feels really easy.
> h1. Just to make it clear
> This work only targets the DMN table in the similar format that it is in the Guided Decision Table. So it does not cover a Verification of the entire DMN diagram that can have several tables that possibly complete each other. We have the same situation if we have multiple DRL Tables in a ksession.
--
This message was sent by Atlassian Jira
(v7.12.1#712002)
7 years, 6 months
[JBoss JIRA] (DROOLS-1830) Verification & Validation: Management for the issue reporting
by Toni Rikkola (Jira)
[ https://issues.jboss.org/browse/DROOLS-1830?page=com.atlassian.jira.plugi... ]
Toni Rikkola updated DROOLS-1830:
---------------------------------
Labels: verifier (was: )
> Verification & Validation: Management for the issue reporting
> -------------------------------------------------------------
>
> Key: DROOLS-1830
> URL: https://issues.jboss.org/browse/DROOLS-1830
> Project: Drools
> Issue Type: Feature Request
> Components: Guided Decision Table Editor
> Reporter: Toni Rikkola
> Assignee: Toni Rikkola
> Priority: Major
> Labels: verifier
>
> #1 issue: Reports keep popping up after each edit.
> #2 issue: Depending what the dtable goals are, some issues are known and should happen. Reporting these over and over again is just useless noise.
> Ideas for keeping the noise down: Make it possible to minimize the verification result panel to the side and only open when needed.
--
This message was sent by Atlassian Jira
(v7.12.1#712002)
7 years, 6 months
[JBoss JIRA] (DROOLS-1874) Verification reporting: Impossible match is detected just for equality operator
by Toni Rikkola (Jira)
[ https://issues.jboss.org/browse/DROOLS-1874?page=com.atlassian.jira.plugi... ]
Toni Rikkola updated DROOLS-1874:
---------------------------------
Labels: reported-by-qe verifier (was: reported-by-qe)
> Verification reporting: Impossible match is detected just for equality operator
> -------------------------------------------------------------------------------
>
> Key: DROOLS-1874
> URL: https://issues.jboss.org/browse/DROOLS-1874
> Project: Drools
> Issue Type: Sub-task
> Components: Guided Decision Table Editor
> Affects Versions: 7.0.0.CR2
> Reporter: Jozef Marko
> Assignee: Toni Rikkola
> Priority: Minor
> Labels: reported-by-qe, verifier
>
> The feature of detecting impossible match stopped to work for condition columns that uses operators less than and greater than. If the condition columns uses equality operator, then the impossible match is detected.
> Steps to reproduce:
> # Create Guided Decision Table
> # Create two columns that do check like: *p : Person(name == [value])*
> # Append row into table
> # In first column check that name equals to "John"
> # In second column check that name equals to "john"
> # Impossible match is detected in this case
> # Create another Guided Decision table
> # Create one column that do check like: *p : Person(age < [value])*
> # Create other column that do check like: *p : Person(age > [value])*
> # Append row into the table
> # Check that age is less than 10 in first column
> # Check that age is greater than 20 in second column
> # Impossible match *is not* thrown, but it is expected
--
This message was sent by Atlassian Jira
(v7.12.1#712002)
7 years, 6 months