Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-3245

Cannot use Mockito to Mock Events; result is ClassCastException

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 5.3.0.CR1
    • drools-core (fusion)
    • None

    Description

      AbstractRuleBase.getTypeDeclaration(Class clazz) cannot determine what type is being mocked, so attempting to mock an event causes the system to fall back to the object being a simple fact. Have test classes to attach to issue: explanation of what I'm seeing:

      testMockObjectAsEvent: may not be the same issue, but the system cannot identify the correct extractor for the event timestamp, and attempts to get a Long value from a method that returns a Date. In this case, it's at least identified as an event.

      testMockObjectAsEventTwoLevels: mock is of an interface that extends a declared event; in this case the mock is never identified as an event, but still follows the path into the rule's window function, resulting in an attempt to cast the mock's DefaultFactHandle to an EventFactHandle.

      Attachments

        Activity

          People

            mproctor@redhat.com Mark Proctor
            rcrawford42 Rob Crawford (Inactive)
            Archiver:
            rhn-support-ceverson Clark Everson

            Dates

              Created:
              Updated:
              Archived:

              PagerDuty