@@ -129,7 +129,11 @@ public class BlobTest {
129
129
.setRetentionExpirationTime (RETENTION_EXPIRATION_TIME )
130
130
.build ();
131
131
private static final BlobInfo BLOB_INFO =
132
- BlobInfo .newBuilder ("b" , "n" ).setMetageneration (42L ).build ();
132
+ BlobInfo .newBuilder ("b" , "n" , 12345678L ).setMetageneration (42L ).build ();
133
+ private static final BlobInfo BLOB_INFO_NO_GENERATION =
134
+ BlobInfo .newBuilder (BLOB_INFO .getBucket (), BLOB_INFO .getName ())
135
+ .setMetageneration (42L )
136
+ .build ();
133
137
private static final BlobInfo DIRECTORY_INFO =
134
138
BlobInfo .newBuilder ("b" , "n/" ).setSize (0L ).setIsDirectory (true ).build ();
135
139
private static final String BASE64_KEY = "JVzfVl8NLD9FjedFuStegjRfES5ll5zc59CIXw572OA=" ;
@@ -233,7 +237,7 @@ public void testReload() throws Exception {
233
237
initializeExpectedBlob (2 );
234
238
Blob expectedReloadedBlob = expectedBlob .toBuilder ().setCacheControl ("c" ).build ();
235
239
expect (storage .getOptions ()).andReturn (mockOptions );
236
- expect (storage .get (BLOB_INFO .getBlobId (), new Storage .BlobGetOption [0 ]))
240
+ expect (storage .get (BLOB_INFO_NO_GENERATION .getBlobId (), new Storage .BlobGetOption [0 ]))
237
241
.andReturn (expectedReloadedBlob );
238
242
replay (storage );
239
243
initializeBlob ();
@@ -245,7 +249,8 @@ public void testReload() throws Exception {
245
249
public void testReloadNull () throws Exception {
246
250
initializeExpectedBlob (1 );
247
251
expect (storage .getOptions ()).andReturn (mockOptions );
248
- expect (storage .get (BLOB_INFO .getBlobId (), new Storage .BlobGetOption [0 ])).andReturn (null );
252
+ expect (storage .get (BLOB_INFO_NO_GENERATION .getBlobId (), new Storage .BlobGetOption [0 ]))
253
+ .andReturn (null );
249
254
replay (storage );
250
255
initializeBlob ();
251
256
Blob reloadedBlob = blob .reload ();
@@ -258,7 +263,8 @@ public void testReloadWithOptions() throws Exception {
258
263
Blob expectedReloadedBlob = expectedBlob .toBuilder ().setCacheControl ("c" ).build ();
259
264
Storage .BlobGetOption [] options = {Storage .BlobGetOption .metagenerationMatch (42L )};
260
265
expect (storage .getOptions ()).andReturn (mockOptions );
261
- expect (storage .get (BLOB_INFO .getBlobId (), options )).andReturn (expectedReloadedBlob );
266
+ expect (storage .get (BLOB_INFO_NO_GENERATION .getBlobId (), options ))
267
+ .andReturn (expectedReloadedBlob );
262
268
replay (storage );
263
269
initializeBlob ();
264
270
Blob updatedBlob = blob .reload (BlobSourceOption .metagenerationMatch ());
@@ -301,8 +307,8 @@ public void testCopyToBucket() throws Exception {
301
307
initializeBlob ();
302
308
CopyWriter returnedCopyWriter = blob .copyTo ("bt" );
303
309
assertEquals (copyWriter , returnedCopyWriter );
304
- assertEquals (capturedCopyRequest . getValue (). getSource (), blob . getBlobId ());
305
- assertEquals (capturedCopyRequest .getValue ().getTarget (), target );
310
+ assertEquals (BLOB_INFO_NO_GENERATION . getBlobId (), capturedCopyRequest . getValue (). getSource ());
311
+ assertEquals (target , capturedCopyRequest .getValue ().getTarget ());
306
312
assertFalse (capturedCopyRequest .getValue ().overrideInfo ());
307
313
assertTrue (capturedCopyRequest .getValue ().getSourceOptions ().isEmpty ());
308
314
assertTrue (capturedCopyRequest .getValue ().getTargetOptions ().isEmpty ());
@@ -320,8 +326,8 @@ public void testCopyTo() throws Exception {
320
326
initializeBlob ();
321
327
CopyWriter returnedCopyWriter = blob .copyTo ("bt" , "nt" );
322
328
assertEquals (copyWriter , returnedCopyWriter );
323
- assertEquals (capturedCopyRequest . getValue (). getSource (), blob . getBlobId ());
324
- assertEquals (capturedCopyRequest .getValue ().getTarget (), target );
329
+ assertEquals (BLOB_INFO_NO_GENERATION . getBlobId (), capturedCopyRequest . getValue (). getSource ());
330
+ assertEquals (target , capturedCopyRequest .getValue ().getTarget ());
325
331
assertFalse (capturedCopyRequest .getValue ().overrideInfo ());
326
332
assertTrue (capturedCopyRequest .getValue ().getSourceOptions ().isEmpty ());
327
333
assertTrue (capturedCopyRequest .getValue ().getTargetOptions ().isEmpty ());
@@ -340,8 +346,8 @@ public void testCopyToBlobId() throws Exception {
340
346
initializeBlob ();
341
347
CopyWriter returnedCopyWriter = blob .copyTo (targetId );
342
348
assertEquals (copyWriter , returnedCopyWriter );
343
- assertEquals (capturedCopyRequest . getValue (). getSource (), blob . getBlobId ());
344
- assertEquals (capturedCopyRequest .getValue ().getTarget (), target );
349
+ assertEquals (BLOB_INFO_NO_GENERATION . getBlobId (), capturedCopyRequest . getValue (). getSource ());
350
+ assertEquals (target , capturedCopyRequest .getValue ().getTarget ());
345
351
assertFalse (capturedCopyRequest .getValue ().overrideInfo ());
346
352
assertTrue (capturedCopyRequest .getValue ().getSourceOptions ().isEmpty ());
347
353
assertTrue (capturedCopyRequest .getValue ().getTargetOptions ().isEmpty ());
0 commit comments