singalen: (Default)
[personal profile] singalen

Originally published at Fiberglass flowers. You can comment here or there.

We’re trying Grails, Rails-like web application framework for Java.
It’s fine, just that Groovy debugger support is, er, imperfect, even in the best Gruoovy IDE – IDEA.

And, if you want to unit test, you won’t have fancy domain class methods addTo* – like Customer.addToOrders().
They’re generated by Grails on startup.
In order to have addTo*(), inherit from GrailsUnitTestCase and call mockDomain(Customer) in setUp().

Oh, if you get "NullPointerException: Cannot invoke method containsKey() on null object", add super.setUp() to yout testcase’s setUp().

Having proper save() is more tricky. Implementation from mockDomain() works to some extent: it won’t save connected objects.
So, in order to get save() working, you have to do something like this:

Read the rest of this entry »

Tags: