Source:
<code>public void testNormalFlow() throws Exception { PartitionId partitionId = new MockPartitionId(testPartition, MockClusterMap.DEFAULT_PARTITION_CLASS); BlobId blobId = new BlobId(BLOB_ID_V6, BlobIdType.NATIVE, dataCenterId, accountId, containerId, partitionId, false, BlobDataType.DATACHUNK); byte[] uploadData = TestUtils.getRandomBytes(blobSize); InputStream inputStream = new ByteArrayInputStream(uploadData); CloudBlobMetadata cloudBlobMetadata = new CloudBlobMetadata(blobId, System.currentTimeMillis(), Utils.Infinite_Time, blobSize, CloudBlobMetadata.EncryptionOrigin.VCR, vcrKmsContext, cryptoAgentFactory); assertTrue("Expected upload to return true", azureDest.uploadBlob(blobId, blobSize, cloudBlobMetadata, inputStream)); verifyDownloadMatches(blobId, uploadData); assertFalse("Expected duplicate upload to return false", azureDest.uploadBlob(blobId, blobSize, cloudBlobMetadata, inputStream)); long expirationTime = Utils.Infinite_Time; assertTrue("Expected update to return true", azureDest.updateBlobExpiration(blobId, expirationTime)); CloudBlobMetadata metadata = azureDest.getBlobMetadata(Collections.singletonList(blobId)).get(blobId.getID()); assertEquals(expirationTime, metadata.getExpirationTime()); assertEquals(azureDest.getAzureBlobName(blobId), metadata.getCloudBlobName()); long deletionTime = System.currentTimeMillis() + 1000; assertTrue("Expected deletion to return true", azureDest.deleteBlob(blobId, deletionTime)); metadata = azureDest.getBlobMetadata(Collections.singletonList(blobId)).get(blobId.getID()); assertEquals(deletionTime, metadata.getDeletionTime()); assertEquals(azureDest.getAzureBlobName(blobId), metadata.getCloudBlobName()); azureDest.purgeBlob(metadata); assertTrue("Expected empty set after purge", azureDest.getBlobMetadata(Collections.singletonList(blobId)).isEmpty()); try { verifyDownloadMatches(blobId, uploadData); } catch (CloudStorageException csex) { <START> assertTrue(csex.getMessage().contains("Error downloading blob")); <END> } }</code><technical_language>Minor: good practice for tests check for exact error text, tests brittle</technical_language>

Target:
public void testNormalFlow() throws Exception { PartitionId partitionId = new MockPartitionId(testPartition, MockClusterMap.DEFAULT_PARTITION_CLASS); BlobId blobId = new BlobId(BLOB_ID_V6, BlobIdType.NATIVE, dataCenterId, accountId, containerId, partitionId, false, BlobDataType.DATACHUNK); byte[] uploadData = TestUtils.getRandomBytes(blobSize); InputStream inputStream = new ByteArrayInputStream(uploadData); CloudBlobMetadata cloudBlobMetadata = new CloudBlobMetadata(blobId, System.currentTimeMillis(), Utils.Infinite_Time, blobSize, CloudBlobMetadata.EncryptionOrigin.VCR, vcrKmsContext, cryptoAgentFactory); assertTrue("Expected upload to return true", azureDest.uploadBlob(blobId, blobSize, cloudBlobMetadata, inputStream)); verifyDownloadMatches(blobId, uploadData); assertFalse("Expected duplicate upload to return false", azureDest.uploadBlob(blobId, blobSize, cloudBlobMetadata, inputStream)); long expirationTime = Utils.Infinite_Time; assertTrue("Expected update to return true", azureDest.updateBlobExpiration(blobId, expirationTime)); CloudBlobMetadata metadata = azureDest.getBlobMetadata(Collections.singletonList(blobId)).get(blobId.getID()); assertEquals(expirationTime, metadata.getExpirationTime()); assertEquals(azureDest.getAzureBlobName(blobId), metadata.getCloudBlobName()); long deletionTime = System.currentTimeMillis() + 1000; assertTrue("Expected deletion to return true", azureDest.deleteBlob(blobId, deletionTime)); metadata = azureDest.getBlobMetadata(Collections.singletonList(blobId)).get(blobId.getID()); assertEquals(deletionTime, metadata.getDeletionTime()); assertEquals(azureDest.getAzureBlobName(blobId), metadata.getCloudBlobName()); azureDest.purgeBlob(metadata); assertTrue("Expected empty set after purge", azureDest.getBlobMetadata(Collections.singletonList(blobId)).isEmpty()); try { verifyDownloadMatches(blobId, uploadData); fail("download blob should fail after data is purged"); } catch (CloudStorageException csex) { } }