Grails

mocking for 'InList' comparator in dynamic finders with use of mockDomain()

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Trivial Trivial
  • Resolution: Fixed
  • Affects Version/s: 1.1
  • Fix Version/s: 1.3.5
  • Component/s: Testing
  • Labels:
    None

Description

With mockDomain() in a unit test most dynamic finders are mocked. The comparator 'InList' (newly available since 1.1) is not mocked though and a use of it results in an error like 'No such property: authorInList for class: Book'.

As all other (=older) comparators get mocked and work pretty well, it is just confusing that 'InList' does not.

Activity

Hide
foxgem added a comment -

The following is the diff (based on grails 1.2.0):

MockUtils.groovy
-----------------------------------------------------
L60 "Between",
"InList" ])

R60 "Between" ])
-----------------------------------------------------
L983
case "InList":
if (propValue in args[0]) result << record
break;

MockUtilsTests.groovy
-----------------------------------------------------
L221
result = TestDomain.findByNameInList(["Alice Doe"])
assertEquals result, aliceDoeUS

result = TestDomain.findAllByNameInList(["Chris Jones"])
assertEquals 2, result.size()
assertEquals 2, TestDomain.countByNameInList(["John Smith"])

thanks.

Show
foxgem added a comment - The following is the diff (based on grails 1.2.0): MockUtils.groovy ----------------------------------------------------- L60 "Between", "InList" ]) R60 "Between" ]) ----------------------------------------------------- L983 case "InList": if (propValue in args[0]) result << record break; MockUtilsTests.groovy ----------------------------------------------------- L221 result = TestDomain.findByNameInList(["Alice Doe"]) assertEquals result, aliceDoeUS result = TestDomain.findAllByNameInList(["Chris Jones"]) assertEquals 2, result.size() assertEquals 2, TestDomain.countByNameInList(["John Smith"]) thanks.

People

Vote (2)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: