List of usage examples for org.springframework.data.domain Page getTotalElements
long getTotalElements();
From source file:org.jblogcms.core.account.repository.AccountRepositoryItTest.java
@Test @Transactional/*w w w. j a v a 2s .c o m*/ public void testFindFavoriteAccounts_returnTwoAccounts() throws Exception { Page<Account> accounts = accountRepository.findFavoriteAccounts(ACCOUNT_1_ID, pageable); Assert.assertEquals(2, accounts.getTotalElements()); Assert.assertEquals(ACCOUNT_2_ID, accounts.getContent().get(0).getId()); Assert.assertEquals(ACCOUNT_2_EMAIL, accounts.getContent().get(0).getEmail()); Assert.assertEquals(ACCOUNT_3_ID, accounts.getContent().get(1).getId()); Assert.assertEquals(ACCOUNT_3_EMAIL, accounts.getContent().get(1).getEmail()); }
From source file:org.schedoscope.metascope.repository.MetascopeViewRepositoryTest.java
@Test public void findByTableFqdnOrderByViewIdTest() { Page<MetascopeView> views = metascopeViewRepository.findByTableFqdnOrderByViewId(metascopeTable.getFqdn(), pageable);/*from w w w . j a va2s . co m*/ assertNotNull(views); assertEquals(2, views.getTotalElements()); }
From source file:com.github.markserrano.jsonquery.jpa.service.OrderServiceTest.java
@Test public void testReadAndCount_OrderById_ASC() { String filter = "{\"groupOp\":\"AND\",\"rules\":" + "[{\"field\":\"parent.store\",\"op\":\"ne\",\"data\":\"StoreB\"}," + "{\"field\":\"parent.thing.id\",\"op\":\"ne\",\"data\":\"1\"}]" + "}"; BooleanBuilder builder = jsonBooleanBuilder.build(new JsonFilter(filter)); orderSpecifier = order.by("id", OrderEnum.ASC); Page<Child> results = service.readAndCount(builder, new PageRequest(0, 3), Child.class, orderSpecifier); Assert.assertNotNull(results);// w ww .j av a 2 s .com Assert.assertEquals(2, results.getTotalElements()); Assert.assertEquals("StoreC", results.getContent().get(0).getParent().getStore()); Assert.assertEquals("StoreD", results.getContent().get(1).getParent().getStore()); }
From source file:com.github.markserrano.jsonquery.jpa.service.OrderServiceTest.java
@Test public void testReadAndCount_OrderById_DESC() { String filter = "{\"groupOp\":\"AND\",\"rules\":" + "[{\"field\":\"parent.store\",\"op\":\"ne\",\"data\":\"StoreB\"}," + "{\"field\":\"parent.thing.id\",\"op\":\"ne\",\"data\":\"1\"}]" + "}"; BooleanBuilder builder = jsonBooleanBuilder.build(new JsonFilter(filter)); orderSpecifier = order.by("id", OrderEnum.DESC); Page<Child> results = service.readAndCount(builder, new PageRequest(0, 3), Child.class, orderSpecifier); Assert.assertNotNull(results);//from w w w .ja v a 2 s .c om Assert.assertEquals(2, results.getTotalElements()); Assert.assertEquals("StoreD", results.getContent().get(0).getParent().getStore()); Assert.assertEquals("StoreC", results.getContent().get(1).getParent().getStore()); }
From source file:com.github.markserrano.jsonquery.jpa.service.OrderServiceTest.java
@Test public void testReadAndCount_OrderByDateTime_ASC() { String filter = "{\"groupOp\":\"AND\",\"rules\":" + "[{\"field\":\"parent.store\",\"op\":\"ne\",\"data\":\"StoreB\"}," + "{\"field\":\"birthDate\",\"op\":\"gt\",\"data\":\"1995-10-01T00:00:00.000Z\"}]" + "}"; BooleanBuilder builder = jsonBooleanBuilder.build(new JsonFilter(filter)); orderSpecifier = order.by("id", OrderEnum.ASC); Page<Child> results = service.readAndCount(builder, new PageRequest(0, 3), Child.class, orderSpecifier); Assert.assertNotNull(results);//from w w w . j av a 2s .c o m Assert.assertEquals(3, results.getTotalElements()); Assert.assertEquals(fmt.parseDateTime("1995-10-05"), results.getContent().get(0).getBirthDate()); Assert.assertEquals(fmt.parseDateTime("2003-10-12"), results.getContent().get(1).getBirthDate()); Assert.assertEquals(fmt.parseDateTime("1996-01-01"), results.getContent().get(2).getBirthDate()); }
From source file:com.github.markserrano.jsonquery.jpa.service.OrderServiceTest.java
@Test public void testReadAndCount_OrderByDateTime_DESC() { String filter = "{\"groupOp\":\"AND\",\"rules\":" + "[{\"field\":\"parent.store\",\"op\":\"ne\",\"data\":\"StoreB\"}," + "{\"field\":\"birthDate\",\"op\":\"gt\",\"data\":\"1995-10-01T00:00:00.000Z\"}]" + "}"; BooleanBuilder builder = jsonBooleanBuilder.build(new JsonFilter(filter)); orderSpecifier = order.by("id", OrderEnum.DESC); Page<Child> results = service.readAndCount(builder, new PageRequest(0, 3), Child.class, orderSpecifier); Assert.assertNotNull(results);//w w w .j av a 2s . c om Assert.assertEquals(3, results.getTotalElements()); Assert.assertEquals(fmt.parseDateTime("1996-01-01"), results.getContent().get(0).getBirthDate()); Assert.assertEquals(fmt.parseDateTime("2003-10-12"), results.getContent().get(1).getBirthDate()); Assert.assertEquals(fmt.parseDateTime("1995-10-05"), results.getContent().get(2).getBirthDate()); }
From source file:org.jblogcms.core.account.repository.AccountRepositoryItTest.java
@Test @Transactional//from ww w . ja v a2 s . co m public void testFindAccountSubscribers_returnNoAccounts() throws Exception { Page<Account> accounts = accountRepository.findAccountSubscribers(ACCOUNT_WITH_NO_SUBSCRIBERS, pageable); Assert.assertEquals(0, accounts.getTotalElements()); }
From source file:com.pamarin.income.lazyload.LazyLoad.java
@Override public List<T> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) { Sort.Direction direction;/* w w w. j av a 2 s .co m*/ if (sortOrder == SortOrder.ASCENDING) { direction = Sort.Direction.ASC; } else { direction = Sort.Direction.DESC; } if (sortField == null) { sortField = "id"; } Page<T> page = load(new PageRequest(first / pageSize, pageSize, direction, sortField)); if (page != null) { list = page.getContent(); totalElements = page.getTotalElements(); this.setRowCount((int) totalElements); } else { list = null; totalElements = 0L; setRowCount(0); } return list; }
From source file:org.jblogcms.core.account.repository.AccountRepositoryItTest.java
@Test @Transactional/*www . ja v a 2s .c o m*/ public void testFindFavoriteAccounts_returnNoAccounts() throws Exception { Page<Account> accounts = accountRepository.findFavoriteAccounts(ACCOUNT_WITH_NO_FAVORITE_ACCOUNTS, pageable); Assert.assertEquals(0, accounts.getTotalElements()); }
From source file:com.epam.ta.reportportal.ws.converter.PagedResourcesAssembler.java
/** * Creates {@link com.epam.ta.reportportal.ws.model.Page} from {@link Page} DB query result * * @param content Page to be processed/*w w w . java 2 s . c o m*/ * @return Transformed Page * @deprecated in favor of using converters based on JDK8 Functions */ @Deprecated public com.epam.ta.reportportal.ws.model.Page<R> toPagedResources(Page<T> content) { Assert.notNull(content); return new com.epam.ta.reportportal.ws.model.Page<>(toResources(content), new com.epam.ta.reportportal.ws.model.Page.PageMetadata(content.getSize(), content.getNumber() + 1, content.getTotalElements(), content.getTotalPages())); }