@Test public void createParentDirTest() throws IOException { File child = mock(File.class); File parent = mock(File.class); when(child.getCanonicalFile()).thenReturn(child); when(child.getParentFile()).thenReturn(parent); when(parent.isDirectory()).thenReturn(true); util.createParentDirs(child); verify(parent).mkdirs(); }
public void createParentDirs(@Nonnull File file) throws IOException { File parent = file.getCanonicalFile().getParentFile(); if (parent == null) { return; } parent.mkdirs(); if (!parent.isDirectory()) { throw new IOException("Unable to create parent directories of " + file); } }
Util { public void createParentDirs(@Nonnull File file) throws IOException { File parent = file.getCanonicalFile().getParentFile(); if (parent == null) { return; } parent.mkdirs(); if (!parent.isDirectory()) { throw new IOException("Unable to create parent directories of " + file); } } }
Util { public void createParentDirs(@Nonnull File file) throws IOException { File parent = file.getCanonicalFile().getParentFile(); if (parent == null) { return; } parent.mkdirs(); if (!parent.isDirectory()) { throw new IOException("Unable to create parent directories of " + file); } }  }
Util { public void createParentDirs(@Nonnull File file) throws IOException { File parent = file.getCanonicalFile().getParentFile(); if (parent == null) { return; } parent.mkdirs(); if (!parent.isDirectory()) { throw new IOException("Unable to create parent directories of " + file); } }  @Nonnull String simplifyPath(@Nonnull String path); void createParentDirs(@Nonnull File file); }
Util { public void createParentDirs(@Nonnull File file) throws IOException { File parent = file.getCanonicalFile().getParentFile(); if (parent == null) { return; } parent.mkdirs(); if (!parent.isDirectory()) { throw new IOException("Unable to create parent directories of " + file); } }  @Nonnull String simplifyPath(@Nonnull String path); void createParentDirs(@Nonnull File file);  }