test: Fix test db setup and add lombok annotations (#6)

* Fix test db setup and add lombok annotations

* Formatting
This commit is contained in:
Torge Hamann 2024-11-17 21:30:50 +01:00 committed by GitHub
parent c3da0eff5c
commit a2aea580f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 26 additions and 41 deletions

View file

@ -1,20 +1,17 @@
package de.mlessmann.certassist;
import static org.slf4j.LoggerFactory.getLogger;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.FileVisitor;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import org.slf4j.Logger;
import lombok.extern.slf4j.Slf4j;
import org.springframework.lang.NonNull;
@Slf4j
public class DeleteRecursiveFileVisitor implements FileVisitor<Path> {
private static final Logger LOGGER = getLogger(DeleteRecursiveFileVisitor.class);
@NonNull
@Override
public FileVisitResult preVisitDirectory(Path dir, @NonNull BasicFileAttributes attrs) throws IOException {
@ -24,7 +21,7 @@ public class DeleteRecursiveFileVisitor implements FileVisitor<Path> {
@NonNull
@Override
public FileVisitResult visitFile(Path file, @NonNull BasicFileAttributes attrs) throws IOException {
LOGGER.trace("Deleting file {}", file);
log.trace("Deleting file {}", file);
Files.delete(file);
return FileVisitResult.CONTINUE;
}
@ -32,14 +29,14 @@ public class DeleteRecursiveFileVisitor implements FileVisitor<Path> {
@NonNull
@Override
public FileVisitResult visitFileFailed(Path file, @NonNull IOException exc) throws IOException {
LOGGER.error("Could not delete file {}", file, exc);
log.error("Could not delete file {}", file, exc);
throw exc;
}
@NonNull
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
LOGGER.trace("Deleting directory {}", dir);
log.trace("Deleting directory {}", dir);
Files.delete(dir);
return FileVisitResult.CONTINUE;
}