How can I tell MockRestServiceServer
to expect a specific json
content during a junit @Test
?
I thought I could expect just a json string as follows:
.andExpect(content().json(...))
, but that method does not exist. So how could I rewrite the following?
private MockRestServiceServer mockServer;
private ObjectMapper objectMapper; //jackson
Person p = new Person();
p.setFirstname("first");
p.setLastname("last");
//mocking a RestTemplate webservice response
mockServer.expect(once(), requestTo("/servlet"))
.andExpect(content().json(objectMapper.writeValueAsString(p))) //.json() does not exist! why?
.andRespond(withSuccess(...));
spring-test-4.3.14.RELEASE
. But what I noticed: the path ofcontent()
isorg.springframework.test.web.client.match
, not*.servlet...
. That's becauseMockRestServiceServer
is for mocking webservice responses throughRestTemplate
. – Karisakarissa