Quantcast

Not able to execute tests while using JSON converters

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Not able to execute tests while using JSON converters

Buddha Shrestha
Hi,

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)
        JSON.use('deep')
           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'() {
        when:
        request.method = 'GET'
        request.contentType = 'application/json'
        new Parent(name: 'XYZ', child: new Child(name: 'Demo')).save()
        params.id = '1'
        request.contentType = 'application/json'
        controller.getParents()

        then:
        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.

Thanks,

--
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 https://groups.google.com/d/msgid/grails-dev-discuss/bfc33f27-39ca-431b-89a8-0ef06fb5a276%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...