Package org.springframework.hateoas

Examples of org.springframework.hateoas.Link


   * @see DATAREST-221
   */
  @Test
  public void returnsLinkWithProjectionTemplateVariableIfProjectionIsDefined() {

    Link link = entityLinks.linkToSingleResource(Order.class, 1);

    assertThat(link.isTemplated(), is(true));
    assertThat(link.getVariableNames(), hasItem(configuration.projectionConfiguration().getParameterName()));
  }
View Full Code Here


   * @see DATAREST-155
   */
  @Test
  public void usesCustomGeneratedBackendId() {

    Link link = entityLinks.linkToSingleResource(Book.class, 7L);
    assertThat(link.expand().getHref(), endsWith("/7-7-7-7-7-7-7"));
  }
View Full Code Here

   * @see DATAREST-317
   */
  @Test
  public void adaptsToExistingPageable() {

    Link link = entityLinks.linkToPagedResource(Person.class, new PageRequest(0, 10));

    assertThat(link.isTemplated(), is(true));
    assertThat(link.getVariableNames(), hasSize(2));
    assertThat(link.getVariableNames(), hasItems("sort", "projection"));
  }
View Full Code Here

   */
  @Test
  public void deletesCustomer() throws Exception {

    // Lookup customer
    Link customers = discoverUnique("customers");
    Link customerLink = assertHasContentLinkWithRel("self", request(customers));

    // Delete customer
    mvc.perform(delete(customerLink.getHref()));

    // Assert no customers anymore
    assertDoesNotHaveContentLinkWithRel("self", request(customers));
  }
View Full Code Here

    return assertHasLinkMatching(rel, hrefEnd == null ? null : endsWith(hrefEnd));
  }

  private final Link assertHasLinkMatching(String rel, Matcher<String> hrefMatcher) {

    Link link = resource.getLink(rel);
    assertThat("Expected link with rel '" + rel + "' but didn't find it in " + resource.getLinks(), link,
        is(notNullValue()));

    if (hrefMatcher != null) {
      assertThat(link.getHref(), is(hrefMatcher));
    }

    return link;
  }
View Full Code Here

  }

  @Test
  public void usesHeaderLinksResponseEntityIfConfigured() throws Exception {

    Resource<String> resource = new Resource<String>("foo", new Link("href", "rel"));
    MethodParameter parameter = METHOD_PARAMS.get("resource");

    ResourceProcessorHandlerMethodReturnValueHandler handler = new ResourceProcessorHandlerMethodReturnValueHandler(
        delegate, resourceProcessors);
    handler.setRootLinksAsHeaders(true);
View Full Code Here

      @Override
      public Resource<Person> process(Resource<Person> resource) {
        System.out.println("processing " + resource);
        System.out.println("url: " + config.getBaseUri().toString());
        resource.add(new Link("http://host:port/path", "myrel"));
        return resource;
      }
    };
  }
View Full Code Here

  protected Link resourceLink(RootResourceInformation resourceLink, Resource resource) {

    ResourceMetadata repoMapping = resourceLink.getResourceMetadata();

    Link selfLink = resource.getLink("self");
    String rel = repoMapping.getItemResourceRel();

    return new Link(selfLink.getHref(), rel);
  }
View Full Code Here

  @Bean
  public ResourceProcessor<RepositoryLinksResource> rootLinksResourceProcessor() {
    return new ResourceProcessor<RepositoryLinksResource>() {
      @Override
      public RepositoryLinksResource process(RepositoryLinksResource resource) {
        resource.add(new Link("href", "rel"));
        return resource;
      }
    };
  }
View Full Code Here

        jsonSchema.addProperty(persistentProperty.getName(), property);
      }
    });

    Link link = entityLinks.linkToCollectionResource(persistentEntity.getType()).expand();

    LinkCollectingAssociationHandler associationHandler = new LinkCollectingAssociationHandler(repositories, new Path(
        link.getHref()), new AssociationLinks(mappings));
    persistentEntity.doWithAssociations(associationHandler);

    jsonSchema.add(associationHandler.getLinks());

    return jsonSchema;
View Full Code Here

TOP

Related Classes of org.springframework.hateoas.Link

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.