[jboss-jira] [JBoss JIRA] (JBRULES-3562) Drools cannot resolve functions when argument is a fact type

RH Bugzilla Integration (JIRA) jira-events at lists.jboss.org
Mon Sep 17 09:51:35 EDT 2012


    [ https://issues.jboss.org/browse/JBRULES-3562?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12719108#comment-12719108 ] 

RH Bugzilla Integration commented on JBRULES-3562:
--------------------------------------------------

Mario Fusco <mfusco at redhat.com> made a comment on [bug 851310|https://bugzilla.redhat.com/show_bug.cgi?id=851310]

That repository works for me. Also I added a further unit test in the code base of the 5.3.x branch using exactly the same DRL generated by that repository and it passes without any problem. I am pasting the source code of that test below:

    @Test
    public void testMvelFunctionWithDeclaredTypeArg() {
        // JBRULES-3562
        String rule = "package testPackage\n" +
                "declare Person\n" +
                "name: String\n" +
                "age: Integer\n" +
                "end\n" +
                "\n" +
                "function String PersonToString(Person p) {\n" +
                "String result = \"\";\n" +
                "result = p.getName() + \", age: \" + p.getAge();\n" +
                "return result;\n" +
                "}\n" +
                "\n" +
                "rule \"testRule1\"\n" +
                "dialect \"mvel\"\n" +
                "when\n" +
                "p : Person( )\n" +
                "then\n" +
                "System.out.println(PersonToString(p));\n" +
                "end\n" +
                "\n" +
                "rule 'testRule2'\n" +
                "dialect 'mvel'\n" +
                "when\n" +
                "$p : Person()\n" +
                "then\n" +
                "System.out.println(PersonToString($p));\n" +
                "end";

        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
        kbuilder.add( ResourceFactory.newByteArrayResource(rule.getBytes()), ResourceType.DRL );

        if ( kbuilder.hasErrors() ) {
            fail( kbuilder.getErrors().toString() );
        }

        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
    }
                
> Drools cannot resolve functions when argument is a fact type
> ------------------------------------------------------------
>
>                 Key: JBRULES-3562
>                 URL: https://issues.jboss.org/browse/JBRULES-3562
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: drools-compiler
>    Affects Versions: 5.3.0.Final
>         Environment: Linux Ubuntu, JBoss 5.1.0
>            Reporter: Nedo Nedic
>            Assignee: Mario Fusco
>             Fix For: 5.5.0.Beta1
>
>
> Note that this only fails when MVEL dialect is used with functions using non-primitive argument types (for an instance using
> fact types arguments).
> This error appeared when we migrated from Drools 5.0.1.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list