Package org.springframework.hateoas

Examples of org.springframework.hateoas.LinkBuilder


  private Links getSearchLinks(Class<?> domainType) {

    List<Link> links = new ArrayList<Link>();

    SearchResourceMappings searchMappings = mappings.getSearchResourceMappings(domainType);
    LinkBuilder builder = entityLinks.linkFor(domainType).slash(searchMappings.getPath());

    for (MethodResourceMapping mapping : searchMappings) {

      if (!mapping.isExported()) {
        continue;
      }

      TemplateVariables variables = new TemplateVariables();

      for (ParameterMetadata metadata : mapping.getParametersMetadata()) {
        variables = variables.concat(new TemplateVariable(metadata.getName(), VariableType.REQUEST_PARAM));
      }

      String href = builder.slash(mapping.getPath()).toString().concat(variables.toString());

      Link link = new Link(href, mapping.getRel());

      if (mapping.isPagingResource()) {
        link = assembler.appendPaginationParameterTemplates(link);
View Full Code Here


    Person second = new Person();
    second.id = 2L;

    List<PersonResource> result = assembler.toResources(Arrays.asList(first, second));

    LinkBuilder builder = linkTo(PersonController.class);

    PersonResource firstResource = new PersonResource();
    firstResource.add(builder.slash(1L).withSelfRel());

    PersonResource secondResource = new PersonResource();
    secondResource.add(builder.slash(1L).withSelfRel());

    assertThat(result.size(), is(2));
    assertThat(result, hasItems(firstResource, secondResource));
  }
View Full Code Here

    when(linkBuilderFactory.linkTo(eq(ControllerWithParameters.class), Mockito.any(Object[].class))).thenReturn(
        linkTo(ControllerWithParameters.class, "1"));

    ControllerEntityLinks links = new ControllerEntityLinks(Arrays.asList(ControllerWithParameters.class),
        linkBuilderFactory);
    LinkBuilder builder = links.linkFor(Order.class, "1");

    assertThat(builder.withSelfRel().getHref(), CoreMatchers.endsWith("/person/1"));
  }
View Full Code Here

TOP

Related Classes of org.springframework.hateoas.LinkBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.