diff --git a/rest-notes-spring-hateoas/src/documentation/asciidoc/main.asciidoc b/rest-notes-spring-hateoas/src/documentation/asciidoc/main.asciidoc index ab83ba4f..6ac321c1 100644 --- a/rest-notes-spring-hateoas/src/documentation/asciidoc/main.asciidoc +++ b/rest-notes-spring-hateoas/src/documentation/asciidoc/main.asciidoc @@ -79,7 +79,7 @@ This request will produce a response with the note's details in its body: include::{generated}/get-note/response.asciidoc[] -Note the `tags` link which we'll make use of later. +Note the `note-tags` link which we'll make use of later. @@ -141,7 +141,8 @@ As before, a `GET` request executed against this URI will retrieve the note's de include::{generated}/get-tagged-note/request-response.asciidoc[] -To see the note's tags, execute a `GET` request against the URI of the note's tags link: +To see the note's tags, execute a `GET` request against the URI of the note's +`note-tags` link: include::{generated}/get-tags/request.asciidoc[] @@ -163,7 +164,7 @@ This request should produce a `204 No Content` response: include::{generated}/tag-existing-note/response.asciidoc[] -When we first created this note, we noted the tags link included in its details: +When we first created this note, we noted the `note-tags` link included in its details: include::{generated}/get-note/response.asciidoc[] diff --git a/rest-notes-spring-hateoas/src/documentation/java/com/example/notes/GettingStartedDocumentation.java b/rest-notes-spring-hateoas/src/documentation/java/com/example/notes/GettingStartedDocumentation.java index e2125426..437cfb97 100644 --- a/rest-notes-spring-hateoas/src/documentation/java/com/example/notes/GettingStartedDocumentation.java +++ b/rest-notes-spring-hateoas/src/documentation/java/com/example/notes/GettingStartedDocumentation.java @@ -119,7 +119,7 @@ public class GettingStartedDocumentation { this.mockMvc.perform(get(noteLocation)).andExpect(status().isOk()) .andExpect(jsonPath("title", is(notNullValue()))) .andExpect(jsonPath("body", is(notNullValue()))) - .andExpect(jsonPath("_links.tags", is(notNullValue())))); + .andExpect(jsonPath("_links.note-tags", is(notNullValue())))); } String createTag() throws Exception, JsonProcessingException { @@ -143,7 +143,7 @@ public class GettingStartedDocumentation { "get-tag", this.mockMvc.perform(get(tagLocation)).andExpect(status().isOk()) .andExpect(jsonPath("name", is(notNullValue()))) - .andExpect(jsonPath("_links.notes", is(notNullValue())))); + .andExpect(jsonPath("_links.tagged-notes", is(notNullValue())))); } String createTaggedNote(String tag) throws Exception { @@ -170,12 +170,12 @@ public class GettingStartedDocumentation { this.mockMvc.perform(get(tagLocation)).andExpect(status().isOk()) .andExpect(jsonPath("title", is(notNullValue()))) .andExpect(jsonPath("body", is(notNullValue()))) - .andExpect(jsonPath("_links.tags", is(notNullValue())))); + .andExpect(jsonPath("_links.note-tags", is(notNullValue())))); } void getTags(String taggedNoteLocation) throws Exception { String tagsLocation = getLink(this.mockMvc.perform(get(taggedNoteLocation)) - .andReturn(), "tags"); + .andReturn(), "note-tags"); document("get-tags", this.mockMvc.perform(get(tagsLocation)).andExpect(status().isOk()) .andExpect(jsonPath("_embedded.tags", hasSize(1)))); @@ -201,15 +201,15 @@ public class GettingStartedDocumentation { void getTagsForExistingNote(String taggedNoteLocation) throws Exception { String tagsLocation = getLink(this.mockMvc.perform(get(taggedNoteLocation)) - .andReturn(), "tags"); + .andReturn(), "note-tags"); document("get-tags-for-existing-note", this.mockMvc.perform(get(tagsLocation)).andExpect(status().isOk()) .andExpect(jsonPath("_embedded.tags", hasSize(1)))); } - private String getLink(MvcResult result, String href) + private String getLink(MvcResult result, String rel) throws UnsupportedEncodingException { return JsonPath.parse(result.getResponse().getContentAsString()).read( - "_links.tags.href"); + "_links." + rel + ".href"); } } diff --git a/rest-notes-spring-hateoas/src/main/java/com/example/notes/NoteResourceAssembler.java b/rest-notes-spring-hateoas/src/main/java/com/example/notes/NoteResourceAssembler.java index 465aa68f..a78626df 100644 --- a/rest-notes-spring-hateoas/src/main/java/com/example/notes/NoteResourceAssembler.java +++ b/rest-notes-spring-hateoas/src/main/java/com/example/notes/NoteResourceAssembler.java @@ -35,7 +35,7 @@ public class NoteResourceAssembler extends ResourceAssemblerSupport