Skip to content

Commit

Permalink
Fix basepath links
Browse files Browse the repository at this point in the history
  • Loading branch information
Skaar, Bjørn-Andre committed Jan 15, 2024
1 parent 196537c commit 59d67ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,7 @@ public ResponseEntity<String> verifyTracking(@PathVariable String email, @PathVa
private void addSearchLink(PagedModel<ClassificationSummaryResource> response) {
WebMvcLinkBuilder linkBuilder = WebMvcLinkBuilder.linkTo(WebMvcLinkBuilder.methodOn(ClassificationController.class).search("query", null, true,
null, null));
response.add(Link.of(ResourceUtil.createUriTemplateBuilder(linkBuilder)
.basePath(basePath).variables("query", "includeCodelists").build(), "search"));
response.add(Link.of(ResourceUtil.createUriTemplateBuilder(linkBuilder).variables("query", "includeCodelists").build(), "search"));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ public void createSearchLinkUsingTemplate() {
WebMvcLinkBuilder linkBuilder = WebMvcLinkBuilder.linkTo(WebMvcLinkBuilder.methodOn(ClassificationController.class)
.search("query", null, true, null, null));
String link = ResourceUtil.createUriTemplate(linkBuilder, "query", "includeCodelists").toString();
assertTrue(link.endsWith("/v1/classifications/search{?query,includeCodelists}"));
link = link.replace("http://localhost", "");
assertEquals("/api/klass/v1/classifications/search{?query,includeCodelists}", link);
}
@Test
public void createSearchLinkWithPathSubstitution() {
WebMvcLinkBuilder linkBuilder = WebMvcLinkBuilder.linkTo(WebMvcLinkBuilder.methodOn(ClassificationController.class)
.search("query", null, true, null, null));
String link = ResourceUtil.createUriTemplateBuilder(linkBuilder).basePath("/api/klass/")
String link = ResourceUtil.createUriTemplateBuilder(linkBuilder)
.variables("query", "includeCodelists").build().toString();
assertTrue(link.endsWith("/api/klass/v1/classifications/search{?query,includeCodelists}"));
link = link.replace("http://localhost", "");
assertEquals("/api/klass/v1/classifications/search{?query,includeCodelists}", link);
}
}

0 comments on commit 59d67ec

Please sign in to comment.