List of usage examples for org.springframework.data.domain Page getNumberOfElements
int getNumberOfElements();
From source file:de.olivergierke.deepdive.CustomerRepositoryIntegrationTest.java
/** * @since Step 4.1//from w w w . j av a2 s .c om */ @Test public void accessesCustomersPageByPage() { Page<Customer> result = repository.findAll(new PageRequest(1, 1)); assertThat(result, is(notNullValue())); assertThat(result.isFirst(), is(false)); assertThat(result.isLast(), is(false)); assertThat(result.getNumberOfElements(), is(1)); }
From source file:org.jblogcms.core.comment.repository.CommentRepositoryItTest.java
@Test @Transactional/*from w w w. j a va2 s .c om*/ public void testFindFavoriteComments_returnOneComment() throws Exception { Page<Comment> comments = commentRepository.findFavoriteComments(ACCOUNT_2_ID, pageable); Assert.assertEquals(1, comments.getNumberOfElements()); Assert.assertEquals(COMMENT_2_ID, comments.getContent().get(0).getId()); Assert.assertEquals(COMMENT_2_TEXT, comments.getContent().get(0).getText()); Assert.assertEquals(COMMENT_2_ACCOUNT_2_ID, comments.getContent().get(0).getAccount().getId()); Assert.assertEquals(COMMENT_2_ACCOUNT_2_NAME, comments.getContent().get(0).getAccount().getName()); Assert.assertEquals(COMMENT_2_POST_1_ID, comments.getContent().get(0).getPost().getId()); Assert.assertEquals(COMMENT_2_POST_1_TITLE, comments.getContent().get(0).getPost().getTitle()); }
From source file:org.jblogcms.core.comment.repository.CommentRepositoryItTest.java
@Test @Transactional//from w w w.java 2s . com public void testFindCommentsByAccountId_returnOneComment() throws Exception { Page<Comment> comments = commentRepository.findCommentsByAccountId(ACCOUNT_2_ID, pageable); Assert.assertEquals(1, comments.getNumberOfElements()); Assert.assertEquals(COMMENT_2_ID, comments.getContent().get(0).getId()); Assert.assertEquals(COMMENT_2_TEXT, comments.getContent().get(0).getText()); Assert.assertEquals(COMMENT_2_ACCOUNT_2_ID, comments.getContent().get(0).getAccount().getId()); Assert.assertEquals(COMMENT_2_ACCOUNT_2_NAME, comments.getContent().get(0).getAccount().getName()); Assert.assertEquals(COMMENT_2_POST_1_ID, comments.getContent().get(0).getPost().getId()); Assert.assertEquals(COMMENT_2_POST_1_TITLE, comments.getContent().get(0).getPost().getTitle()); }
From source file:org.jblogcms.core.comment.repository.CommentRepositoryItTest.java
@Test @Transactional/* w w w . j av a2 s. co m*/ public void testFindFavoriteComments_returnTwoComments() throws Exception { Page<Comment> comments = commentRepository.findFavoriteComments(ACCOUNT_1_ID, pageable); Assert.assertEquals(2, comments.getNumberOfElements()); Assert.assertEquals(COMMENT_1_ID, comments.getContent().get(0).getId()); Assert.assertEquals(COMMENT_1_TEXT, comments.getContent().get(0).getText()); Assert.assertEquals(COMMENT_1_ACCOUNT_1_ID, comments.getContent().get(0).getAccount().getId()); Assert.assertEquals(COMMENT_1_ACCOUNT_1_NAME, comments.getContent().get(0).getAccount().getName()); Assert.assertEquals(COMMENT_1_POST_2_ID, comments.getContent().get(0).getPost().getId()); Assert.assertEquals(COMMENT_1_POST_2_TITLE, comments.getContent().get(0).getPost().getTitle()); Assert.assertEquals(COMMENT_2_ID, comments.getContent().get(1).getId()); Assert.assertEquals(COMMENT_2_TEXT, comments.getContent().get(1).getText()); Assert.assertEquals(COMMENT_2_ACCOUNT_2_ID, comments.getContent().get(1).getAccount().getId()); Assert.assertEquals(COMMENT_2_ACCOUNT_2_NAME, comments.getContent().get(1).getAccount().getName()); Assert.assertEquals(COMMENT_2_POST_1_ID, comments.getContent().get(1).getPost().getId()); Assert.assertEquals(COMMENT_2_POST_1_TITLE, comments.getContent().get(1).getPost().getTitle()); }
From source file:org.jblogcms.core.comment.repository.CommentRepositoryItTest.java
@Test @Transactional// w ww . ja va2 s . co m public void testFindCommentsByAccountId_returNoComments() throws Exception { Page<Comment> comments = commentRepository.findCommentsByAccountId(ACCOUNT_WITH_NO_COMMENTS, pageable); Assert.assertEquals(0, comments.getNumberOfElements()); }
From source file:org.jblogcms.core.comment.repository.CommentRepositoryItTest.java
@Test @Transactional/*from w w w . j av a 2 s.co m*/ public void testFindCommentsByAccountId_returnTwoComments() throws Exception { Page<Comment> comments = commentRepository.findCommentsByAccountId(ACCOUNT_1_ID, pageable); Assert.assertEquals(2, comments.getNumberOfElements()); Assert.assertEquals(COMMENT_1_ID, comments.getContent().get(0).getId()); Assert.assertEquals(COMMENT_1_TEXT, comments.getContent().get(0).getText()); Assert.assertEquals(COMMENT_1_ACCOUNT_1_ID, comments.getContent().get(0).getAccount().getId()); Assert.assertEquals(COMMENT_1_ACCOUNT_1_NAME, comments.getContent().get(0).getAccount().getName()); Assert.assertEquals(COMMENT_1_POST_2_ID, comments.getContent().get(0).getPost().getId()); Assert.assertEquals(COMMENT_1_POST_2_TITLE, comments.getContent().get(0).getPost().getTitle()); Assert.assertEquals(COMMENT_3_ID, comments.getContent().get(1).getId()); Assert.assertEquals(COMMENT_3_TEXT, comments.getContent().get(1).getText()); Assert.assertEquals(COMMENT_3_ACCOUNT_1_ID, comments.getContent().get(1).getAccount().getId()); Assert.assertEquals(COMMENT_3_ACCOUNT_1_NAME, comments.getContent().get(1).getAccount().getName()); Assert.assertEquals(COMMENT_3_POST_1_ID, comments.getContent().get(1).getPost().getId()); Assert.assertEquals(COMMENT_3_POST_1_TITLE, comments.getContent().get(1).getPost().getTitle()); }
From source file:org.openlmis.fulfillment.repository.ShipmentRepositoryIntegrationTest.java
@Test public void shouldFindShipmentPageByOrder() { Shipment save = shipmentRepository.save(generateInstance()); Page<Shipment> page = shipmentRepository.findByOrder(order, createPageable(10, 0)); assertEquals(1, page.getContent().size()); assertEquals(save.getId(), page.getContent().get(0).getId()); assertEquals(10, page.getSize());//ww w. ja v a2 s. c om assertEquals(0, page.getNumber()); assertEquals(1, page.getNumberOfElements()); assertEquals(1, page.getTotalElements()); assertEquals(1, page.getTotalPages()); }
From source file:org.jblogcms.core.comment.repository.CommentRepositoryItTest.java
@Test @Transactional/*from w w w .j a v a2s . com*/ public void testFindFavoriteComments_returnNoComments() throws Exception { Page<Comment> comments = commentRepository.findFavoriteComments(ACCOUNT_WITH_NO_FAVORITE_COMMENTS, pageable); Assert.assertEquals(0, comments.getNumberOfElements()); }
From source file:demo.CustomerRepositoryIntegrationTest.java
/** * @since Step 4.1/*from w ww . j ava2 s . c om*/ */ @Test public void accessesCustomersPageByPage() { Page<Customer> result = repository.findAll(new PageRequest(/* page:*/ 1, /* page size:*/ 1)); assertThat(result).isNotNull(); assertThat(result.isFirst()).isFalse(); assertThat(result.isLast()).isFalse(); assertThat(result.getNumberOfElements()).isEqualTo(1); }
From source file:org.openlmis.fulfillment.repository.ShipmentDraftRepositoryIntegrationTest.java
@Test public void shouldFindShipmentDraftPageByOrder() { ShipmentDraft save = shipmentDraftRepository.save(generateInstance()); Page<ShipmentDraft> page = shipmentDraftRepository.findByOrder(order, createPageable(10, 0)); assertEquals(1, page.getContent().size()); assertEquals(save.getId(), page.getContent().get(0).getId()); assertEquals(10, page.getSize());//from www. j a va 2 s . c o m assertEquals(0, page.getNumber()); assertEquals(1, page.getNumberOfElements()); assertEquals(1, page.getTotalElements()); assertEquals(1, page.getTotalPages()); }