BlobStores { @Beta public static Iterable<StorageMetadata> listAll(BlobStore blobStore, String container, ListContainerOptions containerOptions) { return listAll(blobStore, container, containerOptions, ListAllOptions.NONE); }  @Beta static Iterable<StorageMetadata> listAll(BlobStore blobStore, String container,
            ListContainerOptions containerOptions); @Beta static Iterable<StorageMetadata> listAll(final BlobStore blobStore, final String container,
            final ListContainerOptions containerOptions, final ListAllOptions listAllOptions);  }
@Test(expectedExceptions = { ContainerNotFoundException.class }) public void testListAllForUnknownContainerFromTransientBlobStoreEagerly() throws Exception { ListContainerOptions containerOptions = ListContainerOptions.NONE; ListAllOptions listAllOptions = ListAllOptions.Builder.eager(true); BlobStoreContext context = blobStoreContext(); try { BlobStore blobStore = context.getBlobStore(); BlobStores.listAll(blobStore, "wrongcontainer", containerOptions, listAllOptions); } finally { context.close(); } }
@Test(expectedExceptions = { ContainerNotFoundException.class }) public void testListAllForUnknownContainerFromTransientBlobStore() throws Exception { ListContainerOptions options = ListContainerOptions.NONE; BlobStoreContext context = blobStoreContext(); try { BlobStore blobStore = context.getBlobStore(); Iterable<StorageMetadata> iterable = BlobStores.listAll(blobStore, "wrongcontainer", options); iterable.iterator().hasNext(); } finally { context.close(); } }
@Test public void testListAllWhenOnePage() throws Exception { BlobStore blobStore = createMock(BlobStore.class); ListContainerOptions options = ListContainerOptions.NONE; StorageMetadata v1 = createMock(StorageMetadata.class); PageSet<StorageMetadata> pageSet = new PageSetImpl<StorageMetadata>(ImmutableList.of(v1), null); EasyMock.<PageSet<? extends StorageMetadata>> expect(blobStore.list(containerName, options)).andReturn(pageSet) .once(); EasyMock.replay(blobStore); Iterable<StorageMetadata> iterable = BlobStores.listAll(blobStore, containerName, options); assertEquals(ImmutableList.copyOf(iterable), ImmutableList.of(v1)); }
@Test public void testListAllWhenTwoPages() throws Exception { BlobStore blobStore = createMock(BlobStore.class); ListContainerOptions options = ListContainerOptions.NONE; ListContainerOptions options2 = ListContainerOptions.Builder.afterMarker("marker1"); StorageMetadata v1 = createMock(StorageMetadata.class); StorageMetadata v2 = createMock(StorageMetadata.class); PageSet<StorageMetadata> pageSet = new PageSetImpl<StorageMetadata>(ImmutableList.of(v1), "marker1"); PageSet<StorageMetadata> pageSet2 = new PageSetImpl<StorageMetadata>(ImmutableList.of(v2), null); EasyMock.<PageSet<? extends StorageMetadata>> expect(blobStore.list(containerName, options)).andReturn(pageSet) .once(); EasyMock.<PageSet<? extends StorageMetadata>> expect(blobStore.list(containerName, options2)).andReturn(pageSet2) .once(); EasyMock.replay(blobStore); Iterable<StorageMetadata> iterable = BlobStores.listAll(blobStore, containerName, options); assertEquals(ImmutableList.copyOf(iterable), ImmutableList.of(v1, v2)); }