I am trying to mock RestTemplate
with MockRestServiceServer
. When I am debugging my test, the response entity has the good status and content-type (tested with multiple status and content-type to check the differences), but the body is always null
.
final String uri = "/uri";
final String notNullJsonString = "{}";
// restTemplate is autowired
final MockRestServiceServer mockRestServiceServer = MockRestServiceServer.createServer(restTemplate);
mockRestServiceServer.expect(
MockRestRequestMatchers.requestTo(new URI(uri))
).andRespond(
MockRestResponseCreators.withStatus(HttpStatus.ACCEPTED)
.contentType(MediaType.APPLICATION_JSON)
.body(notNullJsonString)
);
Best regards,