List of usage examples for org.springframework.data.domain Page getNumberOfElements
int getNumberOfElements();
From source file:com.netflix.genie.core.jpa.services.JpaApplicationServiceImplIntegrationTests.java
/** * Test the get applications method with descending sort. *//*from w w w . j av a2 s . co m*/ @Test public void testGetClustersDescending() { //Default to order by Updated final Page<Application> applications = this.appService.getApplications(null, null, null, null, null, PAGEABLE); Assert.assertEquals(3, applications.getNumberOfElements()); Assert.assertEquals(APP_3_ID, applications.getContent().get(0).getId().orElseThrow(IllegalArgumentException::new)); Assert.assertEquals(APP_2_ID, applications.getContent().get(1).getId().orElseThrow(IllegalArgumentException::new)); Assert.assertEquals(APP_1_ID, applications.getContent().get(2).getId().orElseThrow(IllegalArgumentException::new)); }
From source file:com.netflix.genie.core.jpa.services.JpaApplicationServiceImplIntegrationTests.java
/** * Test the get applications method default order by. *///from w w w .j a v a 2 s. c om @Test public void testGetClustersOrderBysDefault() { //Default to order by Updated final Page<Application> applications = this.appService.getApplications(null, null, null, null, null, PAGEABLE); Assert.assertEquals(3, applications.getNumberOfElements()); Assert.assertEquals(APP_3_ID, applications.getContent().get(0).getId().orElseThrow(IllegalArgumentException::new)); Assert.assertEquals(APP_2_ID, applications.getContent().get(1).getId().orElseThrow(IllegalArgumentException::new)); Assert.assertEquals(APP_1_ID, applications.getContent().get(2).getId().orElseThrow(IllegalArgumentException::new)); }
From source file:com.netflix.genie.core.jpa.services.JpaApplicationServiceImplIntegrationTests.java
/** * Test the get applications method with ascending sort. *//*from www .j a v a2 s. c o m*/ @Test public void testGetClustersAscending() { //Default to order by Updated final Pageable ascendingPage = new PageRequest(0, 10, Sort.Direction.ASC, "updated"); final Page<Application> applications = this.appService.getApplications(null, null, null, null, null, ascendingPage); Assert.assertEquals(3, applications.getNumberOfElements()); Assert.assertEquals(APP_1_ID, applications.getContent().get(0).getId().orElseThrow(IllegalArgumentException::new)); Assert.assertEquals(APP_2_ID, applications.getContent().get(1).getId().orElseThrow(IllegalArgumentException::new)); Assert.assertEquals(APP_3_ID, applications.getContent().get(2).getId().orElseThrow(IllegalArgumentException::new)); }
From source file:com.netflix.genie.core.jpa.services.JpaApplicationServiceImplIntegrationTests.java
/** * Test the get applications method order by name. *//* w ww .j av a 2 s .com*/ @Test public void testGetClustersOrderBysName() { final Pageable orderByNamePage = new PageRequest(0, 10, Sort.Direction.DESC, "name"); final Page<Application> applications = this.appService.getApplications(null, null, null, null, null, orderByNamePage); Assert.assertEquals(3, applications.getNumberOfElements()); Assert.assertEquals(APP_1_ID, applications.getContent().get(0).getId().orElseThrow(IllegalArgumentException::new)); Assert.assertEquals(APP_3_ID, applications.getContent().get(1).getId().orElseThrow(IllegalArgumentException::new)); Assert.assertEquals(APP_2_ID, applications.getContent().get(2).getId().orElseThrow(IllegalArgumentException::new)); }
From source file:com.netflix.genie.core.jpa.services.JpaClusterServiceImplIntegrationTests.java
/** * Test the get clusters method with descending sort. *//* w w w . ja v a 2 s . co m*/ @Test public void testGetClustersDescending() { //Default to order by Updated final Page<Cluster> clusters = this.service.getClusters(null, null, null, null, null, PAGE); Assert.assertEquals(2, clusters.getNumberOfElements()); Assert.assertEquals(CLUSTER_2_ID, clusters.getContent().get(0).getId().orElseThrow(IllegalArgumentException::new)); Assert.assertEquals(CLUSTER_1_ID, clusters.getContent().get(1).getId().orElseThrow(IllegalArgumentException::new)); }
From source file:org.yukung.daguerreo.domain.repository.BasicJooqRepositoryTest.java
@Test public void findAllByPageableNothing() throws Exception { // given//from w ww. j a v a 2 s .co m dbSetupTracker.skipNextLaunch(); Pageable nothing = null; // when Page<BookApi> bookApis = repository.findAll(nothing); // then assertThat(bookApis).isNotNull().isNotEmpty().hasSize(3).extracting("id", "name", "url").containsExactly( tuple(1, "Amazon Product Advertising API", "https://ecs.amazonaws.jp/onca/xml"), tuple(2, "Google Books API", "https://www.googleapis.com/books/v1/volumes"), tuple(3, "?API", "https://app.rakuten.co.jp/services/api/BooksBook/Search/20130522")); assertThat(bookApis.getNumber()).isEqualTo(0); assertThat(bookApis.getNumberOfElements()).isEqualTo(3); assertThat(bookApis.getSize()).isEqualTo(0); assertThat(bookApis.getTotalPages()).isEqualTo(1); assertThat(bookApis.getTotalElements()).isEqualTo(3); assertThat(bookApis.isFirst()).isTrue(); assertThat(bookApis.isLast()).isTrue(); assertThat(bookApis.hasNext()).isFalse(); assertThat(bookApis.hasPrevious()).isFalse(); }
From source file:com.netflix.genie.core.jpa.services.JpaClusterServiceImplIntegrationTests.java
/** * Test the get clusters method order by name. */// w w w. ja va 2 s . c om @Test public void testGetClustersOrderBysUser() { final Pageable userPage = new PageRequest(0, 10, Sort.Direction.DESC, "user"); final Page<Cluster> clusters = this.service.getClusters(null, null, null, null, null, userPage); Assert.assertEquals(2, clusters.getNumberOfElements()); Assert.assertEquals(CLUSTER_1_ID, clusters.getContent().get(0).getId().orElseThrow(IllegalArgumentException::new)); Assert.assertEquals(CLUSTER_2_ID, clusters.getContent().get(1).getId().orElseThrow(IllegalArgumentException::new)); }
From source file:com.netflix.genie.core.jpa.services.JpaClusterServiceImplIntegrationTests.java
/** * Test the get clusters method order by a collection field should return the order by default value (updated). *//* w w w .j a va 2s. c o m*/ @Ignore @Test public void testGetClustersOrderBysCollectionField() { final Pageable tagPage = new PageRequest(0, 10, Sort.Direction.DESC, "tags"); final Page<Cluster> clusters = this.service.getClusters(null, null, null, null, null, tagPage); Assert.assertEquals(2, clusters.getNumberOfElements()); Assert.assertEquals(CLUSTER_2_ID, clusters.getContent().get(0).getId().orElseThrow(IllegalArgumentException::new)); Assert.assertEquals(CLUSTER_1_ID, clusters.getContent().get(1).getId().orElseThrow(IllegalArgumentException::new)); }
From source file:com.netflix.genie.core.jpa.services.JpaClusterServiceImplIntegrationTests.java
/** * Test the get clusters method.// w w w. java 2s. c o m */ @Test public void testGetClustersByStatuses() { final Set<ClusterStatus> statuses = EnumSet.noneOf(ClusterStatus.class); statuses.add(ClusterStatus.UP); final Page<Cluster> clusters = this.service.getClusters(null, statuses, null, null, null, PAGE); Assert.assertEquals(2, clusters.getNumberOfElements()); Assert.assertEquals(CLUSTER_2_ID, clusters.getContent().get(0).getId().orElseThrow(IllegalArgumentException::new)); Assert.assertEquals(CLUSTER_1_ID, clusters.getContent().get(1).getId().orElseThrow(IllegalArgumentException::new)); }
From source file:com.netflix.genie.core.jpa.services.JpaClusterServiceImplIntegrationTests.java
/** * Test the get clusters method./*w w w . j av a2 s . c om*/ */ @Test public void testGetClustersByName() { final Page<Cluster> clusters = this.service.getClusters(CLUSTER_2_NAME, null, null, null, null, PAGE); Assert.assertEquals(1, clusters.getNumberOfElements()); Assert.assertEquals(CLUSTER_2_ID, clusters.getContent().get(0).getId().orElseThrow(IllegalArgumentException::new)); }