Package org.springframework.hateoas.PagedResources

Examples of org.springframework.hateoas.PagedResources.PageMetadata


   * @return
   */
  private static <T> PageMetadata asPageMetadata(Page<T> page) {

    Assert.notNull(page, "Page must not be null!");
    return new PageMetadata(page.getSize(), page.getNumber(), page.getTotalElements(), page.getTotalPages());
  }
View Full Code Here


  @Test
  public void doesNotMatchOnNonMatchingResourcesTypes() throws Exception {

    Resource<Object> resource = new Resource<Object>(new Object());
    PagedResources<Resource<Object>> pagedResources = new PagedResources<Resource<Object>>(
        Collections.singleton(resource), new PageMetadata(1, 0, 10));

    TypeInformation<?> type = ClassTypeInformation.from(RepositoryLinksResource.class);
    assertThat(ResourcesProcessorWrapper.isValueTypeMatch(pagedResources, type), is(false));
  }
View Full Code Here

        build(user, repositories.getPersistentEntity(User.class)).//
        withLink(new Link("/users/1")).//
        build();

    PagedResources<PersistentEntityResource> persistentEntityResource = new PagedResources<PersistentEntityResource>(
        Arrays.asList(userResource), new PageMetadata(1, 0, 10));

    String result = mapper.writeValueAsString(persistentEntityResource);

    assertThat(JsonPath.read(result, "$_embedded.users[*].address"), is(notNullValue()));
  }
View Full Code Here

        build(order, repositories.getPersistentEntity(Order.class)).//
        withLink(new Link("/orders/1")).//
        build();

    PagedResources<PersistentEntityResource> persistentEntityResource = new PagedResources<PersistentEntityResource>(
        Arrays.asList(orderResource), new PageMetadata(1, 0, 10));

    String result = mapper.writeValueAsString(persistentEntityResource);

    assertThat(JsonPath.read(result, "$_embedded.orders[*].lineItems"), is(notNullValue()));
  }
View Full Code Here

  /**
   * @see #89
   */
  @Test(expected = IllegalArgumentException.class)
  public void preventsNegativePageSize() {
    new PageMetadata(-1, 0, 0);
  }
View Full Code Here

  /**
   * @see #89
   */
  @Test(expected = IllegalArgumentException.class)
  public void preventsNegativePageNumber() {
    new PageMetadata(0, -1, 0);
  }
View Full Code Here

  /**
   * @see #89
   */
  @Test(expected = IllegalArgumentException.class)
  public void preventsNegativeTotalElements() {
    new PageMetadata(0, 0, -1);
  }
View Full Code Here

  /**
   * @see #89
   */
  @Test(expected = IllegalArgumentException.class)
  public void preventsNegativeTotalPages() {
    new PageMetadata(0, 0, 0, -1);
  }
View Full Code Here

  /**
   * @see #89
   */
  @Test
  public void allowsOneIndexedPages() {
    new PageMetadata(10, 1, 0);
  }
View Full Code Here

    List<Resource<SimpleAnnotatedPojo>> content = new ArrayList<Resource<SimpleAnnotatedPojo>>();
    content.add(new Resource<SimpleAnnotatedPojo>(new SimpleAnnotatedPojo("test1", 1), new Link("localhost")));
    content.add(new Resource<SimpleAnnotatedPojo>(new SimpleAnnotatedPojo("test2", 2), new Link("localhost")));

    return new PagedResources<Resource<SimpleAnnotatedPojo>>(content, new PageMetadata(2, 0, 4), PAGINATION_LINKS);
  }
View Full Code Here

TOP

Related Classes of org.springframework.hateoas.PagedResources.PageMetadata

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.