I am trying to mock a POST method with MockRestServiceServer
in the following way:
MockRestServiceServer server = bindTo(restTemplate).build();
server.expect(requestTo("/my-api"))
.andExpect(method(POST))
.andRespond(withSuccess(expectedResponce, APPLICATION_JSON));
Problem: How do I verify a request body in this setup?
I browsed through the documentation and some examples and still can't figure out how it can be done.
You can use content().string to verify body:
.andExpect(content().string(expectedContent))
Or content().bytes:
this.mockServer.expect(content().bytes("foo".getBytes()))
this.mockServer.expect(content().string("foo"))