Package org.springframework.hateoas

Examples of org.springframework.hateoas.Link


      ResourceMapping propertyMapping = propertyMappings.getMappingFor(property);

      String href = path.slash(propertyMapping.getPath()).toString();
      String rel = propertyMapping.getRel();

      return Collections.singletonList(new Link(href, rel));
    }

    return Collections.emptyList();
  }
View Full Code Here


    MongoPersistentEntity<?> entity = context.getPersistentEntity(Profile.class);
    ResourceMetadata metadata = new MappingResourceMetadata(entity);

    RepositoryLinkBuilder builder = new RepositoryLinkBuilder(metadata, new BaseUri(baseUri));
    Link link = builder.withSelfRel();

    assertThat(link.getHref(), is(expectedUri));
  }
View Full Code Here

      if (LOG.isDebugEnabled()) {
        LOG.debug("Serializing PersistentEntity " + resource.getPersistentEntity());
      }

      final Link id = resource.getId();

      if (id == null) {
        throw new JsonGenerationException(String.format("No self link found resource %s!", resource));
      }

      List<Link> links = new ArrayList<Link>();
      links.addAll(resource.getLinks());

      Path basePath = new Path(id.expand().getHref());
      LinkCollectingAssociationHandler associationHandler = new LinkCollectingAssociationHandler(entities, basePath,
          associationLinks);
      resource.getPersistentEntity().doWithAssociations(associationHandler);

      for (Link link : associationHandler.getLinks()) {
View Full Code Here

    if (searchMappings.isExported()) {
      links.add(entityLinks.linkFor(metadata.getDomainType()).slash(searchMappings.getPath())
          .withRel(searchMappings.getRel()));
    }

    Link baseLink = entityLinks.linkToPagedResource(resourceInformation.getDomainType(), pageable.isDefault() ? null
        : pageable.getPageable());

    Resources<?> resources = resultToResources(results, assembler, baseLink);
    resources.add(links);
    return resources;
View Full Code Here

  @Test
  public void accessPersons() throws Exception {

    MockHttpServletResponse response = request("/people?page=0&size=1");

    Link nextLink = assertHasLinkWithRel(Link.REL_NEXT, response);
    assertDoesNotHaveLinkWithRel(Link.REL_PREVIOUS, response);

    response = request(nextLink);
    assertHasLinkWithRel(Link.REL_PREVIOUS, response);
    nextLink = assertHasLinkWithRel(Link.REL_NEXT, response);
View Full Code Here

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

    MockHttpServletResponse response = request("/");
    Link ordersLink = assertHasLinkWithRel("orders", response);

    MockHttpServletResponse orders = request(ordersLink);
    Link creatorLink = assertHasContentLinkWithRel("creator", orders);

    assertThat(request(creatorLink), is(notNullValue()));
  }
View Full Code Here

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

    MockHttpServletResponse response = request("/");
    Link ordersLink = assertHasLinkWithRel("orders", response);

    MockHttpServletResponse orders = request(ordersLink);
    assertHasJsonPathValue("$..lineItems", orders);
  }
View Full Code Here

   * @see DATAREST-117
   */
  @Test
  public void createPersonThenVerifyIgnoredAttributesDontExist() throws Exception {

    Link peopleLink = discoverUnique("people");
    ObjectMapper mapper = new ObjectMapper();
    Person frodo = new Person("Frodo", "Baggins");
    frodo.setAge(77);
    frodo.setHeight(42);
    frodo.setWeight(75);
View Full Code Here

   * @see DATAREST-95
   */
  @Test
  public void createThenPatch() throws Exception {

    Link peopleLink = discoverUnique("people");

    MockHttpServletResponse bilbo = postAndGet(peopleLink, "{ \"firstName\" : \"Bilbo\", \"lastName\" : \"Baggins\" }",
        MediaType.APPLICATION_JSON);

    Link bilboLink = assertHasLinkWithRel("self", bilbo);

    assertThat((String) JsonPath.read(bilbo.getContentAsString(), "$.firstName"), is("Bilbo"));
    assertThat((String) JsonPath.read(bilbo.getContentAsString(), "$.lastName"), is("Baggins"));

    MockHttpServletResponse frodo = patchAndGet(bilboLink, "{ \"firstName\" : \"Frodo\" }", MediaType.APPLICATION_JSON);
View Full Code Here

   * @see DATAREST-150
   */
  @Test
  public void createThenPut() throws Exception {

    Link peopleLink = discoverUnique("people");

    MockHttpServletResponse bilbo = postAndGet(peopleLink,//
        "{ \"firstName\" : \"Bilbo\", \"lastName\" : \"Baggins\" }",//
        MediaType.APPLICATION_JSON);

    Link bilboLink = assertHasLinkWithRel("self", bilbo);

    assertThat((String) JsonPath.read(bilbo.getContentAsString(), "$.firstName"), equalTo("Bilbo"));
    assertThat((String) JsonPath.read(bilbo.getContentAsString(), "$.lastName"), equalTo("Baggins"));

    MockHttpServletResponse frodo = putAndGet(bilboLink,//
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.