createCriteria Lock失败单元测试

时间:2015-01-29 15:38:51

标签: unit-testing grails gorm createcriteria

我在单元测试的服务方法中有一个查询,我正在调用lock true,但每次我使用lock true运行单元测试时,单元测试失败并给出以下错误。

groovy.lang.MissingMethodException: No signature of method: com.myapp.foo.MyService.lock() is applicable for argument types: (java.lang.Boolean) values: [true]
Possible solutions: each(groovy.lang.Closure), wait(), grep(), find(), dump(), any()
    at com.myapp.foo.MyService.createShipment_closure22_closure79(MyService.groovy:1282)
    at com.myapp.foo.MyService.createShipment_closure22_closure79(MyService.groovy)
    at groovy.lang.Closure.call(Closure.java:411)
    at groovy.lang.Closure.call(Closure.java:405)
    at grails.gorm.CriteriaBuilder.invokeClosureNode(CriteriaBuilder.java:1093)
    at grails.gorm.CriteriaBuilder.get(CriteriaBuilder.java:257)
    at com.myapp.foo.MyService.createShipment_closure22(MyService.groovy:1277)
    at groovy.lang.Closure.call(Closure.java:411)
    at groovy.lang.Closure.call(Closure.java:427)
    at com.myapp.foo.MyService.createShipment(MyService.groovy:1274)
    at com.myapp.foo.MyServiceSpec.test create shipment: success(MyServiceSpec.groovy:124)

我的查询看起来像这样,我从先前的类似查询中了解到它在现实世界中的情况。

def shipmentInstance = Shipment.createCriteria().get {
    maxResults(1)
    eq("trackingNumber", shipment.trackingNumber.toString())

    lock true
}

使用Grails 2.3.11。我已在文档中确认您可以在lock true中使用createCriteria()

0 个答案:

没有答案