@Test
public void testQueryDocumentWhenTheRequestWasSuccessful() {

    final DefaultDataBufferFactory dataBufferFactory = new DefaultDataBufferFactory();
    final WebClient webClient = WebClient.builder()
            .exchangeFunction(clientRequest -> {
                        assertThat(clientRequest.url().toString(), is(equalTo("http://myhost:1234/document/"
                                + TEST_DOCUMENT_ID.toString())));
                        return Mono.just(
                                ClientResponse.create(HttpStatus.OK)
                                        .header("Content-Type", "application/octet-stream")
                                        .body(Flux.just(dataBufferFactory.wrap(new byte[]{0, 1, 2})))
                                        .build()
                        );
                    }
            )
            .build();
    final VaultClientService underTest = new VaultClientService(
            vaultClientConfigurationProperties, documentManipulator, webClient);
    final DocumentEntity documentEntity = DocumentEntity.builder()
            .id(TEST_DOCUMENT_ID)
            .vault("default")
            .build();
    final VaultClientLocationConfigurationProperties vaultClientLocationConfigurationProperties =
            new VaultClientLocationConfigurationProperties();
    vaultClientLocationConfigurationProperties.setHost("myhost");
    vaultClientLocationConfigurationProperties.setPort(1234);
    when(vaultClientConfigurationProperties.getLocation("default"))
            .thenReturn(vaultClientLocationConfigurationProperties);
    final Mono<byte[]> result = underTest.queryDocument(documentEntity);
    StepVerifier.create(result)
            .consumeNextWith(documentContents -> assertThat(documentContents, is(equalTo(new byte[]{0, 1, 2}))))
            .verifyComplete();
    verify(documentManipulator, never()).markIndexFailure(TEST_DOCUMENT_ID);
}