Package org.springframework.hateoas

Examples of org.springframework.hateoas.Link.expand()


    Link countByTypeLink = discoverUnique(profileSearches, "countByType");

    assertThat(countByTypeLink.isTemplated(), is(true));
    assertThat(countByTypeLink.getVariableNames(), hasItem("type"));

    MockHttpServletResponse response = request(countByTypeLink.expand("Twitter"));
    assertThat(response.getContentAsString(), is("1"));
  }

  @Test
  public void testname() throws Exception {
View Full Code Here


      }

      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

   */
  @Test
  public void usesCustomGeneratedBackendId() {

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

  /**
   * @see DATAREST-317
   */
 
View Full Code Here

    assertJsonPathEquals("$.firstName", "Daenerys", createdPerson);

    Link searchLink = discoverUnique(peopleLink, "search");
    Link byFirstNameLink = discoverUnique(searchLink, "findFirstPersonByFirstName");

    MockHttpServletResponse response = request(byFirstNameLink.expand("Daenerys"),
        MediaType.parseMediaType("application/x-spring-data-compact+json"));

    String responseBody = response.getContentAsString();

    JSONArray personLinks = JsonPath.<JSONArray> read(responseBody, "$.links[?(@.rel=='person')].href");
View Full Code Here

    // Assert sort options advertised
    assertThat(findBySortedLink.isTemplated(), is(true));
    assertThat(findBySortedLink.getVariableNames(), contains("sort"));

    // Assert results returned as specified
    follow(findBySortedLink.expand("title,desc")).//
        andExpect(jsonPath("$._embedded.books[0].title").value("Spring Data (Second Edition)")).//
        andExpect(jsonPath("$._embedded.books[1].title").value("Spring Data"));

    follow(findBySortedLink.expand("title,asc")).//
        andExpect(jsonPath("$._embedded.books[0].title").value("Spring Data")).//
View Full Code Here

    // Assert results returned as specified
    follow(findBySortedLink.expand("title,desc")).//
        andExpect(jsonPath("$._embedded.books[0].title").value("Spring Data (Second Edition)")).//
        andExpect(jsonPath("$._embedded.books[1].title").value("Spring Data"));

    follow(findBySortedLink.expand("title,asc")).//
        andExpect(jsonPath("$._embedded.books[0].title").value("Spring Data")).//
        andExpect(jsonPath("$._embedded.books[1].title").value("Spring Data (Second Edition)"));
  }

  /**
 
View Full Code Here

      if (mapping.isPagingResource()) {
        link = assembler.appendPaginationParameterTemplates(link);
      } else if (mapping.isSortableResource()) {

        TemplateVariables sortVariable = sortResolver.getSortTemplateVariables(null, UriComponentsBuilder
            .fromUriString(link.expand().getHref()).build());
        link = new Link(new UriTemplate(link.getHref()).with(sortVariable), link.getRel());
      }

      links.add(link);
    }
View Full Code Here

      // Resource
      request(link);

      // Schema - TODO:Improve by using hypermedia
      mvc.perform(get(link.expand().getHref() + "/schema").//
          accept(MediaType.parseMediaType("application/schema+json"))).//
          andExpect(status().isOk());
    }
  }
View Full Code Here

      String payload = payloads.get(rel);

      if (payload != null) {

        Link link = assertHasLinkWithRel(rel, response);
        String target = link.expand().getHref();

        MockHttpServletRequestBuilder request = post(target).//
            content(payload).//
            contentType(MediaType.APPLICATION_JSON);
View Full Code Here

    MockHttpServletResponse response = request("/");
    Link profileLink = assertHasLinkWithRel("profile", response);

    mvc.perform(//
        get(profileLink.expand().getHref()).//
            accept(ALPS_MEDIA_TYPE)).//
        andExpect(status().isOk()).//
        andExpect(content().contentType(ALPS_MEDIA_TYPE));
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.