getPersistentValue throw a NullPointerException in Unit Test

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

getPersistentValue throw a NullPointerException in Unit Test

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 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
Reply | Threaded
Open this post in threaded view
|

Re: getPersistentValue throw a NullPointerException in Unit Test

longwa
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.


On Tue, Dec 10, 2013 at 3:21 AM, Laurent <[hidden email]> wrote:
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



Reply | Threaded
Open this post in threaded view
|

Re: getPersistentValue throw a NullPointerException in Unit Test

longwa
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


On Tue, Dec 10, 2013 at 1:02 PM, Aaron Long <[hidden email]> wrote:
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.


On Tue, Dec 10, 2013 at 3:21 AM, Laurent <[hidden email]> wrote:
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