Package org.springframework.hateoas

Examples of org.springframework.hateoas.Link


   * @return the {@link UriComponents} representing the base URI, or {@literal null} if it can't be resolved eagerly.
   */
  private UriComponents resolveBaseUri(MethodParameter parameter) {

    try {
      Link linkToMethod = linkBuilderFactory.linkTo(parameter.getDeclaringClass(), parameter.getMethod()).withSelfRel();
      return UriComponentsBuilder.fromUriString(linkToMethod.getHref()).build();
    } catch (IllegalArgumentException o_O) {
      return null;
    }
  }
View Full Code Here


    UriComponents components = builder.build();
    TemplateVariables variables = new TemplateVariables(base.getVariables());
    variables = variables.concat(pageableResolver.getPaginationTemplateVariables(getMethodParameter(), components));

    return new Link(new UriTemplate(components.toString()).with(variables), rel);
  }
View Full Code Here

   * @see DATAREST-230
   */
  @Test
  public void alpsResourceExposesResourcePerCollectionResource() throws Exception {

    Link profileLink = discoverUnique("/", "profile");

    assertThat(discoverUnique(profileLink.getHref(), "orders"), is(notNullValue()));
    assertThat(discoverUnique(profileLink.getHref(), "people"), is(notNullValue()));
  }
View Full Code Here

   * @see DATAREST-230
   */
  @Test
  public void exposesAlpsCollectionResources() throws Exception {

    Link profileLink = discoverUnique("/", "profile");
    Link peopleLink = discoverUnique(profileLink.getHref(), "people");

    mvc.perform(get(peopleLink.getHref())).//
        andDo(print()).//
        andExpect(jsonPath("$.version").value("1.0")).//
        andExpect(jsonPath("$.descriptors[*].name", hasItems("people", "person")));
  }
View Full Code Here

      } else if (content instanceof Map) {

        Map<Object, Resource<?>> map = (Map<Object, Resource<?>>) content;

        for (Entry<Object, Resource<?>> entry : map.entrySet()) {
          Link l = new Link(entry.getValue().getLink("self").getHref(), entry.getKey().toString());
          links.add(l);
        }
      }

    } else {
View Full Code Here

      while (scanner.hasNextLine()) {

        String line = scanner.nextLine();
        if (StringUtils.hasText(line)) {
          links.add(new Link(line));
        }
      }

    } finally {
      scanner.close();
View Full Code Here

  }

  @Test
  public void foo() throws Exception {

    Link profileLink = discoverUnique("profiles");
    follow(profileLink).//
        andExpect(jsonPath("$._embedded.profiles").value(hasSize(2)));
  }
View Full Code Here

  }

  @Test
  public void rendersEmbeddedDocuments() throws Exception {

    Link usersLink = discoverUnique("users");
    Link userLink = assertHasContentLinkWithRel("self", request(usersLink));
    follow(userLink).//
        andExpect(jsonPath("$.address.zipCode").value(is(notNullValue())));
  }
View Full Code Here

   * @see DATAREST-247
   */
  @Test
  public void executeQueryMethodWithPrimitiveReturnType() throws Exception {

    Link profiles = discoverUnique("profiles");
    Link profileSearches = discoverUnique(profiles, "search");
    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"));
  }
View Full Code Here

  }

  @Test
  public void testname() throws Exception {

    Link usersLink = discoverUnique("users");
    Link userLink = assertHasContentLinkWithRel("self", request(usersLink));

    MockHttpServletResponse response = patchAndGet(userLink,
        "{\"lastname\" : null, \"address\" : { \"zipCode\" : \"ZIP\"}}", MediaType.APPLICATION_JSON);

    assertThat(JsonPath.read(response.getContentAsString(), "$.lastname"), is(nullValue()));
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.