Skip to content

Commit 730e80d

Browse files
committed
Remove logger from test class
1 parent c78195a commit 730e80d

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed
Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package com.github.stickerifier.stickerify.junit;
22

3-
import com.github.stickerifier.stickerify.logger.StructuredLogger;
43
import org.junit.jupiter.api.extension.AfterAllCallback;
54
import org.junit.jupiter.api.extension.ExtensionContext;
6-
import org.slf4j.event.Level;
75

86
import java.io.IOException;
97
import java.nio.file.Files;
@@ -15,8 +13,6 @@
1513
*/
1614
public class TempFilesCleanupExtension implements AfterAllCallback {
1715

18-
private static final StructuredLogger LOGGER = new StructuredLogger(TempFilesCleanupExtension.class);
19-
2016
@Override
2117
public void afterAll(ExtensionContext context) throws IOException {
2218
deleteTempFiles();
@@ -26,23 +22,17 @@ private void deleteTempFiles() throws IOException {
2622
var tempFolder = System.getProperty("java.io.tmpdir");
2723

2824
try (var files = Files.list(Path.of(tempFolder))) {
29-
files.filter(this::stickerifyFiles).forEach(this::deleteFile);
25+
for (var file : files.toList()) {
26+
if (isStickerifyFile(file)) {
27+
Files.delete(file);
28+
}
29+
}
3030
}
3131
}
3232

33-
private boolean stickerifyFiles(Path path) {
33+
private boolean isStickerifyFile(Path path) {
3434
var fileName = path.getFileName().toString();
3535

3636
return Files.isRegularFile(path) && (fileName.startsWith("Stickerify-") || fileName.startsWith("OriginalFile-"));
3737
}
38-
39-
private void deleteFile(Path path) {
40-
try {
41-
Files.delete(path);
42-
43-
LOGGER.at(Level.TRACE).addKeyValue("file_name", path.getFileName()).log("The file has been deleted");
44-
} catch (IOException e) {
45-
LOGGER.at(Level.WARN).setCause(e).addKeyValue("file_name", path.getFileName()).log("The file could not be deleted from the system");
46-
}
47-
}
4838
}

0 commit comments

Comments
 (0)