Add tests for attributeupdater

This commit is contained in:
RatzzFatzz
2025-12-16 00:22:10 +01:00
parent d3248e646b
commit 2ecea906b1
6 changed files with 111 additions and 11 deletions

View File

@@ -61,7 +61,7 @@ public class CoherentAttributeUpdater extends SingleFileAttributeUpdater {
if (config.isForceCoherent()) {
log.info("No coherent match found, aborting: {}", rootDir.getPath());
statistic.increaseNoSuitableConfigFoundBy(files.size()); // TODO: should matchedFiles count as already fit config?
statistic.increaseNoSuitableConfigFoundBy(files.size());
return;
}

View File

@@ -162,7 +162,7 @@ public class MkvFileProcessor implements FileProcessor {
log.debug("Executing '{}'", String.join(" ", command));
InputStream inputstream = Runtime.getRuntime().exec(command.toArray(new String[0])).getInputStream();
String output = IOUtils.toString(new InputStreamReader(inputstream));
log.debug("Result: {}", output);
log.debug("Result: {}", output.replaceAll("\\n", " '"));
if (output.contains("Error")) throw new MkvToolNixException(output);
}

View File

@@ -13,6 +13,10 @@ public class AttributeConfig {
private final String audioLanguage;
private final String subtitleLanguage;
public static AttributeConfig of(String audioLanguage, String subtitleLanguage) {
return new AttributeConfig(audioLanguage, subtitleLanguage);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;

View File

@@ -51,8 +51,9 @@ public class InputConfig implements CommandLine.IVersionProvider {
@Option(names = {"-cf", "--force-coherent"}, description = "only applies changes if a coherent match was found for the specifically entered depth")
private boolean forceCoherent;
@Option(names = {"-n", "--only-new-file"}, description = "sets filter-date to last successful execution (overwrites input of filter-date)")
private boolean onlyNewFiles; // TODO: implement usage
// 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 = {"-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 (default: \".*\")")
@@ -92,20 +93,23 @@ public class InputConfig implements CommandLine.IVersionProvider {
public String toString() {
return new StringJoiner(", ", InputConfig.class.getSimpleName() + "[", "]")
.add("configPath=" + configPath)
.add("spec=" + spec)
.add("attributeConfig=" + Arrays.toString(attributeConfig))
.add("libraryPath=" + libraryPath)
.add("mkvToolNix=" + mkvToolNix)
.add("threads=" + threads)
.add("includePattern=" + includePattern)
.add("safeMode=" + safeMode)
.add("threads=" + threads)
.add("coherent=" + coherent)
.add("forceCoherent=" + forceCoherent)
.add("onlyNewFiles=" + onlyNewFiles)
.add("filterDate=" + filterDate)
.add("includePattern=" + includePattern)
.add("excluded=" + excluded)
.add("overwriteForced=" + overwriteForced)
.add("forcedKeywords=" + forcedKeywords)
.add("commentaryKeywords=" + commentaryKeywords)
.add("excludedDirectories=" + excluded)
.add("hearingImpaired=" + hearingImpaired)
.add("preferredSubtitles=" + preferredSubtitles)
.add("attributeConfig=" + attributeConfig)
.add("debug=" + debug)
.toString();
}