Question:
I am trying to write tests for new allergy api I am adding to webservices.rest.
In the tests, I am getting a JSON parsing error because Allergy contains Allergen which contains codedAllergen, a Concept. The parsing (getter conflict) error is the retired field in Concept has two getters isRetired(), and getRetired()
I don’t understand because Concept is just a fundamental class so it must be something I am doing wrong.
My test extends MainResourceControllerTest
OpenMRS has two getters as you mentioned i.e. isRetired and getRetired, so Jackson can’t automatically convert the data into a JSON object as it gets confused with two getters.
You need to convert it into a simpler representation that suits your need like I’m trying to do here while trying to get a base/Raw openmrs object or if there is no preference(for getting JSON) there wont be any exception getting an XML.
To expound on what @maurya said, the specific problem is that you need to have a Converter or Resource for every non-trivial class that is going to be sent over JSON. Specifically, you need to add a Converter for the Allergen class.