Package org.springframework.hateoas

Examples of org.springframework.hateoas.EntityLinks


  @Test
  @SuppressWarnings("unchecked")
  public void registersControllerForEntity() {

    when(linkBuilderFactory.linkTo(SampleController.class, new Object[0])).thenReturn(linkTo(SampleController.class));
    EntityLinks links = new ControllerEntityLinks(Arrays.asList(SampleController.class), linkBuilderFactory);

    assertThat(links.supports(Person.class), is(true));
    assertThat(links.linkFor(Person.class), is(notNullValue()));
  }
View Full Code Here


  @Test
  @SuppressWarnings("unchecked")
  public void rejectsUnmanagedEntity() {

    EntityLinks links = new ControllerEntityLinks(
        Arrays.asList(SampleController.class, ControllerWithParameters.class), linkBuilderFactory);

    assertThat(links.supports(Person.class), is(true));
    assertThat(links.supports(Order.class), is(true));
    assertThat(links.supports(SampleController.class), is(false));

    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage(SampleController.class.getName());
    thrown.expectMessage(ExposesResourceFor.class.getName());
    links.linkFor(SampleController.class);
  }
View Full Code Here

  public void throwsExceptionForUnsupportedClass() {

    exception.expect(IllegalArgumentException.class);
    exception.expectMessage(String.class.getName());

    EntityLinks links = new DelegatingEntityLinks(SimplePluginRegistry.<Class<?>, EntityLinks> create());
    links.linkFor(String.class);
  }
View Full Code Here

  }

  @Test
  public void supportsDomainTypeBackedByPlugin() {

    EntityLinks links = createDelegatingEntityLinks();

    assertThat(links.supports(String.class), is(true));
  }
View Full Code Here

  }

  @Test
  public void delegatesLinkForCall() {

    EntityLinks links = createDelegatingEntityLinks();

    links.linkFor(String.class);
    verify(target, times(1)).linkFor(String.class);
  }
View Full Code Here

   * @param type must not be {@literal null}.
   * @return
   */
  private EntityLinks getPluginFor(Class<?> type) {

    EntityLinks plugin = delegates.getPluginFor(type);

    if (plugin == null) {
      throw new IllegalArgumentException(String.format(
          "Cannot determine link for %s! No EntityLinks instance found supporting the domain type!", type.getName()));
    }
View Full Code Here

  @Test
  public void entityLinksCreated() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.register(HypermediaAutoConfiguration.class);
    this.context.refresh();
    EntityLinks discoverers = this.context.getBean(EntityLinks.class);
    assertNotNull(discoverers);
  }
View Full Code Here

TOP

Related Classes of org.springframework.hateoas.EntityLinks

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.