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,