@@ -129,7 +129,11 @@ public class BlobTest {
129129 .setRetentionExpirationTime (RETENTION_EXPIRATION_TIME )
130130 .build ();
131131 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 ();
133137 private static final BlobInfo DIRECTORY_INFO =
134138 BlobInfo .newBuilder ("b" , "n/" ).setSize (0L ).setIsDirectory (true ).build ();
135139 private static final String BASE64_KEY = "JVzfVl8NLD9FjedFuStegjRfES5ll5zc59CIXw572OA=" ;
@@ -233,7 +237,7 @@ public void testReload() throws Exception {
233237 initializeExpectedBlob (2 );
234238 Blob expectedReloadedBlob = expectedBlob .toBuilder ().setCacheControl ("c" ).build ();
235239 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 ]))
237241 .andReturn (expectedReloadedBlob );
238242 replay (storage );
239243 initializeBlob ();
@@ -245,7 +249,8 @@ public void testReload() throws Exception {
245249 public void testReloadNull () throws Exception {
246250 initializeExpectedBlob (1 );
247251 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 );
249254 replay (storage );
250255 initializeBlob ();
251256 Blob reloadedBlob = blob .reload ();
@@ -258,7 +263,8 @@ public void testReloadWithOptions() throws Exception {
258263 Blob expectedReloadedBlob = expectedBlob .toBuilder ().setCacheControl ("c" ).build ();
259264 Storage .BlobGetOption [] options = {Storage .BlobGetOption .metagenerationMatch (42L )};
260265 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 );
262268 replay (storage );
263269 initializeBlob ();
264270 Blob updatedBlob = blob .reload (BlobSourceOption .metagenerationMatch ());
@@ -301,8 +307,8 @@ public void testCopyToBucket() throws Exception {
301307 initializeBlob ();
302308 CopyWriter returnedCopyWriter = blob .copyTo ("bt" );
303309 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 ());
306312 assertFalse (capturedCopyRequest .getValue ().overrideInfo ());
307313 assertTrue (capturedCopyRequest .getValue ().getSourceOptions ().isEmpty ());
308314 assertTrue (capturedCopyRequest .getValue ().getTargetOptions ().isEmpty ());
@@ -320,8 +326,8 @@ public void testCopyTo() throws Exception {
320326 initializeBlob ();
321327 CopyWriter returnedCopyWriter = blob .copyTo ("bt" , "nt" );
322328 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 ());
325331 assertFalse (capturedCopyRequest .getValue ().overrideInfo ());
326332 assertTrue (capturedCopyRequest .getValue ().getSourceOptions ().isEmpty ());
327333 assertTrue (capturedCopyRequest .getValue ().getTargetOptions ().isEmpty ());
@@ -340,8 +346,8 @@ public void testCopyToBlobId() throws Exception {
340346 initializeBlob ();
341347 CopyWriter returnedCopyWriter = blob .copyTo (targetId );
342348 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 ());
345351 assertFalse (capturedCopyRequest .getValue ().overrideInfo ());
346352 assertTrue (capturedCopyRequest .getValue ().getSourceOptions ().isEmpty ());
347353 assertTrue (capturedCopyRequest .getValue ().getTargetOptions ().isEmpty ());
0 commit comments