### Question:
FileTool { public static void ensureDirectoryExists(final Path file, final String errorTemplate) { Path parent = file.getParent(); try { if (parent != null) { Files.createDirectories(parent); } } catch (final IOException e) { throw buildError(parent, errorTemplate, e); } } private  FileTool(); static void ensureDirectoryExists(final Path file, final String errorTemplate); static void writeMinimalJson(final Path file, final String errorTemplate); static void writeAsJson(final Path file, final Object v, final String errorTemplate); static T readFromJson(final Class<T> beanClass, final Path file, final String errorTemplate);  }### Answer:
@Test public void testEnsureDirectoryExistsWithError() { Path impossible = existingFile.resolve("file"); assertThrows(SantaException.class, () -> FileTool.ensureDirectoryExists(impossible, ERROR_TEMPLATE)); }
@Test public void testEnsureDirectoryExistsWithDirectory() { FileTool.ensureDirectoryExists(existingFile, ERROR_TEMPLATE); assertTrue(Files.isDirectory(base)); }
@Test public void testEnsureDirectoryExistsWithError() { Path impossible = existingFile.resolve("file"); assertThrows(VocabHunterException.class, () -> FileTool.ensureDirectoryExists(impossible, ERROR_TEMPLATE)); }
@Test public void testEnsureDirectoryExistsWithoutBase() { Path file = Paths.get("file"); FileTool.ensureDirectoryExists(file, ERROR_TEMPLATE); }