Bug 1121985 - Test scenario: Not working with Java enums
Summary: Test scenario: Not working with Java enums
Alias: None
Product: JBoss BRMS Platform 6
Classification: Retired
Component: Business Central
Version: 6.0.0
Hardware: Unspecified
OS: Unspecified
Target Milestone: ER3
: 6.1.0
Assignee: Toni Rikkola
QA Contact: Lukáš Petrovický
Depends On:
TreeView+ depends on / blocked
Reported: 2014-07-22 09:24 UTC by Toni Rikkola
Modified: 2018-12-09 18:12 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed:
Type: Bug

Attachments (Terms of Use)

Description Toni Rikkola 2014-07-22 09:24:32 UTC
Description of problem:

Test scenario fails to run when using enums. Tested with the setup below.

Email from the rules-users mailing list:

"Hi all, I'm defining a test scenario within guvnor (now called kie-workbench)
and I'm experiencing some issues about using java enums.

The case is simple, I have a java model (deploying a jar) with a class
having a member of enum type. The enum is defined in the same package but in
a different java file, not an inner class. This is packed in a jar that I
deploy manually uploading the file to the embedded maven repo using the

public class ClassWithMemberAsEnum { private EnumType enumMember;
/*getters/setters included*/}
public enum EnumType {HELLO, BYE}

Then I write a dummy rule with the guided editor like this:

import es.shin.test.ClassWithMemberAsEnum;
import es.shin.test.EnumType;
rule "DummyRule"
    dialect "mvel"
        x : ClassWithMemberAsEnum( enumMember == EnumType.HELLO )
        x.setEnumMember( EnumType.BYE );

And finally a test scenario inserting a ClassWithMemberAsEnum initialized
with enumMember=EnumType.HELLO and checking that it is changed to
EnumType.BYE after firing all rules.

The error message returned in the reporting console is:

EnumTest : [Error: unable to resolve method using strict-mode:
java.lang.Object.es()] [Near : {... es.shin.test.EnumType.HELLO ....}] ^
[Line: 1, Column: 1]

I have tried the same case but defining the class in the data modeler and
the enum with the enumeration editor, without using any jar artifact. The
case worked as expected."

Comment 3 Spolti 2014-11-12 17:04:42 UTC
The same test was made in the following versions:

5.3.1 -> worked as expected
6.0.2 -> same problem
6.0.3 -> same problem

Comment 5 b5a7_ 2015-07-03 00:01:42 UTC
Similar use case - trying to set the value of an enum, I got an error:
testdrl : [Error: could not access/write property (gender) in: au.gov.tas.test.Person] [Near : {... __fact__.gender= __val__ ....}] ^ [Line: 1, Column: 15]
When creating the test scenario, the workbench correctly interprets the enumeration, allowing the appropriate value to be selected but is obviously passing the string because, I needed to add a setter that accepted a string value.

Note You need to log in before you can comment on or make changes to this bug.