diff --git a/src/main/java/it/gov/pagopa/atmlayer/service/model/utils/FileUtilities.java b/src/main/java/it/gov/pagopa/atmlayer/service/model/utils/FileUtilities.java index a14bc456..54b0ffd2 100644 --- a/src/main/java/it/gov/pagopa/atmlayer/service/model/utils/FileUtilities.java +++ b/src/main/java/it/gov/pagopa/atmlayer/service/model/utils/FileUtilities.java @@ -98,8 +98,7 @@ public static String toHexString(byte[] hash) { public static File fromStringToFile(String fileBase64) { try { byte[] decodedBytes = Base64.getDecoder().decode(fileBase64); - Files.createDirectories(Path.of("/decoded")); - File tempFile = File.createTempFile("tempfile", ".tmp", new File("/decoded")); + File tempFile = File.createTempFile("tempfile", ".tmp"); try (FileOutputStream fos = new FileOutputStream(tempFile)) { fos.write(decodedBytes); } diff --git a/src/test/java/it/gov/pagopa/atmlayer/service/model/utils/FileUtilitiesTest.java b/src/test/java/it/gov/pagopa/atmlayer/service/model/utils/FileUtilitiesTest.java index 1b076548..bf29822a 100644 --- a/src/test/java/it/gov/pagopa/atmlayer/service/model/utils/FileUtilitiesTest.java +++ b/src/test/java/it/gov/pagopa/atmlayer/service/model/utils/FileUtilitiesTest.java @@ -25,20 +25,20 @@ @QuarkusTest class FileUtilitiesTest { -// @Test -// void testFromStringToFile_ValidBase64() throws IOException { -// String validBase64 = Base64.getEncoder().encodeToString("Hello World!".getBytes()); -// String fileName = "filename"; -// -// File result = fromStringToFile(validBase64); -// -// assertNotNull(result); -// assertTrue(result.exists()); -// -// byte[] fileContent = Files.readAllBytes(result.toPath()); -// assertEquals("Hello World!", new String(fileContent)); -// -// } + @Test + void testFromStringToFile_ValidBase64() throws IOException { + String validBase64 = Base64.getEncoder().encodeToString("Hello World!".getBytes()); + String fileName = "filename"; + + File result = fromStringToFile(validBase64); + + assertNotNull(result); + assertTrue(result.exists()); + + byte[] fileContent = Files.readAllBytes(result.toPath()); + assertEquals("Hello World!", new String(fileContent)); + + } @Test void testFromStringToFile_InvalidBase64() {