VaultController { @DeleteMapping("/document/{documentId}") public Mono<Void> removeDocument(@PathVariable final String documentId) { if (!vaultConfigurationProperties.isModificationEnabled()) { return Mono.error(new ResponseStatusException(HttpStatus.FORBIDDEN, "Modification is disabled on this vault instance!")); } return documentEntityFactory.getDocumentEntity(UUID.fromString(documentId)) .switchIfEmpty(Mono.error(new ResponseStatusException(HttpStatus.NOT_FOUND, "Document not found with id " + documentId + " or already removed!"))) .flatMap(documentEntity -> { if (!documentEntity.isInVault(vaultConfigurationProperties.getName())) { return Mono.error(new ResponseStatusException(HttpStatus.CONFLICT, "Document with id " + documentId + " is available on a different vault!")); } return vaultDocumentManager.removeDocument(documentEntity) .thenReturn(documentEntity); }) .flatMap(documentEntity -> documentEntityFactory.removeDocumentEntity(documentEntity.getId())) .then(); }  @GetMapping("/document/{documentId}") Mono<ResponseEntity<Resource>> queryDocument(@PathVariable final String documentId); @DeleteMapping("/document/{documentId}") Mono<Void> removeDocument(@PathVariable final String documentId); @PostMapping("/document/{documentId}/recompress") Mono<Void> recompressDocument(@PathVariable final String documentId,
            @RequestBody final RecompressRequest recompressRequest); @GetMapping("/free-space") Mono<FreeSpaceResponse> getFreeSpace();  }
@Test public void testRemoveWhenRequestIsSuccessful() { when(vaultConfigurationProperties.isModificationEnabled()) .thenReturn(true); when(vaultConfigurationProperties.getName()) .thenReturn("my-vault"); final DocumentEntity documentEntity = DocumentEntity.builder() .id(UUID.fromString(TEST_DOCUMENT_ID)) .vault("my-vault") .build(); when(documentEntityFactory.getDocumentEntity(UUID.fromString(TEST_DOCUMENT_ID))) .thenReturn(Mono.just(documentEntity)); when(documentEntityFactory.removeDocumentEntity(UUID.fromString(TEST_DOCUMENT_ID))) .thenReturn(Mono.empty()); when(vaultDocumentManager.removeDocument(documentEntity)) .thenReturn(Mono.empty()); webTestClient.delete() .uri("/document/{documentId}", TEST_DOCUMENT_ID) .exchange() .expectStatus().isEqualTo(HttpStatus.OK) .returnResult(Void.class) .getResponseBody() .blockFirst(); verify(vaultDocumentManager).removeDocument(documentEntity); verify(documentEntityFactory).removeDocumentEntity(UUID.fromString(TEST_DOCUMENT_ID)); }