spring - Mock controller with an object parameter -
I am trying to test a method with this signature:
@RequestMapping (value @ "/ employee / {id}", method = RequestMethod.PUT, consumes = "application / json") @ Transactional Public @ Responseboard Map Update (@PathVerify Integer ID, @RestestBodyHashmap & lt; string, Object> information] {} The problem is that MockMvc param properties only accept string parameters, there is a hashmap or A Examples of how to have RequestBody as parameter class object? When I try to pass a hashm as a string, I get a mismatch exception.
You have to use Jackson for this. This idea is to destariate your objects (it does not matter if this hashmap) is in JSON string and passes it to MockMvc.
Just search for the test class there and see how it is used. Skip unit tests of GET requests.
Comments
Post a Comment