@Override public boolean hasNextPage() { return getNextPageToken() != null && !getNextPageToken().equals(""); }
@Test public void testList() throws Exception { initializeExpectedBucket(4); PageImpl<Blob> expectedBlobPage = new PageImpl<>(null, "c", blobResults); expect(storage.getOptions()).andReturn(mockOptions); expect(storage.list(BUCKET_INFO.getName())).andReturn(expectedBlobPage); replay(storage); initializeBucket(); Page<Blob> blobPage = bucket.list(); Iterator<Blob> blobInfoIterator = blobPage.getValues().iterator(); Iterator<Blob> blobIterator = blobPage.getValues().iterator(); while (blobInfoIterator.hasNext() && blobIterator.hasNext()) { assertEquals(blobInfoIterator.next(), blobIterator.next()); } assertFalse(blobInfoIterator.hasNext()); assertFalse(blobIterator.hasNext()); assertEquals(expectedBlobPage.getNextPageToken(), blobPage.getNextPageToken()); }
@Test public void testList() throws Exception { initializeExpectedDataset(4); List<Table> tableResults = ImmutableList.of( new Table(serviceMockReturnsOptions, new Table.BuilderImpl(TABLE_INFO1)), new Table(serviceMockReturnsOptions, new Table.BuilderImpl(TABLE_INFO2)), new Table(serviceMockReturnsOptions, new Table.BuilderImpl(TABLE_INFO3))); PageImpl<Table> expectedPage = new PageImpl<>(null, "c", tableResults); expect(bigquery.getOptions()).andReturn(mockOptions); expect(bigquery.listTables(DATASET_INFO.getDatasetId())).andReturn(expectedPage); replay(bigquery); initializeDataset(); Page<Table> tablePage = dataset.list(); assertArrayEquals( tableResults.toArray(), Iterables.toArray(tablePage.getValues(), Table.class)); assertEquals(expectedPage.getNextPageToken(), tablePage.getNextPageToken()); }
@Test public void testListWithOptions() throws Exception { initializeExpectedDataset(4); List<Table> tableResults = ImmutableList.of( new Table(serviceMockReturnsOptions, new Table.BuilderImpl(TABLE_INFO1)), new Table(serviceMockReturnsOptions, new Table.BuilderImpl(TABLE_INFO2)), new Table(serviceMockReturnsOptions, new Table.BuilderImpl(TABLE_INFO3))); PageImpl<Table> expectedPage = new PageImpl<>(null, "c", tableResults); expect(bigquery.getOptions()).andReturn(mockOptions); expect(bigquery.listTables(DATASET_INFO.getDatasetId(), BigQuery.TableListOption.pageSize(10L))) .andReturn(expectedPage); replay(bigquery); initializeDataset(); Page<Table> tablePage = dataset.list(BigQuery.TableListOption.pageSize(10L)); assertArrayEquals( tableResults.toArray(), Iterables.toArray(tablePage.getValues(), Table.class)); assertEquals(expectedPage.getNextPageToken(), tablePage.getNextPageToken()); }
@Test public void testPage() { final PageImpl<String> nextResult = new PageImpl<>(null, "c", NEXT_VALUES); PageImpl.NextPageFetcher<String> fetcher = new TestPageFetcher(nextResult); PageImpl<String> result = new PageImpl<>(fetcher, "c", VALUES); assertEquals(nextResult, result.getNextPage()); assertEquals("c", result.getNextPageToken()); assertEquals(VALUES, result.getValues()); }
@Override public boolean hasNextPage() { return getNextPageToken() != null && !getNextPageToken().equals(""); }