If calling grails.converters.JSON from unit test throws error like:
It is easy to fix this error by adding ControllerUnitTestMixin to the test definition like:
java.lang.RuntimeException: org.codehaus.groovy.grails.web.converters.exceptions.ConverterException: Unconvertable Object of class: my.blog.Post at org.codehaus.groovy.grails.web.converters.AbstractConverter.toString(AbstractConverter.java:111) at org.codehaus.groovy.runtime.InvokerHelper.format(InvokerHelper.java:616) at org.codehaus.groovy.runtime.InvokerHelper.format(InvokerHelper.java:559)
It is easy to fix this error by adding ControllerUnitTestMixin to the test definition like:
@TestMixin(ControllerUnitTestMixin) @TestFor(BlogService) class BlogServiceTests { ...
Oh man, I had similar problem before, and it was really uncomfortable to work with it, but then I found a solution of this problem on one service that explained me how to use java tostring https://explainjava.com/tostring-method-java/ properly and without any extra efforts.
ReplyDeleteIt doesn't make much sense to create a general-purpose JSON (JavaScript Object Notation) converter to Excel, CSV or text files. JSON is a lightweight data format which is used to describe objects and arrays (lists) of data. To display the data (in a general sense), it would make more sense to create a tree structure of the data with branches or a list of lists. One of the easier ways to display JSON is to paste it into JavaScript on a web page and use script to generate a list of lists by recursing through the data structure. Here is a way to do that. First create a text file (a file with a .txt extension). Copy/paste the below code into that file. Replace the sample JSON with the contents of your .json file. Rename the file's extension as an .html file and view in your browser.I also have many suggestions about the conversion through this Conversion Calculator.
ReplyDeleteDevice Converter program is an easy, adaptive and also yet an astonishing allin 1 Unit Conversion Calculator program that's developed bearing in your mind regular utilization of apparatus converter at various activities every afternoon. It's just a universal component converter program that's effective at reversing components of distinct types. Basic to utilize beautiful user-friendly and graphics user interface.
ReplyDelete