FileUtil { public static Stream<URL> filesToUrls(final File... jars) { if (jars == null) { throw new IllegalArgumentException("Null"); } return Stream.of(jars) .map(f -> { try { return Optional.of(f.toURI() .toURL()); } catch (final MalformedURLException e) { LOGGER.debug("Skipping file: '{}'.", f, e); return Optional.<URL>empty(); } }) .flatMap(Optional::stream); } private  FileUtil(); static boolean configurePermissions(final File f, final boolean executable); static boolean isJarFile(final File f); static Either<Exception, Optional<File>> findFolder(final String folderName); static Stream<URL> filesToUrls(final File... jars);  }
@Test void processFaultyFiles() throws URISyntaxException { final URI uri = new URI("wrongproto: final File f = mock(File.class); when(f.toURI()).thenReturn(uri); assertThat(FileUtil.filesToUrls(f)).isEmpty(); }
@Test void someUrls() throws IOException { File f = File.createTempFile("robozonky-", ".testing"); assertThat(FileUtil.filesToUrls(f)).contains(f.toURI() .toURL()); }
@Test void nullUrls() { assertThatThrownBy(() -> FileUtil.filesToUrls((File[]) null)) .isInstanceOf(IllegalArgumentException.class); }
@Test void emptyUrls() { assertThat(FileUtil.filesToUrls(new File[0])).isEmpty(); }