Skip to content
Snippets Groups Projects
Commit 8eb50747 authored by Aiden-at-508687582768's avatar Aiden-at-508687582768 Committed by Stephane Nicoll
Browse files

Fix content negotiation for /vets

See gh-326
parent 6905e38c
No related branches found
No related tags found
No related merge requests found
...@@ -48,7 +48,7 @@ class VetController { ...@@ -48,7 +48,7 @@ class VetController {
return "vets/vetList"; return "vets/vetList";
} }
@GetMapping({ "/vets.json", "/vets.xml" }) @GetMapping({ "/vets" })
public @ResponseBody Vets showResourcesVetList() { public @ResponseBody Vets showResourcesVetList() {
// Here we are returning an object of type 'Vets' rather than a collection of Vet // Here we are returning an object of type 'Vets' rather than a collection of Vet
// objects so it is simpler for JSon/Object mapping // objects so it is simpler for JSon/Object mapping
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
<table class="table-buttons"> <table class="table-buttons">
<tr> <tr>
<td><a th:href="@{/vets.xml}">View as XML</a></td> <td><a th:href="@{/vets}">View as XML</a></td>
<td><a th:href="@{/vets.json}">View as JSON</a></td>
</tr> </tr>
</table> </table>
......
...@@ -65,7 +65,7 @@ public class VetControllerTests { ...@@ -65,7 +65,7 @@ public class VetControllerTests {
@Test @Test
public void testShowResourcesVetList() throws Exception { public void testShowResourcesVetList() throws Exception {
ResultActions actions = mockMvc.perform(get("/vets.json").accept(MediaType.APPLICATION_JSON)) ResultActions actions = mockMvc.perform(get("/vets").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()); .andExpect(status().isOk());
actions.andExpect(content().contentType("application/json;charset=UTF-8")) actions.andExpect(content().contentType("application/json;charset=UTF-8"))
.andExpect(jsonPath("$.vetList[0].id").value(1)); .andExpect(jsonPath("$.vetList[0].id").value(1));
...@@ -73,7 +73,7 @@ public class VetControllerTests { ...@@ -73,7 +73,7 @@ public class VetControllerTests {
@Test @Test
public void testShowVetListXml() throws Exception { public void testShowVetListXml() throws Exception {
mockMvc.perform(get("/vets.xml").accept(MediaType.APPLICATION_XML)) mockMvc.perform(get("/vets").accept(MediaType.APPLICATION_XML))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_XML_VALUE)) .andExpect(content().contentType(MediaType.APPLICATION_XML_VALUE))
.andExpect(content().node(hasXPath("/vets/vetList[id=1]/id"))); .andExpect(content().node(hasXPath("/vets/vetList[id=1]/id")));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment