### Question:
ContentFileOperationPerformer { public void overwriteFile(ContentFileTransactionContext context, InputStream inputStream, String path, String oldPath) throws IOException { Preconditions.checkNotNull(context); Preconditions.checkNotNull(inputStream); Preconditions.checkNotNull(path); Preconditions.checkNotNull(oldPath); File contentDirectory = context.getContentDirectory(); File deletedTmpDirectory = context.getDeletedTmpDirectory(); File oldFile = new File(contentDirectory, oldPath); FileUtils.copyFile(oldFile, new File(deletedTmpDirectory, oldPath)); oldFile.delete(); FileUtils.copyInputStreamToFile(inputStream, new File(contentDirectory, path)); context.addAddedFile(path); }  void addFile(ContentFileTransactionContext context, InputStream inputStream, String path); void overwriteFile(ContentFileTransactionContext context, InputStream inputStream, String path, String oldPath);  }### Answer:
@Test(expected = NullPointerException.class) public void overwriteFile_NULL_CONTEXT() throws IOException { contentFileOperationPerformer.overwriteFile(null, is, "file.txt", "oldFile.txt"); }
@Test(expected = NullPointerException.class) public void overwriteFile_NULL_STREAM() throws IOException { contentFileOperationPerformer.overwriteFile(context, null, "file.txt", "oldFile.txt"); }
@Test(expected = NullPointerException.class) public void overwriteFile_NULL_PATH() throws IOException { contentFileOperationPerformer.overwriteFile(context, is, null, "oldFile.txt"); }
@Test(expected = NullPointerException.class) public void overwriteFile_NULL_OLD_PATH() throws IOException { contentFileOperationPerformer.overwriteFile(context, is, "file.txt", null); }
@Test public void overwriteFile() throws IOException { ContentFileTransactionContext context = new ContentFileTransactionContext(contentDir, deletedTmpDir); InputStream is = IOUtils.toInputStream("content of file"); File oldFile = new File(contentDir, "oldFile.txt"); oldFile.createNewFile(); contentFileOperationPerformer.overwriteFile(context, is, "file.txt", "oldFile.txt"); assertFileInContentDirectory("file.txt", "content of file"); assertFileInDeletedTmpDirectory("oldFile.txt", ""); assertEquals(1, context.getAddedFiles().size()); assertEquals("file.txt", context.getAddedFiles().peek()); }