Blob(Storage storage, BlobInfo.BuilderImpl infoBuilder) { super(infoBuilder); this.storage = checkNotNull(storage); this.options = storage.getOptions(); }
Bucket(Storage storage, BucketInfo.BuilderImpl infoBuilder) { super(infoBuilder); this.storage = checkNotNull(storage); this.options = storage.getOptions(); }
/** Returns the project that is assigned to this provider. */ public String getProject() { initStorage(); return storage.getOptions().getProjectId(); }
@Override public Boolean call() { return ((StorageRpc) storage.getOptions().getRpc()) .deleteNotification(bucket, notification); } },
@Override public List<com.google.api.services.storage.model.Notification> call() { return ((StorageRpc) storage.getOptions().getRpc()).listNotifications(bucket); } },
@Test public void testGetOptions() { EasyMock.replay(storageRpcMock); initializeService(); assertSame(options, storage.getOptions()); }
@Test public void testContent() throws Exception { initializeExpectedBlob(2); byte[] content = {1, 2}; expect(storage.getOptions()).andReturn(mockOptions); expect(storage.readAllBytes(BLOB_INFO.getBlobId())).andReturn(content); replay(storage); initializeBlob(); assertArrayEquals(content, blob.getContent()); }
@Test public void testReloadNull() throws Exception { initializeExpectedBlob(1); expect(storage.getOptions()).andReturn(mockOptions); expect(storage.get(BLOB_INFO.getBlobId(), new Storage.BlobGetOption[0])).andReturn(null); replay(storage); initializeBlob(); Blob reloadedBlob = blob.reload(); assertNull(reloadedBlob); }
@Test public void testListAcls() throws Exception { initializeExpectedBucket(4); expect(storage.getOptions()).andReturn(mockOptions); expect(storage.listAcls(BUCKET_INFO.getName())).andReturn(ACLS); replay(storage); initializeBucket(); assertEquals(ACLS, bucket.listAcls()); }
@Test public void testListDefaultAcls() throws Exception { initializeExpectedBucket(4); expect(storage.getOptions()).andReturn(mockOptions); expect(storage.listDefaultAcls(BUCKET_INFO.getName())).andReturn(ACLS); replay(storage); initializeBucket(); assertEquals(ACLS, bucket.listDefaultAcls()); }
@Test public void testDelete() throws Exception { initializeExpectedBlob(2); expect(storage.getOptions()).andReturn(mockOptions); expect(storage.delete(BLOB_INFO.getBlobId(), new Storage.BlobSourceOption[0])).andReturn(true); replay(storage); initializeBlob(); assertTrue(blob.delete()); }
@Test public void testExists_True() throws Exception { initializeExpectedBucket(4); Storage.BucketGetOption[] expectedOptions = {Storage.BucketGetOption.fields()}; expect(storage.getOptions()).andReturn(mockOptions); expect(storage.get(BUCKET_INFO.getName(), expectedOptions)).andReturn(expectedBucket); replay(storage); initializeBucket(); assertTrue(bucket.exists()); }
@Test public void testExists_False() throws Exception { initializeExpectedBucket(4); Storage.BucketGetOption[] expectedOptions = {Storage.BucketGetOption.fields()}; expect(storage.getOptions()).andReturn(mockOptions); expect(storage.get(BUCKET_INFO.getName(), expectedOptions)).andReturn(null); replay(storage); initializeBucket(); assertFalse(bucket.exists()); }
@Test public void testGetDefaultAcl() throws Exception { initializeExpectedBucket(4); expect(storage.getOptions()).andReturn(mockOptions); expect(storage.getDefaultAcl(BUCKET_INFO.getName(), User.ofAllAuthenticatedUsers())) .andReturn(ACL); replay(storage); initializeBucket(); assertEquals(ACL, bucket.getDefaultAcl(User.ofAllAuthenticatedUsers())); }
@Test public void testGetAcl() throws Exception { initializeExpectedBucket(4); expect(storage.getOptions()).andReturn(mockOptions); expect(storage.getAcl(BUCKET_INFO.getName(), User.ofAllAuthenticatedUsers())).andReturn(ACL); replay(storage); initializeBucket(); assertEquals(ACL, bucket.getAcl(User.ofAllAuthenticatedUsers())); }
@Test public void testDeleteAcl() throws Exception { initializeExpectedBucket(4); expect(storage.getOptions()).andReturn(mockOptions); expect(storage.deleteAcl(BUCKET_INFO.getName(), User.ofAllAuthenticatedUsers())) .andReturn(true); replay(storage); initializeBucket(); assertTrue(bucket.deleteAcl(User.ofAllAuthenticatedUsers())); }
@Test public void testReload() throws Exception { initializeExpectedBlob(2); Blob expectedReloadedBlob = expectedBlob.toBuilder().setCacheControl("c").build(); expect(storage.getOptions()).andReturn(mockOptions); expect(storage.get(BLOB_INFO.getBlobId(), new Storage.BlobGetOption[0])) .andReturn(expectedReloadedBlob); replay(storage); initializeBlob(); Blob updatedBlob = blob.reload(); assertEquals(expectedReloadedBlob, updatedBlob); }
@Test public void testCreateAcl() throws Exception { initializeExpectedBucket(4); expect(storage.getOptions()).andReturn(mockOptions); Acl returnedAcl = ACL.toBuilder().setEtag("ETAG").setId("ID").build(); expect(storage.createAcl(BUCKET_INFO.getName(), ACL)).andReturn(returnedAcl); replay(storage); initializeBucket(); assertEquals(returnedAcl, bucket.createAcl(ACL)); }
@Test public void testUpdateDefaultAcl() throws Exception { initializeExpectedBucket(4); expect(storage.getOptions()).andReturn(mockOptions); Acl returnedAcl = ACL.toBuilder().setEtag("ETAG").setId("ID").build(); expect(storage.updateDefaultAcl(BUCKET_INFO.getName(), ACL)).andReturn(returnedAcl); replay(storage); initializeBucket(); assertEquals(returnedAcl, bucket.updateDefaultAcl(ACL)); }
@Test public void testCreateAcl() throws Exception { initializeExpectedBlob(1); expect(storage.getOptions()).andReturn(mockOptions); Acl returnedAcl = ACL.toBuilder().setEtag("ETAG").setId("ID").build(); expect(storage.createAcl(BLOB_INFO.getBlobId(), ACL)).andReturn(returnedAcl); replay(storage); initializeBlob(); assertEquals(returnedAcl, blob.createAcl(ACL)); }