From cd19871d49d2a23eb80115cfffd29ac49c1fc9aa Mon Sep 17 00:00:00 2001 From: Fabrice B Date: Thu, 12 Dec 2024 17:19:10 +0100 Subject: [PATCH] tests(hotfix always use FileOperations to process documents) --- pom.xml | 2 +- .../bauhaus_services/FileSystemOperation.java | 12 +- .../bauhaus_services/FilesOperations.java | 6 +- .../bauhaus_services/MinioFilesOperation.java | 17 ++- .../documentations/DocumentationExport.java | 8 +- .../documents/DocumentsPublication.java | 2 +- .../documents/DocumentsUtils.java | 25 ++-- .../insee/rmes/utils/RestTemplateUtils.java | 121 ------------------ .../DocumentationExportTest.java | 6 +- ...DocumentsResourcesWithFilesOperation.java} | 91 ++++++++----- .../fr/insee/rmes/utils/ConsoleCapture.java | 41 ++++++ .../webservice/DocumentsResourcesTest.java | 9 -- 12 files changed, 154 insertions(+), 186 deletions(-) delete mode 100644 src/main/java/fr/insee/rmes/utils/RestTemplateUtils.java rename src/test/java/fr/insee/rmes/integration/{TestDocumentsResourcesWithMinio.java => TestDocumentsResourcesWithFilesOperation.java} (50%) create mode 100644 src/test/java/fr/insee/rmes/utils/ConsoleCapture.java diff --git a/pom.xml b/pom.xml index 02054a40b..722a17742 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ fr.insee.rmes Bauhaus-BO jar - 4.1.6 + 4.1.7-beta2 Bauhaus-Back-Office Back-office services for Bauhaus https://github.com/InseeFr/Bauhaus-Back-Office diff --git a/src/main/java/fr/insee/rmes/bauhaus_services/FileSystemOperation.java b/src/main/java/fr/insee/rmes/bauhaus_services/FileSystemOperation.java index d237a0d07..8e43e57c0 100644 --- a/src/main/java/fr/insee/rmes/bauhaus_services/FileSystemOperation.java +++ b/src/main/java/fr/insee/rmes/bauhaus_services/FileSystemOperation.java @@ -18,11 +18,11 @@ public class FileSystemOperation implements FilesOperations { protected Config config; @Override - public void delete(String path) { + public void delete(Path absolutePath) { try { - Files.delete(Paths.get(path)); + Files.delete(absolutePath); } catch (IOException e) { - throw new RmesFileException(path, "Failed to delete file: " + path, e); + throw new RmesFileException(absolutePath.getFileName().toString(), "Failed to delete file: " + absolutePath, e); } } @@ -35,6 +35,11 @@ public InputStream read(String fileName) { } } + @Override + public boolean existsInStorage(String filename) { + return Files.exists(Paths.get(config.getDocumentsStorageGestion()).resolve(filename)); + } + @Override public void write(InputStream content, Path destPath) { try { @@ -59,4 +64,5 @@ public void copy(String srcPath, String destPath) { public boolean dirExists(Path gestionStorageFolder) { return Files.isDirectory(requireNonNull(gestionStorageFolder)); } + } diff --git a/src/main/java/fr/insee/rmes/bauhaus_services/FilesOperations.java b/src/main/java/fr/insee/rmes/bauhaus_services/FilesOperations.java index 7f7f6453f..77d138715 100644 --- a/src/main/java/fr/insee/rmes/bauhaus_services/FilesOperations.java +++ b/src/main/java/fr/insee/rmes/bauhaus_services/FilesOperations.java @@ -4,10 +4,12 @@ import java.nio.file.Path; public interface FilesOperations { - void delete(String path); - InputStream read(String path); + void delete(Path absolutePath); + InputStream read(String filename); void write(InputStream content, Path destPath); void copy(String srcPath, String destPath); boolean dirExists(Path gestionStorageFolder); + + boolean existsInStorage(String filename); } diff --git a/src/main/java/fr/insee/rmes/bauhaus_services/MinioFilesOperation.java b/src/main/java/fr/insee/rmes/bauhaus_services/MinioFilesOperation.java index ed1682f3e..ce16a7ad2 100644 --- a/src/main/java/fr/insee/rmes/bauhaus_services/MinioFilesOperation.java +++ b/src/main/java/fr/insee/rmes/bauhaus_services/MinioFilesOperation.java @@ -10,6 +10,8 @@ import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; +import static java.util.Objects.requireNonNull; + public record MinioFilesOperation(MinioClient minioClient, String bucketName, String directoryGestion, String directoryPublication) implements FilesOperations { @Override @@ -33,6 +35,18 @@ private static String extractFileName(String filePath) { return Path.of(filePath).getFileName().toString(); } + @Override + public boolean existsInStorage(String filename) { + var objectName = extractFileName(requireNonNull(filename)); + try { + return minioClient.statObject(StatObjectArgs.builder() + .bucket(bucketName) + .object(objectName) + .build()).size() > 0; + } catch (MinioException | InvalidKeyException | IOException | NoSuchAlgorithmException e) { + return false; + } + } @Override public void write(InputStream content, Path filePath) { @@ -80,7 +94,8 @@ public boolean dirExists(Path gestionStorageFolder) { } @Override - public void delete(String objectName) { + public void delete(Path absolutePath) { + String objectName = absolutePath.getFileName().toString(); try { minioClient.removeObject(RemoveObjectArgs.builder() .bucket(bucketName) diff --git a/src/main/java/fr/insee/rmes/bauhaus_services/operations/documentations/DocumentationExport.java b/src/main/java/fr/insee/rmes/bauhaus_services/operations/documentations/DocumentationExport.java index 46eef73dd..e8dc43ccb 100644 --- a/src/main/java/fr/insee/rmes/bauhaus_services/operations/documentations/DocumentationExport.java +++ b/src/main/java/fr/insee/rmes/bauhaus_services/operations/documentations/DocumentationExport.java @@ -160,19 +160,19 @@ private Set exportRubricsDocuments(JSONObject sims, Path directory) thro for (int i = 0; i < documents.length(); i++) { JSONObject document = documents.getJSONObject(i); - String url = document.getString("url").replace("file://", ""); + String url = DocumentsUtils.getDocumentUrlFromDocument(document); if(!history.contains(url)){ history.add(url); logger.debug("Extracting document {}", url); - Path documentPath = Path.of(url); + String documentFilename = DocumentsUtils.getDocumentNameFromUrl(url); - if(!Files.exists(documentPath)){ + if(!documentsUtils.existsInStorage(documentFilename)){ missingDocuments.add(document.getString("id")); } else { String documentFileName = FilesUtils.generateFinalFileNameWithExtension(UriUtils.getLastPartFromUri(url), maxLength); - try (InputStream inputStream = Files.newInputStream(documentPath)){ + try (InputStream inputStream = documentsUtils.retrieveDocumentFromStorage(documentFilename)){ Path documentDirectory = Path.of(directory.toString(), "documents"); if (!Files.exists(documentDirectory)) { logger.debug("Creating the documents folder"); diff --git a/src/main/java/fr/insee/rmes/bauhaus_services/operations/documentations/documents/DocumentsPublication.java b/src/main/java/fr/insee/rmes/bauhaus_services/operations/documentations/documents/DocumentsPublication.java index 51b6a327d..1486c7e10 100644 --- a/src/main/java/fr/insee/rmes/bauhaus_services/operations/documentations/documents/DocumentsPublication.java +++ b/src/main/java/fr/insee/rmes/bauhaus_services/operations/documentations/documents/DocumentsPublication.java @@ -49,7 +49,7 @@ public void publishAllDocumentsInSims(String idSims) throws RmesException { for (Map.Entry doc : mapIdUrls.entrySet()) { String docId = doc.getKey().toString(); String originalPath = doc.getValue(); - String filename = docUtils.getDocumentNameFromUrl(originalPath); + String filename = DocumentsUtils.getDocumentNameFromUrl(originalPath); // Publish the physical files copyFileInPublicationFolders(originalPath); // Change url in document (getModelToPublish) and publish the RDF diff --git a/src/main/java/fr/insee/rmes/bauhaus_services/operations/documentations/documents/DocumentsUtils.java b/src/main/java/fr/insee/rmes/bauhaus_services/operations/documentations/documents/DocumentsUtils.java index 05744c48c..b43e92e07 100644 --- a/src/main/java/fr/insee/rmes/bauhaus_services/operations/documentations/documents/DocumentsUtils.java +++ b/src/main/java/fr/insee/rmes/bauhaus_services/operations/documentations/documents/DocumentsUtils.java @@ -41,7 +41,6 @@ import java.io.InputStream; import java.net.MalformedURLException; import java.net.URI; -import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.nio.file.Paths; @@ -282,7 +281,7 @@ private void checkUrlDoesNotExist(String id, String url, int errorCode, String e JSONObject existingUriJson = repoGestion.getResponseAsObject(DocumentsQueries.getDocumentUriQuery(url)); if (existingUriJson.length() > 0) { String uri = existingUriJson.getString(Constants.DOCUMENT); - String existingId = getIdFromUri(uri); + String existingId = getDocumentNameFromUrl(uri); if (!existingId.equals(id)) { throw new RmesNotAcceptableException(errorCode, errorMessage, uri); } @@ -556,21 +555,13 @@ private void changeDocumentsURL(String iri, String docUrl, String newUrl) throws private void deleteFile(String docUrl) { Path path = Paths.get(docUrl); - try { - Files.delete(path); - } catch (IOException e) { - logger.error(e.getMessage()); - } + filesOperations.delete(path); } - public String getDocumentNameFromUrl(String docUrl) { + public static String getDocumentNameFromUrl(String docUrl) { return UriUtils.getLastPartFromUri(docUrl); } - private String getIdFromUri(String uri) { - return UriUtils.getLastPartFromUri(uri); - } - private String createFileUrl(String name) throws RmesException { Path gestionStorageFolder=Path.of(config.getDocumentsStorageGestion()); if (!filesOperations.dirExists(gestionStorageFolder)){ @@ -603,7 +594,7 @@ private IRI getDocumentUri(IRI url) throws RmesException { return RdfUtils.toURI(uri.getString(Constants.DOCUMENT)); } - public String getDocumentUrlFromDocument(JSONObject jsonDoc) { + public static String getDocumentUrlFromDocument(JSONObject jsonDoc) { return jsonDoc.getString(Constants.URL).replace(SCHEME_FILE, ""); } @@ -696,5 +687,13 @@ private String getFileName(String path) { // Extraire juste le nom de fichier du chemin return Paths.get(path).getFileName().toString(); } + + public InputStream retrieveDocumentFromStorage(String filename) { + return filesOperations.read(filename); + } + + public boolean existsInStorage(String filename) { + return filesOperations.existsInStorage(filename); + } } diff --git a/src/main/java/fr/insee/rmes/utils/RestTemplateUtils.java b/src/main/java/fr/insee/rmes/utils/RestTemplateUtils.java deleted file mode 100644 index b80894d6c..000000000 --- a/src/main/java/fr/insee/rmes/utils/RestTemplateUtils.java +++ /dev/null @@ -1,121 +0,0 @@ -package fr.insee.rmes.utils; - -import fr.insee.rmes.exceptions.RmesException; -import org.apache.commons.codec.binary.Base64; -import org.springframework.core.io.FileSystemResource; -import org.springframework.core.io.Resource; -import org.springframework.http.*; -import org.springframework.stereotype.Service; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -@Service -public class RestTemplateUtils { - - RestTemplate restTemplate = new RestTemplate(); - - public HttpHeaders getHeadersWithBasicAuth(String username, String password) { - // HttpHeaders - HttpHeaders headers = new HttpHeaders(); - - // Authentication - String auth = username + ":" + password; - byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.US_ASCII)); - String authHeader = "Basic " + new String(encodedAuth); - headers.set("Authorization", authHeader); - - return headers; - } - - public HttpHeaders addJsonContentToHeader(HttpHeaders headers) { - addAcceptJsonToHeader(headers); - headers.setContentType(MediaType.APPLICATION_JSON ); - return headers; - } - - - public String getResponseAsString(String target, HttpHeaders headers, Map params) { - if (params == null) return getResponseAsString(target, headers); - // HttpEntity: To get result as String. - HttpEntity entity = new HttpEntity<>(headers); - - // Send request with GET method, and Headers, and Params (can't be null). - ResponseEntity response = restTemplate.exchange(target, HttpMethod.GET, entity, String.class, params); - - return response.getBody(); - } - - public String getResponseAsString(String target, HttpHeaders headers) { - // HttpEntity: To get result as String. - HttpEntity entity = new HttpEntity<>(headers); - - // Send request with GET method, and Headers. - ResponseEntity response = restTemplate.exchange(target, HttpMethod.GET, entity, String.class); - - return response.getBody(); - } - - public void addAcceptJsonToHeader(HttpHeaders headers) { - List acceptHeaders =new ArrayList<>( headers.getAccept()); - acceptHeaders.add(MediaType.APPLICATION_JSON ); - headers.setAccept(acceptHeaders); - } - - private static Resource getFileAsResource(InputStream fileIs, String filename) throws RmesException { - try { - String tempDir = System.getProperty("java.io.tmpdir"); - Path tempFile = Paths.get(tempDir ,filename); - Files.write(tempFile, fileIs.readAllBytes()); - File file = tempFile.toFile(); - file.deleteOnExit(); - return new FileSystemResource(file); - } catch (IOException e) { - throw new RmesException(HttpStatus.INTERNAL_SERVER_ERROR, "Can't convert file to resource IOException", e.getMessage()); - } - - } - - public String postForEntity(String target, MultiValueMap body, HttpHeaders headers) throws RmesException { - - // HttpEntity>: To get result as String. - HttpEntity requestEntity = new HttpEntity<>(body, headers); - - // Send request with POST method, and Headers. - try { - ResponseEntity response = restTemplate.postForEntity(target, requestEntity, String.class); - return response.getBody(); - }catch(Exception e) { - throw new RmesException(HttpStatus.FAILED_DEPENDENCY, "SPOC error, "+ e.getClass(), e.getMessage()); - } - } - - public MultiValueMap buildBodyAsMap(String request, InputStream fileResource, String filename) throws RmesException { - MultiValueMap body = new LinkedMultiValueMap<>(); - - //add file to join to body - HttpHeaders fileheaders = new HttpHeaders(); - fileheaders.setContentType(MediaType.APPLICATION_OCTET_STREAM); - body.add("attachments", new HttpEntity<>(getFileAsResource(fileResource, filename), fileheaders)); - - //add xml content to body - HttpHeaders contentheaders = new HttpHeaders(); - contentheaders.setContentType(MediaType.APPLICATION_XML); - body.add("request", new HttpEntity<>(request, contentheaders)); - - return body; - } - - -} diff --git a/src/test/java/fr/insee/rmes/bauhaus_services/operations/documentations/DocumentationExportTest.java b/src/test/java/fr/insee/rmes/bauhaus_services/operations/documentations/DocumentationExportTest.java index 3a5171cbc..0661536f7 100644 --- a/src/test/java/fr/insee/rmes/bauhaus_services/operations/documentations/DocumentationExportTest.java +++ b/src/test/java/fr/insee/rmes/bauhaus_services/operations/documentations/DocumentationExportTest.java @@ -29,6 +29,7 @@ import java.util.HashMap; import java.util.Map; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; @@ -71,6 +72,7 @@ void testExportAsZip_success() throws Exception { document.put("id", "1"); when(documentsUtils.getDocumentsUriAndUrlForSims("sims123")).thenReturn(new JSONArray().put(document)); + when(documentsUtils.existsInStorage(any())).thenReturn(false); var sims = new JSONObject(); sims.put("id", "sims123"); sims.put("labelLg1", "simsLabel"); @@ -93,8 +95,8 @@ void testExportAsZip_success() throws Exception { assertEquals(HttpStatus.OK, response.getStatusCode()); assertNotNull(response.getBody()); - assertEquals(response.getStatusCode(), HttpStatus.OK); - assertEquals(response.getHeaders().get("X-Missing-Documents").get(0), "1"); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + assertThat(response.getHeaders().get("X-Missing-Documents").getFirst()).isEqualTo("1"); } @Test diff --git a/src/test/java/fr/insee/rmes/integration/TestDocumentsResourcesWithMinio.java b/src/test/java/fr/insee/rmes/integration/TestDocumentsResourcesWithFilesOperation.java similarity index 50% rename from src/test/java/fr/insee/rmes/integration/TestDocumentsResourcesWithMinio.java rename to src/test/java/fr/insee/rmes/integration/TestDocumentsResourcesWithFilesOperation.java index 7187d466c..07cde8904 100644 --- a/src/test/java/fr/insee/rmes/integration/TestDocumentsResourcesWithMinio.java +++ b/src/test/java/fr/insee/rmes/integration/TestDocumentsResourcesWithFilesOperation.java @@ -1,7 +1,6 @@ package fr.insee.rmes.integration; import fr.insee.rmes.bauhaus_services.FilesOperations; -import fr.insee.rmes.bauhaus_services.operations.ParentUtils; import fr.insee.rmes.bauhaus_services.operations.documentations.documents.DocumentsImpl; import fr.insee.rmes.bauhaus_services.operations.documentations.documents.DocumentsUtils; import fr.insee.rmes.bauhaus_services.rdf_utils.PublicationUtils; @@ -24,6 +23,11 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import java.io.InputStream; +import java.nio.file.Path; + +import static fr.insee.rmes.utils.ConsoleCapture.startCapturingConsole; +import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.Matchers.containsString; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; @@ -31,54 +35,49 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @WebMvcTest(DocumentsResources.class) -@Import({BaseConfigForMvcTests.class, DocumentsImpl.class}) -class TestDocumentsResourcesWithMinio { +@Import({BaseConfigForMvcTests.class, DocumentsImpl.class, TestDocumentsResourcesWithFilesOperation.ConfigurationForTest.class}) +class TestDocumentsResourcesWithFilesOperation { @Autowired private MockMvc mockMvc; -// @MockBean -// private ParentUtils parentUtils; -// @MockBean -// private RepositoryPublication repositoryPublication; -// @MockBean -// private StampsRestrictionServiceImpl stampsRestrictionService; -// @MockBean -// private IdGenerator idGenerator; -// @MockBean -// private PublicationUtils publicationUtils; -// @MockBean -// private Config config; -// @MockBean -// private RepositoryGestion repositoryGestion; - @MockBean - FilesOperations filesOperations; + private RepositoryPublication repositoryPublication; + @MockBean + private StampsRestrictionServiceImpl stampsRestrictionService; + @MockBean + private IdGenerator idGenerator; + @MockBean + private PublicationUtils publicationUtils; + @MockBean + private Config config; + @MockBean + private RepositoryGestion repositoryGestion; private final String fichierId="ID"; - private static final String nomFichier = "nomFichier"; + static final String nomFichier = "nomFichier"; + static final String objectName = "directoryGestion/"+nomFichier; + static final String bucketName = "metadata_bucket"; @Test void shouldLogAndReturnInternalException_WhenErrorOccursInMinio() throws Exception { - - String objectName = "directoryGestion/"+nomFichier; - String bucketName = "metadata_bucket"; - when(filesOperations.read(anyString())).thenThrow(new RmesFileException(nomFichier, "Error reading file: " + nomFichier+ - " as object `"+objectName+"` in bucket "+bucketName, new MinioException())); - - + var capture=startCapturingConsole(); mockMvc.perform(MockMvcRequestBuilders.get("/documents/document/" + fichierId + "/file")) .andExpect(status().isInternalServerError()) .andExpect(content().string(containsString("fileName='" + nomFichier + "'"))); + assertThat(capture.standardOut()).asString().contains("Error reading file: "+nomFichier+" as object `"+objectName+"` in bucket "+bucketName); + assertThat(capture.standardOut()).asString().contains("at fr.insee.rmes.bauhaus_services.operations.documentations.documents.DocumentsUtils.downloadDocumentFile"); + assertThat(capture.standardOut()).asString().contains("at fr.insee.rmes.bauhaus_services.operations.documentations.documents.DocumentsImpl.downloadDocument"); + capture.stop(); } @TestConfiguration static class ConfigurationForTest{ @Bean - public DocumentsUtils documentsUtils(FilesOperations filesOperations) { - return new DocumentsUtils(null, filesOperations){ + public DocumentsUtils documentsUtils() { + return new DocumentsUtils(null, new FilesOperationStub()){ @Override protected String getDocumentFilename(String id){ return nomFichier; @@ -88,4 +87,38 @@ protected String getDocumentFilename(String id){ } + static class FilesOperationStub implements FilesOperations{ + + @Override + public void delete(Path absolutePath) { + + } + + @Override + public InputStream read(String path) { + throw new RmesFileException(nomFichier, "Error reading file: " + nomFichier+ + " as object `"+objectName+"` in bucket "+bucketName, new MinioException()); + } + + @Override + public void write(InputStream content, Path destPath) { + + } + + @Override + public void copy(String srcPath, String destPath) { + + } + + @Override + public boolean dirExists(Path gestionStorageFolder) { + return false; + } + + @Override + public boolean existsInStorage(String filename) { + return false; + } + } + } \ No newline at end of file diff --git a/src/test/java/fr/insee/rmes/utils/ConsoleCapture.java b/src/test/java/fr/insee/rmes/utils/ConsoleCapture.java new file mode 100644 index 000000000..9a4cc23cf --- /dev/null +++ b/src/test/java/fr/insee/rmes/utils/ConsoleCapture.java @@ -0,0 +1,41 @@ +package fr.insee.rmes.utils; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + +public class ConsoleCapture{ + + private final ByteArrayOutputStream standardOut; + private final ByteArrayOutputStream standardErr; + private boolean capturing; + private PrintStream lastErr; + private PrintStream lastOut; + + private ConsoleCapture(ByteArrayOutputStream standardOut, ByteArrayOutputStream standardErr) { + this.standardOut = standardOut; + this.standardErr = standardErr; + this.capturing=true; + } + + public static ConsoleCapture startCapturingConsole() { + ConsoleCapture consoleCapture = new ConsoleCapture(new ByteArrayOutputStream(), new ByteArrayOutputStream()); + consoleCapture.lastErr=System.err; + consoleCapture.lastOut=System.out; + System.setOut(new PrintStream(consoleCapture.standardOut)); + System.setErr(new PrintStream(consoleCapture.standardErr)); + return consoleCapture; + } + + public void stop() { + System.setErr(this.lastErr); + System.setOut(this.lastOut); + capturing=false; + } + + public String standardOut() { + if(! capturing) { + throw new IllegalStateException("No capturing any more"); + } + return standardOut.toString(); + } +} \ No newline at end of file diff --git a/src/test/java/fr/insee/rmes/webservice/DocumentsResourcesTest.java b/src/test/java/fr/insee/rmes/webservice/DocumentsResourcesTest.java index 78c66dd60..8204cd645 100644 --- a/src/test/java/fr/insee/rmes/webservice/DocumentsResourcesTest.java +++ b/src/test/java/fr/insee/rmes/webservice/DocumentsResourcesTest.java @@ -39,13 +39,4 @@ void shouldReturnNotFoundException() throws Exception { .andExpect(status().isNotFound()) .andExpect(content().string(containsString("id not found"))); } - - @Test - void shouldReturnInternalException() throws Exception { - when(documentsService.downloadDocument(anyString())).thenThrow(new RmesException(HttpStatus.INTERNAL_SERVER_ERROR.value(), "I/O error", "Error downloading file")); - - mockMvc.perform(MockMvcRequestBuilders.get("/documents/document/nomFichier/file")) - .andExpect(status().isInternalServerError()) - .andExpect(content().string(containsString("fileName='nomFichier'"))); - } }