Skip to content

Commit

Permalink
DATAREST-976 - Polishing.
Browse files Browse the repository at this point in the history
Extracted test for the newly supported sorting scenario so that we now.

Original pull request: #251.
  • Loading branch information
odrotbohm committed Jan 16, 2017
1 parent ffe96e4 commit 99f4953
Showing 1 changed file with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,12 @@ public void exectuesSearchThatTakesASort() throws Exception {
assertThat(findBySortedLink.getVariableNames(), hasItems("sort", "projection"));

// Assert results returned as specified
client.follow(findBySortedLink.expand("offer.price,desc")).//
client.follow(findBySortedLink.expand("title,desc")).//
andExpect(jsonPath("$._embedded.books[0].title").value("Spring Data (Second Edition)")).//
andExpect(jsonPath("$._embedded.books[1].title").value("Spring Data")).//
andExpect(client.hasLinkWithRel("self"));

client.follow(findBySortedLink.expand("offer.price,asc")).//
client.follow(findBySortedLink.expand("title,asc")).//
andExpect(jsonPath("$._embedded.books[0].title").value("Spring Data")).//
andExpect(jsonPath("$._embedded.books[1].title").value("Spring Data (Second Edition)")).//
andExpect(client.hasLinkWithRel("self"));
Expand Down Expand Up @@ -627,6 +627,29 @@ public void callUnmappedCustomRepositoryController() throws Exception {
mvc.perform(post("/orders/search/sort?sort=type&page=1&size=10")).andExpect(status().isOk());
}

@Test // DATAREST-976
public void appliesSortByEmbeddedAssociation() throws Exception {

Link booksLink = client.discoverUnique("books");
Link searchLink = client.discoverUnique(booksLink, "search");
Link findBySortedLink = client.discoverUnique(searchLink, "find-by-sorted");

// Assert sort options advertised
assertThat(findBySortedLink.isTemplated(), is(true));
assertThat(findBySortedLink.getVariableNames(), hasItems("sort", "projection"));

// Assert results returned as specified
client.follow(findBySortedLink.expand("offer.price,desc")).//
andExpect(jsonPath("$._embedded.books[0].title").value("Spring Data (Second Edition)")).//
andExpect(jsonPath("$._embedded.books[1].title").value("Spring Data")).//
andExpect(client.hasLinkWithRel("self"));

client.follow(findBySortedLink.expand("offer.price,asc")).//
andExpect(jsonPath("$._embedded.books[0].title").value("Spring Data")).//
andExpect(jsonPath("$._embedded.books[1].title").value("Spring Data (Second Edition)")).//
andExpect(client.hasLinkWithRel("self"));
}

private List<Link> preparePersonResources(Person primary, Person... persons) throws Exception {

Link peopleLink = client.discoverUnique("people");
Expand Down

0 comments on commit 99f4953

Please sign in to comment.