I am trying to test my API,for which I am calling my API using mockMVC as below:
ResultActions resultAction = mockMvc.perform(MockMvcRequestBuilders.get("/users/v1/{userId}",userId)
.contentType(MediaType.APPLICATION_JSON).headers(header));
I am getting following exception:
org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
Here is my rest code(using Spring Boot)
@RequestMapping(value = "/users/v1/{userId}",
produces = { "application/json" },
method = RequestMethod.GET)
@ResponseStatus(code = HttpStatus.OK)
public User getUser(Integer userId) {
User user = userManagementService.fetchUser(userId);
return user;
}
Can you please suggest what is going wrong here.
I found the issue.On putting @EnableWebMvc on my Step definition file,it worked perfectly.