From a5aae0acf4ba47a4b91144e791fa176223d05aec Mon Sep 17 00:00:00 2001 From: RatzzFatzz Date: Thu, 8 Jan 2026 22:03:06 +0100 Subject: [PATCH] Add handler for only new files parameter --- .../impl/CommandRunner.java | 7 +- .../impl/FileFilter.java | 26 ++++--- .../impl/LastExecutionHandler.java | 61 ++++++++++++++++ .../impl/processors/AttributeUpdater.java | 8 ++- .../processors/CoherentAttributeUpdater.java | 5 +- .../SingleFileAttributeUpdater.java | 5 +- .../model/InputConfig.java | 4 +- .../impl/FileFilterTest.java | 2 +- .../impl/LastExecutionHandlerTest.java | 72 +++++++++++++++++++ .../impl/processors/AttributeUpdaterTest.java | 3 +- .../CoherentAttributeUpdaterTest.java | 8 ++- .../SingleFileAttributeUpdaterTest.java | 6 +- 12 files changed, 178 insertions(+), 29 deletions(-) create mode 100644 src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/LastExecutionHandler.java create mode 100644 src/test/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/LastExecutionHandlerTest.java diff --git a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/CommandRunner.java b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/CommandRunner.java index f818dad..4539d08 100644 --- a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/CommandRunner.java +++ b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/CommandRunner.java @@ -39,13 +39,14 @@ public class CommandRunner implements Runnable { System.out.println("Safemode active. No files will be changed!"); } - FileFilter fileFilter = new FileFilter(config.getExcluded(), config.getIncludePattern(), config.getFilterDate()); + LastExecutionHandler lastExecutionHandler = config.isOnlyNewFiles() ? new LastExecutionHandler("./last-executions.yml") : null; + FileFilter fileFilter = new FileFilter(config.getExcluded(), config.getIncludePattern(), config.getFilterDate(), lastExecutionHandler); FileProcessor fileProcessor = new CachedFileProcessor(new MkvFileProcessor(config.getMkvToolNix(), fileFilter)); AttributeChangeProcessor attributeChangeProcessor = new AttributeChangeProcessor(config.getPreferredSubtitles().toArray(new String[0]), config.getForcedKeywords(), config.getCommentaryKeywords(), config.getHearingImpaired()); AttributeUpdater kernel = config.getCoherent() != null - ? new CoherentAttributeUpdater(config, fileProcessor, attributeChangeProcessor) - : new SingleFileAttributeUpdater(config, fileProcessor, attributeChangeProcessor); + ? new CoherentAttributeUpdater(config, fileProcessor, attributeChangeProcessor, lastExecutionHandler) + : new SingleFileAttributeUpdater(config, fileProcessor, attributeChangeProcessor, lastExecutionHandler); kernel.execute(); } } diff --git a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/FileFilter.java b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/FileFilter.java index 8f78dc6..b1045a0 100644 --- a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/FileFilter.java +++ b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/FileFilter.java @@ -9,9 +9,7 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.attribute.BasicFileAttributes; -import java.util.Date; -import java.util.HashSet; -import java.util.Set; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -21,6 +19,7 @@ public class FileFilter { private final Set excluded; private final Pattern includePattern; private final Date filterDate; + private final LastExecutionHandler lastExecutionHandler; private final String EXTENSION_GROUP = "extension"; private final Pattern extensionPattern = Pattern.compile(String.format(".*(?<%s>\\..*)", EXTENSION_GROUP)); @@ -33,8 +32,9 @@ public class FileFilter { } if (!hasMatchingPattern(pathName) - || !isNewer(pathName) - || isExcluded(pathName, new HashSet<>(excluded))) { + || isExcluded(pathName, new HashSet<>(excluded)) + || lastExecutionHandler != null && !isNewOrChanged(pathName) + || !isNewer(pathName, filterDate)) { log.debug("Excluded {}", pathName); ResultStatistic.getInstance().excluded(); return false; @@ -52,19 +52,20 @@ public class FileFilter { return includePattern.matcher(pathName.getName()).matches(); } - private boolean isNewer(File pathName) { - if (filterDate == null) return true; + private boolean isNewer(File pathName, Date date) { + if (date == null) return true; try { BasicFileAttributes attributes = Files.readAttributes(pathName.toPath(), BasicFileAttributes.class); - return isNewer(DateUtils.convert(attributes.creationTime().toMillis())); + return isNewer(DateUtils.convert(attributes.creationTime().toMillis()), date) + || isNewer(DateUtils.convert(attributes.lastModifiedTime().toMillis()), date); } catch (IOException e) { log.warn("File attributes could not be read", e); } return true; } - private boolean isNewer(Date creationDate) { - return creationDate.toInstant().isAfter(filterDate.toInstant()); + private boolean isNewer(Date creationDate, Date compareDate) { + return creationDate.toInstant().isAfter(compareDate.toInstant()); } private boolean isExcluded(File pathName, Set excludedDirs) { @@ -86,4 +87,9 @@ public class FileFilter { return false; } + + private boolean isNewOrChanged(File pathname) { + Date lastExecutionDate = lastExecutionHandler.get(pathname.getAbsolutePath()); + return lastExecutionDate == null || isNewer(pathname, lastExecutionDate); + } } diff --git a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/LastExecutionHandler.java b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/LastExecutionHandler.java new file mode 100644 index 0000000..596d41d --- /dev/null +++ b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/LastExecutionHandler.java @@ -0,0 +1,61 @@ +package at.pcgamingfreaks.mkvaudiosubtitlechanger.impl; + +import at.pcgamingfreaks.yaml.YAML; +import at.pcgamingfreaks.yaml.YamlInvalidContentException; +import at.pcgamingfreaks.yaml.YamlKeyNotFoundException; +import lombok.extern.slf4j.Slf4j; + +import java.io.File; +import java.io.IOException; +import java.time.Instant; +import java.util.Date; + +@Slf4j +public class LastExecutionHandler { + private final File file; + private YAML lastFileExecution; + + public LastExecutionHandler(String path) { + file = new File(path); + try { + lastFileExecution = loadLastFileExecution(file); + } catch (YamlInvalidContentException | IOException e) { + log.warn("Couldn't find or read {}", path, e); + } + } + + public YAML loadLastFileExecution(File file) throws YamlInvalidContentException, IOException { + if (file.exists() && file.isFile()) { + return new YAML(file); + } + return new YAML(""); + } + + public Date get(String path) { + if (!lastFileExecution.isSet(path)) return null; + try { + return Date.from(Instant.parse(lastFileExecution.getString(path))); + } catch (YamlKeyNotFoundException e) { + throw new RuntimeException(e); + } + } + + public void update(String path) { + update(path, Date.from(Instant.now())); + } + + public void update(String path, Date execution) { + if (lastFileExecution == null) return; + lastFileExecution.set(path, execution.toInstant()); + } + + public void persist() { + try { + lastFileExecution.save(file); + } catch (IOException e) { + log.warn("", e); + } + } +} + + diff --git a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/AttributeUpdater.java b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/AttributeUpdater.java index 228bcfc..2df82e5 100644 --- a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/AttributeUpdater.java +++ b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/AttributeUpdater.java @@ -1,6 +1,7 @@ package at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.processors; import at.pcgamingfreaks.mkvaudiosubtitlechanger.exceptions.MkvToolNixException; +import at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.LastExecutionHandler; import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.FileInfo; import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.InputConfig; import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.ResultStatistic; @@ -25,14 +26,16 @@ public abstract class AttributeUpdater { protected final InputConfig config; protected final FileProcessor fileProcessor; protected final AttributeChangeProcessor attributeChangeProcessor; + protected final LastExecutionHandler lastExecutionHandler; protected final ResultStatistic statistic = ResultStatistic.getInstance(); private final ExecutorService executor; - public AttributeUpdater(InputConfig config, FileProcessor fileProcessor, AttributeChangeProcessor attributeChangeProcessor) { + public AttributeUpdater(InputConfig config, FileProcessor fileProcessor, AttributeChangeProcessor attributeChangeProcessor, LastExecutionHandler lastExecutionHandler) { this.config = config; this.fileProcessor = fileProcessor; this.attributeChangeProcessor = attributeChangeProcessor; + this.lastExecutionHandler = lastExecutionHandler; this.executor = Executors.newFixedThreadPool(config.getThreads()); } @@ -62,7 +65,7 @@ public abstract class AttributeUpdater { executor.awaitTermination(1, TimeUnit.DAYS); } -// writeLastExecutionDate(); + lastExecutionHandler.persist(); statistic.stopTimer(); statistic.print(); @@ -84,6 +87,7 @@ public abstract class AttributeUpdater { * @param fileInfo contains information about file and desired configuration. */ protected void checkStatusAndUpdate(FileInfo fileInfo) { + if (lastExecutionHandler != null) lastExecutionHandler.update(fileInfo.getFile().getAbsolutePath()); if (!fileInfo.getChanges().isEmpty()) { statistic.changePlanned(); diff --git a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/CoherentAttributeUpdater.java b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/CoherentAttributeUpdater.java index 595dd8b..10cb59e 100644 --- a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/CoherentAttributeUpdater.java +++ b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/CoherentAttributeUpdater.java @@ -1,5 +1,6 @@ package at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.processors; +import at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.LastExecutionHandler; import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.FileInfo; import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.InputConfig; import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.AttributeConfig; @@ -15,8 +16,8 @@ import java.util.Set; @Slf4j public class CoherentAttributeUpdater extends SingleFileAttributeUpdater { - public CoherentAttributeUpdater(InputConfig config, FileProcessor processor, AttributeChangeProcessor attributeChangeProcessor) { - super(config, processor, attributeChangeProcessor); + public CoherentAttributeUpdater(InputConfig config, FileProcessor processor, AttributeChangeProcessor attributeChangeProcessor, LastExecutionHandler lastExecutionHandler) { + super(config, processor, attributeChangeProcessor, lastExecutionHandler); } @Override diff --git a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/SingleFileAttributeUpdater.java b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/SingleFileAttributeUpdater.java index 7e6f97e..6e4bd4f 100644 --- a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/SingleFileAttributeUpdater.java +++ b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/SingleFileAttributeUpdater.java @@ -1,5 +1,6 @@ package at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.processors; +import at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.LastExecutionHandler; import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.FileInfo; import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.InputConfig; import lombok.extern.slf4j.Slf4j; @@ -12,8 +13,8 @@ import java.util.List; @Slf4j public class SingleFileAttributeUpdater extends AttributeUpdater { - public SingleFileAttributeUpdater(InputConfig config, FileProcessor processor, AttributeChangeProcessor attributeChangeProcessor) { - super(config, processor, attributeChangeProcessor); + public SingleFileAttributeUpdater(InputConfig config, FileProcessor processor, AttributeChangeProcessor attributeChangeProcessor, LastExecutionHandler lastExecutionHandler) { + super(config, processor, attributeChangeProcessor, lastExecutionHandler); } @Override diff --git a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/model/InputConfig.java b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/model/InputConfig.java index e610348..b0d4d56 100644 --- a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/model/InputConfig.java +++ b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/model/InputConfig.java @@ -53,8 +53,8 @@ public class InputConfig implements CommandLine.IVersionProvider { private boolean forceCoherent; // TODO: implement usage -// @Option(names = {"-n", "--only-new-file"}, description = "sets filter-date to last successful execution (overwrites input of filter-date)") -// private boolean onlyNewFiles; + @Option(names = {"-n", "--only-new-file"}, description = "ignores all files unchanged and previously processed") + private boolean onlyNewFiles; @Option(names = {"-d", "--filter-date"}, defaultValue = Option.NULL_VALUE, description = "only consider files created newer than entered date (format: \"dd.MM.yyyy-HH:mm:ss\")") private Date filterDate; @Option(names = {"-i", "--include-pattern"}, defaultValue = ".*", description = "include files matching pattern") diff --git a/src/test/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/FileFilterTest.java b/src/test/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/FileFilterTest.java index 5fae36f..acafa6d 100644 --- a/src/test/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/FileFilterTest.java +++ b/src/test/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/FileFilterTest.java @@ -71,7 +71,7 @@ class FileFilterTest { when(file.toPath()).thenReturn(Path.of(TEST_FILE)); long currentTime = System.currentTimeMillis(); - FileFilter fileFilter = new FileFilter(excludedDirs, Pattern.compile(pattern), new Date(currentTime + filterDateOffset)); + FileFilter fileFilter = new FileFilter(excludedDirs, Pattern.compile(pattern), new Date(currentTime + filterDateOffset), null); try (MockedStatic mockedFiles = Mockito.mockStatic(DateUtils.class)) { mockedFiles diff --git a/src/test/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/LastExecutionHandlerTest.java b/src/test/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/LastExecutionHandlerTest.java new file mode 100644 index 0000000..b079cca --- /dev/null +++ b/src/test/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/LastExecutionHandlerTest.java @@ -0,0 +1,72 @@ +package at.pcgamingfreaks.mkvaudiosubtitlechanger.impl; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.time.Instant; + +import static org.junit.jupiter.api.Assertions.*; + +class LastExecutionHandlerTest { + private static final String LAST_EXECUTION_YML = "./last-execution.yml"; + + @AfterEach + void destruct() { + File file = new File("./last-execution.yml"); + if (file.exists()) file.delete(); + } + + @Test + void missingFile() throws IOException { + LastExecutionHandler underTest = new LastExecutionHandler("./last-execution.yml"); + assertNull(underTest.get("/arst")); + underTest.update("/arst"); + assertNotNull(underTest.get("/arst")); + underTest.persist(); + File file = new File("./last-execution.yml"); + assertTrue(file.exists()); + assertTrue(Files.readString(file.toPath()).contains("/arst: ")); + } + + @Test + void emptyFile() throws IOException { + File file = new File(LAST_EXECUTION_YML); + file.createNewFile(); + missingFile(); // does the checks needed for empty file case + } + + @Test + void existingFileNoChanges() throws IOException { + File file = new File(LAST_EXECUTION_YML); + file.createNewFile(); + Files.writeString(file.toPath(), "/arst: \"" + Instant.now() + "\""); + String expected = Files.readString(file.toPath()); + + LastExecutionHandler underTest = new LastExecutionHandler(LAST_EXECUTION_YML); + assertNotNull(underTest.get("/arst")); + underTest.persist(); + File file1 = new File(LAST_EXECUTION_YML); + assertTrue(file1.exists()); + assertEquals(expected, Files.readString(file.toPath())); + } + + @Test + void existingFileWithChanges() throws IOException { + File file = new File(LAST_EXECUTION_YML); + file.createNewFile(); + Files.writeString(file.toPath(), "/arst: \"" + Instant.now() + "\""); + String expected = Files.readString(file.toPath()); + + LastExecutionHandler underTest = new LastExecutionHandler(LAST_EXECUTION_YML); + assertNotNull(underTest.get("/arst")); + underTest.update("/arst"); + assertNotNull(underTest.get("/arst")); + underTest.persist(); + File file1 = new File(LAST_EXECUTION_YML); + assertTrue(file1.exists()); + assertNotEquals(expected, Files.readString(file.toPath())); + } +} \ No newline at end of file diff --git a/src/test/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/AttributeUpdaterTest.java b/src/test/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/AttributeUpdaterTest.java index d40c790..a6a4140 100644 --- a/src/test/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/AttributeUpdaterTest.java +++ b/src/test/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/AttributeUpdaterTest.java @@ -1,5 +1,6 @@ package at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.processors; +import at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.LastExecutionHandler; import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.*; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.params.ParameterizedTest; @@ -36,7 +37,7 @@ class AttributeUpdaterTest { InputConfig config = new InputConfig(); config.setThreads(1); config.setSafeMode(true); - AttributeUpdater underTest = new AttributeUpdater(config, null, null) { + AttributeUpdater underTest = new AttributeUpdater(config, null, null, new LastExecutionHandler("")) { @Override protected List getFiles() { return List.of(); diff --git a/src/test/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/CoherentAttributeUpdaterTest.java b/src/test/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/CoherentAttributeUpdaterTest.java index 08ef0e5..c202f03 100644 --- a/src/test/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/CoherentAttributeUpdaterTest.java +++ b/src/test/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/CoherentAttributeUpdaterTest.java @@ -1,12 +1,12 @@ package at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.processors; import at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.CommandRunner; +import at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.LastExecutionHandler; import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.AttributeConfig; import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.FileInfo; import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.InputConfig; import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.TrackAttributes; import org.apache.commons.lang3.tuple.Pair; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -66,7 +66,8 @@ class CoherentAttributeUpdaterTest { new CommandLine(commandRunner).parseArgs("-a", "ger:ger", "/arst"); InputConfig config = commandRunner.getConfig(); AttributeChangeProcessor attributeChangeProcessor = new AttributeChangeProcessor(config.getPreferredSubtitles().toArray(new String[0]), config.getForcedKeywords(), config.getCommentaryKeywords(), config.getHearingImpaired()); - CoherentAttributeUpdater updater = new CoherentAttributeUpdater(config, fileProcessor, attributeChangeProcessor); + LastExecutionHandler lastExecutionHandler = new LastExecutionHandler(""); + CoherentAttributeUpdater updater = new CoherentAttributeUpdater(config, fileProcessor, attributeChangeProcessor, lastExecutionHandler); Set matchedFiles = new HashSet<>(fileInfoMock.size() * 2); List files = new ArrayList<>(); @@ -193,7 +194,8 @@ class CoherentAttributeUpdaterTest { doReturn(testMkvFiles).when(fileProcessor).loadFiles(any()); AttributeChangeProcessor attributeChangeProcessor = new AttributeChangeProcessor(new String[]{"pref"}, Set.of("forced"), Set.of("commentary"), Set.of("SDH")); - CoherentAttributeUpdater underTest = new CoherentAttributeUpdater(config, fileProcessor, attributeChangeProcessor); + LastExecutionHandler lastExecutionHandler = new LastExecutionHandler(""); + CoherentAttributeUpdater underTest = new CoherentAttributeUpdater(config, fileProcessor, attributeChangeProcessor, lastExecutionHandler); underTest.process(new File("")); diff --git a/src/test/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/SingleFileAttributeUpdaterTest.java b/src/test/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/SingleFileAttributeUpdaterTest.java index 3b19d02..ac549d6 100644 --- a/src/test/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/SingleFileAttributeUpdaterTest.java +++ b/src/test/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/impl/processors/SingleFileAttributeUpdaterTest.java @@ -1,10 +1,10 @@ package at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.processors; +import at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.LastExecutionHandler; import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.AttributeConfig; import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.FileInfo; import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.InputConfig; import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.TrackAttributes; -import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -16,7 +16,6 @@ import java.util.Set; import java.util.stream.Stream; import static at.pcgamingfreaks.mkvaudiosubtitlechanger.util.PathUtils.TEST_DIR; -import static at.pcgamingfreaks.mkvaudiosubtitlechanger.util.PathUtils.TEST_FILE; import static at.pcgamingfreaks.mkvaudiosubtitlechanger.util.TrackAttributeUtil.*; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; @@ -78,7 +77,8 @@ class SingleFileAttributeUpdaterTest { FileProcessor fileProcessor = spy(FileProcessor.class); doReturn(fileInfo).when(fileProcessor).readAttributes(any()); AttributeChangeProcessor attributeChangeProcessor = new AttributeChangeProcessor(new String[]{"pref"}, Set.of("forced"), Set.of("commentary"), Set.of("SDH")); - SingleFileAttributeUpdater underTest = new SingleFileAttributeUpdater(config, fileProcessor, attributeChangeProcessor); + LastExecutionHandler lastExecutionHandler = new LastExecutionHandler(""); + SingleFileAttributeUpdater underTest = new SingleFileAttributeUpdater(config, fileProcessor, attributeChangeProcessor, lastExecutionHandler); underTest.process(fileInfo.getFile());