Discussion:
getPersistentValue throw a NullPointerException in Unit Test
Laurent
2013-12-10 08:21:22 UTC
Permalink
Hello,

It seems that now (in grails 2.3.1 and over) there is a posibility to access
getPersistent value and other isDirty property, but when calling
getPersistentValue from any Domain Class I've got a :

java.lang.NullPointerException
at
org.grails.datastore.gorm.GormInstanceApi.getPersistentValue(GormInstanceApi.groovy:305)

And impossible to "mock" by :
MyDomain.metaClass.static.getPersistentValue = {String s -> return null}

Any idea to get around this bug (isDirty seems to work, at least no
execption...)

Regards



--
View this message in context: http://grails.1312388.n4.nabble.com/getPersistentValue-throw-a-NullPointerException-in-Unit-Test-tp4652323.html
Sent from the Grails - dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Aaron Long
2013-12-10 18:02:40 UTC
Permalink
At some point there was some discussion about adding a makeDirty() method
for unit testing. I'm not sure if that solution was ever implemented but
might be worth checking.
Post by Laurent
Hello,
It seems that now (in grails 2.3.1 and over) there is a posibility to access
getPersistent value and other isDirty property, but when calling
java.lang.NullPointerException
at
org.grails.datastore.gorm.GormInstanceApi.getPersistentValue(GormInstanceApi.groovy:305)
MyDomain.metaClass.static.getPersistentValue = {String s -> return null}
Any idea to get around this bug (isDirty seems to work, at least no
execption...)
Regards
--
http://grails.1312388.n4.nabble.com/getPersistentValue-throw-a-NullPointerException-in-Unit-Test-tp4652323.html
Sent from the Grails - dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
Aaron Long
2014-01-06 16:45:00 UTC
Permalink
Did you ever figure out the proper way to implement this in 2.3?

I wonder if the inability to metaClass things is because more and more of
this stuff is marked as @CompileStatic.

-Aaron
Post by Aaron Long
At some point there was some discussion about adding a makeDirty() method
for unit testing. I'm not sure if that solution was ever implemented but
might be worth checking.
Post by Laurent
Hello,
It seems that now (in grails 2.3.1 and over) there is a posibility to access
getPersistent value and other isDirty property, but when calling
java.lang.NullPointerException
at
org.grails.datastore.gorm.GormInstanceApi.getPersistentValue(GormInstanceApi.groovy:305)
MyDomain.metaClass.static.getPersistentValue = {String s -> return null}
Any idea to get around this bug (isDirty seems to work, at least no
execption...)
Regards
--
http://grails.1312388.n4.nabble.com/getPersistentValue-throw-a-NullPointerException-in-Unit-Test-tp4652323.html
Sent from the Grails - dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
Loading...