use of org.springframework.hateoas.ResourceSupport in project spring-boot by spring-projects.
the class LinksEnhancerTests method useNameAsRelIfAvailable.
@Test
public void useNameAsRelIfAvailable() throws Exception {
TestMvcEndpoint endpoint = new TestMvcEndpoint(new TestEndpoint("a"));
endpoint.setPath("something-else");
LinksEnhancer enhancer = getLinksEnhancer(Collections.singletonList((MvcEndpoint) endpoint));
ResourceSupport support = new ResourceSupport();
enhancer.addEndpointLinks(support, "");
assertThat(support.getLink("a").getHref()).contains("/something-else");
}
use of org.springframework.hateoas.ResourceSupport in project spring-boot by spring-projects.
the class LinksEnhancerTests method usePathAsRelIfNameNotAvailable.
@Test
public void usePathAsRelIfNameNotAvailable() throws Exception {
MvcEndpoint endpoint = new NoNameTestMvcEndpoint("/a", false);
LinksEnhancer enhancer = getLinksEnhancer(Collections.singletonList(endpoint));
ResourceSupport support = new ResourceSupport();
enhancer.addEndpointLinks(support, "");
assertThat(support.getLink("a").getHref()).contains("/a");
}
use of org.springframework.hateoas.ResourceSupport in project spring-boot by spring-projects.
the class LinksEnhancerTests method multipleHrefsForSameRelWhenPathIsDifferent.
@Test
public void multipleHrefsForSameRelWhenPathIsDifferent() throws Exception {
TestMvcEndpoint endpoint = new TestMvcEndpoint(new TestEndpoint("a"));
endpoint.setPath("endpoint");
TestMvcEndpoint otherEndpoint = new TestMvcEndpoint(new TestEndpoint("a"));
otherEndpoint.setPath("other-endpoint");
LinksEnhancer enhancer = getLinksEnhancer(Arrays.asList((MvcEndpoint) endpoint, otherEndpoint));
ResourceSupport support = new ResourceSupport();
enhancer.addEndpointLinks(support, "");
assertThat(support.getLinks()).haveExactly(1, getCondition("a", "endpoint"));
assertThat(support.getLinks()).haveExactly(1, getCondition("a", "other-endpoint"));
}
use of org.springframework.hateoas.ResourceSupport in project tutorials by eugenp.
the class IndexController method index.
@GetMapping
public ResourceSupport index() {
ResourceSupport index = new ResourceSupport();
index.add(linkTo(CRUDController.class).withRel("crud"));
return index;
}
use of org.springframework.hateoas.ResourceSupport in project CzechIdMng by bcvsolutions.
the class AbstractReadDtoController method get.
/**
* Returns response DTO by given backendId
*
* @param backendId
* @return
*/
@ApiOperation(value = "Read record", authorizations = { @Authorization(SwaggerConfig.AUTHENTICATION_BASIC), @Authorization(SwaggerConfig.AUTHENTICATION_CIDMST) })
public ResponseEntity<?> get(@ApiParam(value = "Record's uuid identifier or unique code, if record supports Codeable interface.", required = true) @PathVariable @NotNull String backendId) {
DTO dto = getDto(backendId);
if (dto == null) {
throw new EntityNotFoundException(getService().getEntityClass(), backendId);
}
ResourceSupport resource = toResource(dto);
if (resource == null) {
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
//
return new ResponseEntity<>(resource, HttpStatus.OK);
}
Aggregations