public BlobOperationResponse getBlob(final Exchange exchange) throws IOException {
        if (LOG.isTraceEnabled()) {
            LOG.trace("Getting a blob [{}] from exchange [{}]...", configurationProxy.getBlobName(exchange), exchange);
        }

        final Message message = BlobUtils.getInMessage(exchange);
        final OutputStream outputStream = ObjectHelper.isEmpty(message) ? null : message.getBody(OutputStream.class);
        final BlobRange blobRange = configurationProxy.getBlobRange(exchange);
        final BlobCommonRequestOptions blobCommonRequestOptions = getCommonRequestOptions(exchange);

        if (outputStream == null) {
            // Then we create an input stream
            final Map<String, Object> blobInputStream
                    = client.openInputStream(blobRange, blobCommonRequestOptions.getBlobRequestConditions());
            final BlobExchangeHeaders blobExchangeHeaders = BlobExchangeHeaders
                    .createBlobExchangeHeadersFromBlobProperties((BlobProperties) blobInputStream.get("properties"));

            return BlobOperationResponse.create(blobInputStream.get("inputStream"), blobExchangeHeaders.toMap());
        }
        // we have an outputStream set, so we use it
        final DownloadRetryOptions downloadRetryOptions = getDownloadRetryOptions(configurationProxy);

        try {
            final ResponseBase<BlobDownloadHeaders, Void> response = client.downloadWithResponse(outputStream, blobRange,
                    downloadRetryOptions, blobCommonRequestOptions.getBlobRequestConditions(),
                    blobCommonRequestOptions.getContentMD5() != null, blobCommonRequestOptions.getTimeout());

            final BlobExchangeHeaders blobExchangeHeaders
                    = BlobExchangeHeaders.createBlobExchangeHeadersFromBlobDownloadHeaders(response.getDeserializedHeaders())
                            .httpHeaders(response.getHeaders());

            return BlobOperationResponse.create(outputStream, blobExchangeHeaders.toMap());
        } finally {
            if (configurationProxy.getConfiguration().isCloseStreamAfterRead()) {
                outputStream.close();
            }
        }
    }
@Test
    void testGetBlob() throws IOException {
        // mocking
        final Map<String, Object> mockedResults = new HashMap<>();
        mockedResults.put("inputStream", new ByteArrayInputStream("testInput".getBytes(Charset.defaultCharset())));
        mockedResults.put("properties", createBlobProperties());

        when(client.openInputStream(any(), any())).thenReturn(mockedResults);

        final Exchange exchange = new DefaultExchange(context);

        // first: test with no exchange provided
        final BlobOperations operations = new BlobOperations(configuration, client);

        final BlobOperationResponse response = operations.getBlob(null);

        assertNotNull(response);
        assertNotNull(response.getBody());
        assertNotNull(response.getHeaders());
        assertNotNull(response.getHeaders().get(BlobConstants.CREATION_TIME));
        assertEquals("testInput", new BufferedReader(new InputStreamReader((InputStream) response.getBody())).readLine());

        // second: test with exchange provided
        configuration.setBlobType(BlobType.blockblob);
        final BlobOperationResponse response2 = operations.getBlob(exchange);

        assertNotNull(response2);
        assertNotNull(response2.getBody());
        assertNotNull(response2.getHeaders());
        assertNotNull(response2.getHeaders().get(BlobConstants.CREATION_TIME));

        // third: test with exchange provided but with outputstream set
        // mocking
        final ResponseBase<BlobDownloadHeaders, Void> mockedResults2 = new ResponseBase<>(
                null, 200, new HttpHeaders().set("x-test-header", "123"), null, new BlobDownloadHeaders().setETag("tag1"));
        when(client.downloadWithResponse(any(), any(), any(), any(), anyBoolean(), any())).thenReturn(mockedResults2);
        exchange.getIn().setBody(new ByteArrayOutputStream());

        final BlobOperationResponse response3 = operations.getBlob(exchange);

        assertNotNull(response3);
        assertNotNull(response3.getBody());
        assertNotNull(response3.getHeaders());
        assertEquals("tag1", response3.getHeaders().get(BlobConstants.E_TAG));
    }