@@ -494,12 +494,12 @@ public void exectuesSearchThatTakesASort() throws Exception {
494
494
assertThat (findBySortedLink .getVariableNames (), hasItems ("sort" , "projection" ));
495
495
496
496
// Assert results returned as specified
497
- client .follow (findBySortedLink .expand ("offer.price ,desc" )).//
497
+ client .follow (findBySortedLink .expand ("title ,desc" )).//
498
498
andExpect (jsonPath ("$._embedded.books[0].title" ).value ("Spring Data (Second Edition)" )).//
499
499
andExpect (jsonPath ("$._embedded.books[1].title" ).value ("Spring Data" )).//
500
500
andExpect (client .hasLinkWithRel ("self" ));
501
501
502
- client .follow (findBySortedLink .expand ("offer.price ,asc" )).//
502
+ client .follow (findBySortedLink .expand ("title ,asc" )).//
503
503
andExpect (jsonPath ("$._embedded.books[0].title" ).value ("Spring Data" )).//
504
504
andExpect (jsonPath ("$._embedded.books[1].title" ).value ("Spring Data (Second Edition)" )).//
505
505
andExpect (client .hasLinkWithRel ("self" ));
@@ -627,6 +627,29 @@ public void callUnmappedCustomRepositoryController() throws Exception {
627
627
mvc .perform (post ("/orders/search/sort?sort=type&page=1&size=10" )).andExpect (status ().isOk ());
628
628
}
629
629
630
+ @ Test // DATAREST-976
631
+ public void appliesSortByEmbeddedAssociation () throws Exception {
632
+
633
+ Link booksLink = client .discoverUnique ("books" );
634
+ Link searchLink = client .discoverUnique (booksLink , "search" );
635
+ Link findBySortedLink = client .discoverUnique (searchLink , "find-by-sorted" );
636
+
637
+ // Assert sort options advertised
638
+ assertThat (findBySortedLink .isTemplated (), is (true ));
639
+ assertThat (findBySortedLink .getVariableNames (), hasItems ("sort" , "projection" ));
640
+
641
+ // Assert results returned as specified
642
+ client .follow (findBySortedLink .expand ("offer.price,desc" )).//
643
+ andExpect (jsonPath ("$._embedded.books[0].title" ).value ("Spring Data (Second Edition)" )).//
644
+ andExpect (jsonPath ("$._embedded.books[1].title" ).value ("Spring Data" )).//
645
+ andExpect (client .hasLinkWithRel ("self" ));
646
+
647
+ client .follow (findBySortedLink .expand ("offer.price,asc" )).//
648
+ andExpect (jsonPath ("$._embedded.books[0].title" ).value ("Spring Data" )).//
649
+ andExpect (jsonPath ("$._embedded.books[1].title" ).value ("Spring Data (Second Edition)" )).//
650
+ andExpect (client .hasLinkWithRel ("self" ));
651
+ }
652
+
630
653
private List <Link > preparePersonResources (Person primary , Person ... persons ) throws Exception {
631
654
632
655
Link peopleLink = client .discoverUnique ("people" );
0 commit comments