@Test public void notReadable() throws IOException { final FileContents fileContents = new FileContents(Paths.get("fakepath")); assertThat(fileContents.get(), is("")); }
public static boolean isGraphvizAvailable() { final List<String> command = new ArrayList<>(); command.add("dot"); command.add("-V"); LOGGER.log(Level.INFO, new StringFormat("Checking if Graphviz is available:\n%s", command.toString())); final ProcessExecutor processExecutor = new ProcessExecutor(); processExecutor.setCommandLine(command); Integer exitCode; try { exitCode = processExecutor.call(); LOGGER.log(Level.INFO, new FileContents(processExecutor.getProcessOutput())); } catch (final Exception e) { LOGGER.log(Level.WARNING, "Could not execute Graphviz command", e); LOGGER.log(Level.WARNING, new FileContents(processExecutor.getProcessError())); exitCode = Integer.MIN_VALUE; } final boolean successful = exitCode != null && exitCode == 0; return successful; }
@Override public String toString() { return get(); }
@Test public void nullcheck() throws IOException { assertThrows(NullPointerException.class, () -> new FileContents(null)); final Path tempFilePath = IOUtility.createTempFilePath("test", ".dat"); assertThrows(NullPointerException.class, () -> new FileContents(tempFilePath, null)); }
@Override public String toString() { return get(); }
@Test public void badEncoding() throws IOException { final String text = "Hello, World!"; final Path tempFilePath = IOUtility.createTempFilePath("test", ".dat"); Files.write(tempFilePath, text.getBytes("UTF-8")); final FileContents fileContents = new FileContents(tempFilePath, StandardCharsets.UTF_16); assertThat(fileContents.get(), is(not(text))); }
new FileContents(processExecutor.getProcessOutput())); final Supplier<String> processError = new FileContents(processExecutor .getProcessError()); if (!successful)
@Override public String toString() { return get(); }
@Test public void happyPath() throws IOException { final String text = "Hello, World!"; final Path tempFilePath = IOUtility.createTempFilePath("test", ".dat"); Files.write(tempFilePath, text.getBytes("UTF-8")); final FileContents fileContents = new FileContents(tempFilePath); assertThat(fileContents.get(), is(text)); }
public static boolean isGraphvizAvailable() { final List<String> command = new ArrayList<>(); command.add("dot"); command.add("-V"); LOGGER.log(Level.INFO, new StringFormat("Checking if Graphviz is available:\n%s", command.toString())); final ProcessExecutor processExecutor = new ProcessExecutor(); processExecutor.setCommandLine(command); Integer exitCode; try { exitCode = processExecutor.call(); LOGGER.log(Level.INFO, new FileContents(processExecutor.getProcessOutput())); } catch (final Exception e) { LOGGER.log(Level.WARNING, "Could not execute Graphviz command", e); LOGGER.log(Level.WARNING, new FileContents(processExecutor.getProcessError())); exitCode = Integer.MIN_VALUE; } final boolean successful = exitCode != null && exitCode == 0; return successful; }
@Override public String toString() { return get(); }
public static boolean isGraphvizAvailable() { final List<String> command = new ArrayList<>(); command.add("dot"); command.add("-V"); LOGGER.log(Level.INFO, new StringFormat("Checking if Graphviz is available:\n%s", command.toString())); final ProcessExecutor processExecutor = new ProcessExecutor(); processExecutor.setCommandLine(command); Integer exitCode; try { exitCode = processExecutor.call(); LOGGER.log(Level.INFO, new FileContents(processExecutor.getProcessOutput())); } catch (final Exception e) { LOGGER.log(Level.WARNING, "Could not execute Graphviz command", e); LOGGER.log(Level.WARNING, new FileContents(processExecutor.getProcessError())); exitCode = Integer.MIN_VALUE; } final boolean successful = exitCode != null && exitCode == 0; return successful; }
new FileContents(processExecutor.getProcessOutput())); final Supplier<String> processError = new FileContents(processExecutor .getProcessError()); if (!successful)
new FileContents(processExecutor.getProcessOutput())); final Supplier<String> processError = new FileContents(processExecutor .getProcessError()); if (!successful)