grails

Grails - functional test with Geb doesnt work with HtmlUnitDriver

六眼飞鱼酱① 提交于 2020-01-05 08:35:23
问题 I have created a functional test, which works fine when driver is FireFox or Chrome. The same fails when i try to use HtmlUnit driver. The application gets started, but gets stuck while running the first test. Then i have kill the java process to stop it. Pasting the code snippet that i use to initialize the htmlunit driver driver = { def driver = new HtmlUnitDriver() driver.javascriptEnabled = true baseUrl = 'http://localhost:8585' driver } 回答1: Which version of grails are you using?

How can I mock a grails 4 service in a controller unit test

ぐ巨炮叔叔 提交于 2020-01-05 08:27:11
问题 I don't understand how mocking works in Grails 4.0. I have this unit test that fails (it is just an illustration of the real test, the real test actually involves the controller): import com.myapp.MySearchService class ApiControllerSpec extends Specification implements ControllerUnitTest<ApiController> { def setup() { } def cleanup() { } void "test listSources"() { given: def mock = Mock(MySearchService) { find(_) >> [["label": "abc", "description": "xsad"]] } when: System.out.println(mock

Grails integration test - domain object equality

北城余情 提交于 2020-01-05 08:17:53
问题 Setting up some integration tests, I'm having issues with domain class equality. The equality works as expected during normal execution, but when testing the Service methods through an integration test, the test for equality is coming back false. One service (called in the setUp() of the Test Case) puts a Domain object into the session SomeService { setSessionVehicle(String name) { Vehicle vehicle = Vehicle.findByName(name) session.setAttribute("SessionVehicle", vehicle) } getSessionVehicle()

Search records having comma seperated values that contains any element from the given list

随声附和 提交于 2020-01-05 07:48:22
问题 I have a domain class Schedule with a property 'days' holding comma separated values like '2,5,6,8,9'. Class Schedule { String days ... } Schedule schedule1 = new Schedule(days :'2,5,6,8,9') schedule1.save() Schedule schedule2 = new Schedule(days :'1,5,9,13') schedule2.save() I need to get the list of the schedules having any day from the given list say [2,8,11]. Output: [schedule1] How do I write the criteria query or HQL for the same. We can prefix & suffix the days with comma like ',2,5,6

Hibernate: force get() to respect the data type of its parameter

一笑奈何 提交于 2020-01-05 07:18:11
问题 Setup: Grails 2.5.6 with Hibernate 4.3.10 I have a table with a string id. Thing is, its values are numeric strings, and this seems to mess up get() when I pass in a value such as "000000" . Domain class: class Term { static mapping = { id name: 'code', generator: 'assigned' version false code column: 'CODE' description column: 'DESC' } String code String description } Data looks like: CODE || DESC -------++--------------------------- 000000 || The Beginning of Time 201715 || Post Secondary

Hibernate: force get() to respect the data type of its parameter

假装没事ソ 提交于 2020-01-05 07:18:09
问题 Setup: Grails 2.5.6 with Hibernate 4.3.10 I have a table with a string id. Thing is, its values are numeric strings, and this seems to mess up get() when I pass in a value such as "000000" . Domain class: class Term { static mapping = { id name: 'code', generator: 'assigned' version false code column: 'CODE' description column: 'DESC' } String code String description } Data looks like: CODE || DESC -------++--------------------------- 000000 || The Beginning of Time 201715 || Post Secondary

Why do grails Quartz jobs die after a few minutes on production?

允我心安 提交于 2020-01-05 05:18:10
问题 Using the grails Quartz plugin (latest stable version, 0.4.2), I have four different Jobs that run fine in my development environment, most of them every minute. However in the production environment, they run for a few minutes and then "die" - they just don't run anymore. There is no Exception thrown or similar. The rest of the application still works fine. Does anybody have an idea what the reason for this could be? Where / How should I start analyzing the problem? 回答1: I also ran into an

How to unauthorize/revoke LinkedIn token in my application

旧城冷巷雨未停 提交于 2020-01-05 03:33:16
问题 I have a grails application in which I want a user to grant me access to his/her LinkedIn account to get information and show it in different ways. I was able to do the following: Get the authorization code Use that authorization code to get the Access Token I store that Access Token together with the expiration date in my User entity. Refresh that Access Token when the expiration date is within X days from today. Now the issue I'm having is that I would like the user to revoke or invalidate

Change count of displaing items in paginate section

随声附和 提交于 2020-01-05 02:31:58
问题 Is there any way to change count of displaying beans into paginate section by user in grails 2x? I can not find this in grails docs. It means something like (see itemsPerPage) <g:paginate total="${beanInstanceTotal}" itemsPerPage="[10,20,50]" .../> I think that this is obvious functionality for pagination. 回答1: Check the max parameter in g:paginate. From the docs: max (optional) - The number of records to display per page (defaults to 10). Used ONLY if params.max is empty You can then parse

Multiple many-to-many associations in one Grails domain class

做~自己de王妃 提交于 2020-01-05 01:10:10
问题 I am using Grails 3.0.6 and am struggling with a complicated and highly interconnected domain model. I have classes with multiple many-to-many associations to other classes and I am left with no choice but to have multiple belongsTo associations on at least one class. I am unable to figure out the syntax to represent this. My domain model was quite complicated, but I was able to reduce my problem to this simplified example: class Graph { static hasMany = [vertices: Vertex] } class OtherClass