@Override
  protected WritableByteChannel create(LocalResourceId resourceId, CreateOptions createOptions)
      throws IOException {
    LOG.debug("creating file {}", resourceId);
    File absoluteFile = resourceId.getPath().toFile().getAbsoluteFile();
    if (absoluteFile.getParentFile() != null
        && !absoluteFile.getParentFile().exists()
        && !absoluteFile.getParentFile().mkdirs()
        && !absoluteFile.getParentFile().exists()) {
      throw new IOException("Unable to create parent directories for '" + resourceId + "'");
    }
    return Channels.newChannel(new BufferedOutputStream(new FileOutputStream(absoluteFile)));
  }
@Test
  public void testCreateFilesException() throws Exception {
    File mockParentFile = mock(File.class);
    when(mockParentFile.mkdirs()).thenThrow(new RuntimeException("exception when creating files"));

    File mockAbsoluteFile = mock(File.class);
    when(mockAbsoluteFile.getParentFile()).thenReturn(mockParentFile);

    File mockFile = mock(File.class);
    when(mockFile.getAbsoluteFile()).thenReturn(mockAbsoluteFile);

    Path mockPath = mock(Path.class);
    when(mockPath.toFile()).thenReturn(mockFile);

    LocalResourceId mockResourceId = mock(LocalResourceId.class);
    when(mockResourceId.getPath()).thenReturn(mockPath);

    thrown.expect(RuntimeException.class);

    localFileSystem.create(
        mockResourceId, StandardCreateOptions.builder().setMimeType(MimeTypes.TEXT).build());
  }