Assessment shows jackson gettingInvalidDefinitionException at RestaurantControllerDebugModuleHiddenTest2

The hidden tests are failing with the message
com.crio.qeats.controller.RestaurantControllerDebugModuleHiddenTest2 > hiddenTest1() FAILED
com.fasterxml.jackson.databind.exc.InvalidDefinitionException at
I tried looking for the issue, I have my default constructor, getters, setters in my RequestMapping class.
@Nabhan-CrioTA Can you tell me the format of data you are sending in the controller test?

So, the particular error as you would remember from QMoney happens when our DTO class gets some field to store that isn’t defined in it. You would’ve come across this while setting DTO for Alphavantage API as we didn’t want to store all the fields returned by the API response. You’ll need to use Jackson annotation to mark the DTO class storing the data to ignore any new properties.

So, you mean to say there is an issue with serialization with request dto or response dto?
Can you tell me whether the request will always be made to the url “/qeats/v1/restaurants?latitude=22.16&longitude=85.40”?

Yep, the request url will be the the same.

See the structure of json in qeatsbackend/src/test/resources/fixtures/exchanges/list_restaurant_response.json

Will your response dto be able to handle that?

So I think the issue lies with the id and restaurant id. I am just using jsonAlias(id) above the restaurant id. I think I need to define both id and restaurant id and make id ignorable when sending response. Am I right?

Yep, you can do that

Hey, I modified my file and added appropriate annotation so that it fits the list_restaurant_response.json file. Still it is failing.

hello @initish2017
there is 1 classe involved while serializing and deserializing i.e. Restaurant.class
now, that you are sure that there is no problem in that class you can further expand your thought process to another classes that may have been using the serialized/deserialized output. Are those classes have proper annotations?
HInt: analyse your files in qeats/exchanges.

Thanks. I have fixed that issue. It was a fault with annotations in Request class.
Now, my tests results are saying AssertionFailedError(HiddenTest2) and IndexOutOfBoundsException(Test1).
I am validating the name in the controller layer. Is this the correct approach or I have to add this logic in service layer as well?
One question - I am not sending the restaurants with invalid names to the response. Am I right?

Okay. So I changed a few things and it got fixed. Thanks @Nabhan-CrioTA and @Anmol-Crio_TA for your help.

hello @initish2017 please mark this as solution, this will close the ticket. :slight_smile:

Closing this topic as your issue has been resolved by the community. If not Kindly un-mark the accepted solution to re-open the topic or feel free to create a new topic and post a link to this topic as a reference.