Grails Unit Testing: Json-Codec missing / How to mock Json-Codec? -
I am testing unit controller and currently I'm stuck in the method call "encodeAsJSON ()" (Called by the controller)
I get a milligram exception, which I hope is encoded SJSON () is a Grails-Codec.
loadCodec
must be followed by some method to search
but I can not import it because my IDE (SpringSource-ToolSuite) Can not find.
Error:
import org.codehaus.groovy.grails.plugins.codecs.JSONCodec
Everything works:
Import org.codehaus.groovy.grails Plugins.codecs.HTMLCodec
But I do not need HTMLCodec and there is no list of JSONCodec.
This method is still working (turning on the app), but I do not know how this unit checks. any idea? Am I clarifying something?
Well, I got an answer to search and try:
< Code> Map.metaClass.encodeAsJSON = {- & gt; Representative}
example I used
String.metaClass.encodeAsSha1 = {- & gt;
()
()
The string does not work - of course I am using the map, which will be converted to JSON needed.
<I think that you have "fake" (this is the real joke?) On the Groovy-Interface of the related datatype.
Hope this helps someone else
Comments
Post a Comment