@Test public void parseFile_ShouldReturnEmptyProfile_OnError() throws Exception { Path testFile = getPath("profile.ffmpeg"); Optional<Profile> result = subject.parseFile(testFile); assertThat(result).isEmpty(); }
@Override public Optional<Profile> parseFile(Path path) { log.entry(path); try { List<String> lines = Files .lines(path) .map(String::trim) .filter(this::isNotCommentLine) .collect(Collectors.toList()); return log.exit(Optional.of( Profile.builder() .arguments(lines.stream() .filter(this::isNotFieldLine) .collect(Collectors.toList())) .fields(lines.stream() .filter(this::isFieldLine) .collect(Collectors.toMap(this::extractKey, this::extractValue))) .location(path) .build())); } catch (IOException e) { log.catching(XLogger.Level.WARN, e); return log.exit(Optional.empty()); } }
ProfileParserImpl implements ProfileParser { @Override public Optional<Profile> parseFile(Path path) { log.entry(path); try { List<String> lines = Files .lines(path) .map(String::trim) .filter(this::isNotCommentLine) .collect(Collectors.toList()); return log.exit(Optional.of( Profile.builder() .arguments(lines.stream() .filter(this::isNotFieldLine) .collect(Collectors.toList())) .fields(lines.stream() .filter(this::isFieldLine) .collect(Collectors.toMap(this::extractKey, this::extractValue))) .location(path) .build())); } catch (IOException e) { log.catching(XLogger.Level.WARN, e); return log.exit(Optional.empty()); } } }
ProfileParserImpl implements ProfileParser { @Override public Optional<Profile> parseFile(Path path) { log.entry(path); try { List<String> lines = Files .lines(path) .map(String::trim) .filter(this::isNotCommentLine) .collect(Collectors.toList()); return log.exit(Optional.of( Profile.builder() .arguments(lines.stream() .filter(this::isNotFieldLine) .collect(Collectors.toList())) .fields(lines.stream() .filter(this::isFieldLine) .collect(Collectors.toMap(this::extractKey, this::extractValue))) .location(path) .build())); } catch (IOException e) { log.catching(XLogger.Level.WARN, e); return log.exit(Optional.empty()); } }  }
ProfileParserImpl implements ProfileParser { @Override public Optional<Profile> parseFile(Path path) { log.entry(path); try { List<String> lines = Files .lines(path) .map(String::trim) .filter(this::isNotCommentLine) .collect(Collectors.toList()); return log.exit(Optional.of( Profile.builder() .arguments(lines.stream() .filter(this::isNotFieldLine) .collect(Collectors.toList())) .fields(lines.stream() .filter(this::isFieldLine) .collect(Collectors.toMap(this::extractKey, this::extractValue))) .location(path) .build())); } catch (IOException e) { log.catching(XLogger.Level.WARN, e); return log.exit(Optional.empty()); } }  @Override Optional<Profile> parseFile(Path path); }
ProfileParserImpl implements ProfileParser { @Override public Optional<Profile> parseFile(Path path) { log.entry(path); try { List<String> lines = Files .lines(path) .map(String::trim) .filter(this::isNotCommentLine) .collect(Collectors.toList()); return log.exit(Optional.of( Profile.builder() .arguments(lines.stream() .filter(this::isNotFieldLine) .collect(Collectors.toList())) .fields(lines.stream() .filter(this::isFieldLine) .collect(Collectors.toMap(this::extractKey, this::extractValue))) .location(path) .build())); } catch (IOException e) { log.catching(XLogger.Level.WARN, e); return log.exit(Optional.empty()); } }  @Override Optional<Profile> parseFile(Path path); static final Pattern FORMAT_PATTERN; }