@Test @SuppressWarnings("unchecked") public void apply_ShouldReturnParentProfile_IfSiblingFileCouldNotBeRead() throws Exception { Path media = createFile(getPath("0", "movies", "subdir", "movie.mp4")); createFile(profileFolder.resolve("0/movies/subdir/profile.ffmpeg")); createFile(profileFolder.resolve("0/movies/profile.ffmpeg")); when(candidate.getSourcePath()).thenReturn(media); when(parser.parseFile(any())).thenReturn(Optional.empty(), Optional.of(profile)); Optional<Profile> result = subject.apply(candidate); assertThat(result).hasValue(profile); }
@Override public Optional<Profile> apply(Media candidate) { log.entry(candidate); Path mediaFileParent = candidate.getSourcePath().getParent(); Path sisterDir = profileScanConfig.profile_base_dir().resolve(mediaFileParent); Path profileFile = sisterDir.resolve(profileScanConfig.profile_file_name() + profileScanConfig .profile_file_name_extension()); Path rootDir = profileScanConfig.profile_base_dir().resolve(mediaFileParent.getName(0)); return log.exit(parseRecursive(profileFile, rootDir)); }
DirectoryStructureMatcher implements ProfileMatcher { @Override public Optional<Profile> apply(Media candidate) { log.entry(candidate); Path mediaFileParent = candidate.getSourcePath().getParent(); Path sisterDir = profileScanConfig.profile_base_dir().resolve(mediaFileParent); Path profileFile = sisterDir.resolve(profileScanConfig.profile_file_name() + profileScanConfig .profile_file_name_extension()); Path rootDir = profileScanConfig.profile_base_dir().resolve(mediaFileParent.getName(0)); return log.exit(parseRecursive(profileFile, rootDir)); } }
DirectoryStructureMatcher implements ProfileMatcher { @Override public Optional<Profile> apply(Media candidate) { log.entry(candidate); Path mediaFileParent = candidate.getSourcePath().getParent(); Path sisterDir = profileScanConfig.profile_base_dir().resolve(mediaFileParent); Path profileFile = sisterDir.resolve(profileScanConfig.profile_file_name() + profileScanConfig .profile_file_name_extension()); Path rootDir = profileScanConfig.profile_base_dir().resolve(mediaFileParent.getName(0)); return log.exit(parseRecursive(profileFile, rootDir)); } @Inject  DirectoryStructureMatcher(ProfileScanConfig profileScanConfig,
                              ProfileParser profileParser); }
DirectoryStructureMatcher implements ProfileMatcher { @Override public Optional<Profile> apply(Media candidate) { log.entry(candidate); Path mediaFileParent = candidate.getSourcePath().getParent(); Path sisterDir = profileScanConfig.profile_base_dir().resolve(mediaFileParent); Path profileFile = sisterDir.resolve(profileScanConfig.profile_file_name() + profileScanConfig .profile_file_name_extension()); Path rootDir = profileScanConfig.profile_base_dir().resolve(mediaFileParent.getName(0)); return log.exit(parseRecursive(profileFile, rootDir)); } @Inject  DirectoryStructureMatcher(ProfileScanConfig profileScanConfig,
                              ProfileParser profileParser); @Override Optional<Profile> apply(Media candidate); }
DirectoryStructureMatcher implements ProfileMatcher { @Override public Optional<Profile> apply(Media candidate) { log.entry(candidate); Path mediaFileParent = candidate.getSourcePath().getParent(); Path sisterDir = profileScanConfig.profile_base_dir().resolve(mediaFileParent); Path profileFile = sisterDir.resolve(profileScanConfig.profile_file_name() + profileScanConfig .profile_file_name_extension()); Path rootDir = profileScanConfig.profile_base_dir().resolve(mediaFileParent.getName(0)); return log.exit(parseRecursive(profileFile, rootDir)); } @Inject  DirectoryStructureMatcher(ProfileScanConfig profileScanConfig,
                              ProfileParser profileParser); @Override Optional<Profile> apply(Media candidate);  }