Polishing.

Added test case and re-enabled the base URI to be prepended even in case a controller path prefix is configured. That functionality had been lost with the originally submitted changes.

Related ticket: #2157
Original pull request: #2088.
This commit is contained in:
Oliver Drotbohm
2022-07-06 16:15:20 +02:00
parent 8daacadb1e
commit 07ebc501cd
6 changed files with 101 additions and 30 deletions

View File

@@ -58,10 +58,12 @@ public class JpaRepositoryConfig extends JpaInfrastructureConfig {
void someMethod(@PathVariable String id) {}
}
@RepositoryRestController(path = {"orders", "orders/v2"})
@RepositoryRestController({ "orders", "orders/v2" })
static class OrdersJsonController {
@RequestMapping(value = {"/search/sort","/search/sorted"}, method = RequestMethod.POST, produces = "application/hal+json")
@RequestMapping(path = { "/search/sort", "/search/sorted" }, //
method = RequestMethod.POST, //
produces = "application/hal+json")
void someMethodWithArgs(Sort sort, Pageable pageable, DefaultedPageable defaultedPageable) {}
}
}

View File

@@ -682,9 +682,13 @@ public class JpaWebTests extends CommonWebTests {
andExpect(client.hasLinkWithRel(IanaLinkRelations.SELF));
}
@Test // DATAREST-910 DATAREST-2088
@Test // DATAREST-910, #2087
void callUnmappedCustomRepositoryController() throws Exception {
// Invalid prefix
mvc.perform(post("/orders/v3/search/sort")).andExpect(status().isNotFound());
// With mapped prefixes
mvc.perform(post("/orders/search/sort")).andExpect(status().isOk());
mvc.perform(post("/orders/search/sorted")).andExpect(status().isOk());
mvc.perform(post("/orders/v2/search/sort")).andExpect(status().isOk());