IOTools { public void flush(@Nullable final Flushable flushable) { if (flushable == null) { return; } try { flushable.flush(); } catch (final IOException e) { LOG.log(Level.WARNING, "Flush failed", e); } }  void flush(@Nullable final Flushable flushable); void close(@Nullable final Closeable closeable); void createFolder(final String folder);  }
@Test public void flushShouldHandleNull() { ioTools.flush(null); }
@Test public void flushShouldFlush() throws IOException { final Flushable flushable = mock(Flushable.class); ioTools.flush(flushable); verify(flushable).flush(); }
@Test public void flushShouldIgnoreExceptions() throws IOException { final Flushable flushable = mock(Flushable.class); doThrow(new IOException("Throw on flush")).when(flushable).flush(); ioTools.flush(flushable); verify(flushable).flush(); }