GRAILS-8841: Implement case-insensitive eq() Criteria in Unit Tests
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
Original Reporter: keithrz
Environment: Not Specified
Version: 2.0.1
Migrated From: http://jira.grails.org/browse/GRAILS-8841
My service unit test worked until I added the [ignoreCase: true] parameter to an eq() method.
The service works as expected outside of unit tests.
The service code is below. I did not include the code for the test Spec (Version: Spock 0.6-SNAPSHOT), but it doesn't seem to matter what is in the test Spec, as long as it calls the service.
Service Code:
{code}
package myPackage
class myService {
def getDomainObjs(value) {
def bundleList = MyDomainObj.withCriteria() {
eq("value", value, [ignoreCase: true])
}
}
}
{code}
Stack Trace:
{code}
groovy.lang.MissingMethodException: No signature of method: myPackage.myService.eq() is applicable for argument types: (java.lang.String, java.lang.String, java.util.LinkedHashMap) values: [value, value, [ignoreCase:true]]
Possible solutions: grep(), any(), wait(), every(), dump(), find()
at myPackage.myService.getDomainObjs_closure1(myService.groovy:6)
at myPackage.myService.getDomainObjs_closure1(myService.groovy)
at groovy.lang.Closure.call(Closure.java:412)
at groovy.lang.Closure.call(Closure.java:406)
at grails.gorm.CriteriaBuilder.invokeClosureNode(CriteriaBuilder.java:990)
at grails.gorm.CriteriaBuilder.invokeMethod(CriteriaBuilder.java:312)
at org.grails.datastore.gorm.GormStaticApi.withCriteria(GormStaticApi.groovy:261)
at myPackage.myService.getDomainObjs(ContentBundleService.groovy:5)
at myPackage.myServiceSpec.The getDomainObjs service must match by value(myServiceSpec.groovy:27)
{code}
Contributor guide
Research direction
Start by reproducing the service call shown in the issue, then trace the criteria closure through GormStaticApi.withCriteria and CriteriaBuilder.invokeClosureNode, the entry points named in the stack trace. Verify how eq() handles the ignoreCase option in unit tests; done means the service call no longer raises MissingMethodException and performs a case-insensitive match.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- backend, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100