Not able to execute tests while using JSON converters

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Not able to execute tests while using JSON converters

Buddha Shrestha

I'm doing a small test on grails 3.2 using JSON converters(deep)
These are my domain.

class Parent{
   String name
    static hasMany = [childs:Child] 
    static constraints = {

class Child{
   String name
   static belongsTo = [parent:Parent]
   static constraints={}

And I used 'deep' converter to get all the information. My controller looks like this:

def getParents() {
        def parentList = Parent.findAllById(params?.id)
           render parentList as JSON

These controllers provide me correct response. But when I try to implement this into a unit test which looks like this: 
    void 'test check status'() {
        request.method = 'GET'
        request.contentType = 'application/json'
        new Parent(name: 'XYZ', child: new Child(name: 'Demo')).save() = '1'
        request.contentType = 'application/json'

        response.status == HttpStatus.SC_OK

But. when I try to test this, I get an error like :
org.grails.web.converters.exceptions.ConverterException: Error converting Bean with class **********

I'm confused what should I do. Please suggest.


You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit
For more options, visit