@Test
public void testPutProject() throws Exception {

  final File file = new File(
      getClass().getClassLoader().getResource("sample_flow_01.zip").getFile());
  final String hash = new String(Hex.encodeHex(HashUtils.MD5.getHashBytes(file)));
  // This requires far too much information about the internals for FileContext.create()
  // to make the test succeed. That unfortunately seems to be the price of using a mocking
  // framework. It's worth considering a custom implementation of FileContext for this.
  FSDataOutputStream nullOutputStream = new FSDataOutputStream(new NullOutputStream());
  when(this.hdfsFileContext.create(any(Path.class), any(EnumSet.class)))
      .thenReturn(nullOutputStream);
  final ProjectStorageMetadata metadata = new ProjectStorageMetadata(1, 2,
      "uploader", HashUtils.MD5.getHashBytes(file), IPv4);
  final String key = this.hdfsStorage.putProject(metadata, file);
  final String expectedName = String.format("1/1-%s.zip", hash);
  Assert.assertEquals(expectedName, key);
  final String expectedPath = "/path/to/prj/" + expectedName;
  verify(this.hdfsFileContext).create(any(Path.class), eq(EnumSet.of(CreateFlag.CREATE,
      CreateFlag.OVERWRITE)));
  verify(this.hdfsFileContext)
      .rename(any(Path.class), eq(new Path(expectedPath)), eq(Options.Rename.OVERWRITE));
}