@Test public void createDirectoryRecursivelyShouldThrowExceptionUnableToCreateDirectory(@Mocked final Files unused) { try { new Expectations() { { Files.createDirectories((Path) any); result = new IOException("testException123"); } }; } catch (IOException e) { fail("Unexpected exception in expectations block: " + e); } try { OdeFileUtils.createDirectoryRecursively(dir); fail("Expected IOException while trying to create directory:"); } catch (Exception e) { assertEquals(IOException.class, e.getClass()); assertTrue(e.getMessage().startsWith("Exception while trying to create directory:")); } }
public static void createDirectoryRecursively(Path dir) throws IOException { try { Files.createDirectories(dir); } catch (IOException e) { throw new IOException("Exception while trying to create directory: " + e); } if (!dir.toFile().exists()) { throw new IOException("Failed to verify directory creation - directory does not exist."); } }
OdeFileUtils { public static void createDirectoryRecursively(Path dir) throws IOException { try { Files.createDirectories(dir); } catch (IOException e) { throw new IOException("Exception while trying to create directory: " + e); } if (!dir.toFile().exists()) { throw new IOException("Failed to verify directory creation - directory does not exist."); } } }
OdeFileUtils { public static void createDirectoryRecursively(Path dir) throws IOException { try { Files.createDirectories(dir); } catch (IOException e) { throw new IOException("Exception while trying to create directory: " + e); } if (!dir.toFile().exists()) { throw new IOException("Failed to verify directory creation - directory does not exist."); } } private  OdeFileUtils(); }
OdeFileUtils { public static void createDirectoryRecursively(Path dir) throws IOException { try { Files.createDirectories(dir); } catch (IOException e) { throw new IOException("Exception while trying to create directory: " + e); } if (!dir.toFile().exists()) { throw new IOException("Failed to verify directory creation - directory does not exist."); } } private  OdeFileUtils(); static void createDirectoryRecursively(Path dir); static void backupFile(Path file, Path backupDir); static void moveFile(Path file, Path destination); }
OdeFileUtils { public static void createDirectoryRecursively(Path dir) throws IOException { try { Files.createDirectories(dir); } catch (IOException e) { throw new IOException("Exception while trying to create directory: " + e); } if (!dir.toFile().exists()) { throw new IOException("Failed to verify directory creation - directory does not exist."); } } private  OdeFileUtils(); static void createDirectoryRecursively(Path dir); static void backupFile(Path file, Path backupDir); static void moveFile(Path file, Path destination);  }