Package org.springframework.hateoas

Examples of org.springframework.hateoas.Link


  public void usesIdOfIdentifyableForPathSegment() {

    Identifiable<Long> identifyable = Mockito.mock(Identifiable.class);
    Mockito.when(identifyable.getId()).thenReturn(10L);

    Link link = linkTo(PersonControllerImpl.class).slash(identifyable).withSelfRel();
    assertThat(link.getHref(), endsWith("/people/10"));
  }
View Full Code Here


  }

  @Test
  public void appendingNullIsANoOp() {

    Link link = linkTo(PersonControllerImpl.class).slash(null).withSelfRel();
    assertThat(link.getHref(), endsWith("/people"));

    link = linkTo(PersonControllerImpl.class).slash((Object) null).withSelfRel();
    assertThat(link.getHref(), endsWith("/people"));
  }
View Full Code Here

  }

  @Test
  public void linksToMethod() {

    Link link = linkTo(methodOn(ControllerWithMethods.class).myMethod(null)).withSelfRel();
    assertPointsToMockServer(link);
    assertThat(link.getHref(), endsWith("/something/else"));
  }
View Full Code Here

  }

  @Test
  public void linksToMethodWithPathVariable() {

    Link link = linkTo(methodOn(ControllerWithMethods.class).methodWithPathVariable("1")).withSelfRel();
    assertPointsToMockServer(link);
    assertThat(link.getHref(), endsWith("/something/1/foo"));
  }
View Full Code Here

  @Test
  public void usesForwardedHostAsHostIfHeaderIsSet() {

    request.addHeader("X-Forwarded-Host", "somethingDifferent");

    Link link = linkTo(PersonControllerImpl.class).withSelfRel();
    assertThat(link.getHref(), startsWith("http://somethingDifferent"));
  }
View Full Code Here

  @Test
  public void usesForwardedSslIfHeaderIsSet() {

    request.addHeader("X-Forwarded-Ssl", "on");

    Link link = linkTo(PersonControllerImpl.class).withSelfRel();
    assertThat(link.getHref(), startsWith("https://"));
  }
View Full Code Here

  @Test
  public void usesForwardedSslIfHeaderIsSetOff() {

    request.addHeader("X-Forwarded-Ssl", "off");

    Link link = linkTo(PersonControllerImpl.class).withSelfRel();
    assertThat(link.getHref(), startsWith("http://"));
  }
View Full Code Here

  public void usesForwardedSslAndHostIfHeaderIsSet() {

    request.addHeader("X-Forwarded-Host", "somethingDifferent");
    request.addHeader("X-Forwarded-Ssl", "on");

    Link link = linkTo(PersonControllerImpl.class).withSelfRel();
    assertThat(link.getHref(), startsWith("https://somethingDifferent"));
  }
View Full Code Here

   * @see #26, #39
   */
  @Test
  public void addsRequestParametersHandedIntoSlashCorrectly() {

    Link link = linkTo(PersonController.class).slash("?foo=bar").withSelfRel();

    UriComponents components = toComponents(link);
    assertThat(components.getQuery(), is("foo=bar"));
  }
View Full Code Here

   * @see #26, #39
   */
  @Test
  public void linksToMethodWithPathVariableAndRequestParams() {

    Link link = linkTo(methodOn(ControllerWithMethods.class).methodForNextPage("1", 10, 5)).withSelfRel();

    UriComponents components = toComponents(link);
    assertThat(components.getPath(), is("/something/1/foo"));

    MultiValueMap<String, String> queryParams = components.getQueryParams();
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.