mockServer
.when(
request()
.withPath("/get_book")
.withQueryStringParameter(
new Parameter("id", "1")
)
)
.respond(
response()
.withHeaders(
new Header("Content-Type", "application/json")
)
.withBody("" +
"{" + System.getProperty("line.separator") +
" \"id\": \"1\"," + System.getProperty("line.separator") +
" \"title\": \"Xenophon's imperial fiction : on the education of Cyrus\"," + System.getProperty("line.separator") +
" \"author\": \"James Tatum\"," + System.getProperty("line.separator") +
" \"isbn\": \"0691067570\"," + System.getProperty("line.separator") +
" \"publicationDate\": \"1989\"" + System.getProperty("line.separator") +
"}")
);
MvcResult response = mockMvc.perform(get("/book/1").accept(MediaType.TEXT_HTML))
.andExpect(status().isOk())
.andExpect(content().contentType("text/html;charset=UTF-8"))
.andReturn();
BookPage bookPage = new BookPage(response);
bookPage.containsBook(new Book(1, "Xenophon's imperial fiction : on the education of Cyrus", "James Tatum", "0691067570", "1989"));
proxy.verify(
request()
.withPath("/get_book")
.withQueryStringParameter(
new Parameter("id", "1")
),
Times.exactly(1)
);
}