### Question:
ContentFileCommitRollbackService { public void commit(ContentFileTransactionContext context) throws IOException { Preconditions.checkNotNull(context); File deletedTmpDirectory = context.getDeletedTmpDirectory(); FileUtils.deleteDirectory(deletedTmpDirectory); }  void commit(ContentFileTransactionContext context); void rollback(ContentFileTransactionContext context);  }### Answer:
@Test(expected = NullPointerException.class) public void commit_NULL_CONTEXT() throws IOException { contentFileCommitRollbackService.commit(null); }
@Test public void commit_ADDED_FILES() throws IOException { ContentFileTransactionContext context = new ContentFileTransactionContext(contentDir, deletedTmpDir); context.addAddedFile("file1.txt"); context.addAddedFile("file2.txt"); File file1 = createFile(contentDir, "file1.txt", "content1"); File file2 = createFile(contentDir, "file2.txt", "content2"); contentFileCommitRollbackService.commit(context); assertFile(file1, "content1"); assertFile(file2, "content2"); assertFalse(deletedTmpDir.exists()); }
@Test public void commit_DELETED_FILES() throws IOException { ContentFileTransactionContext context = new ContentFileTransactionContext(contentDir, deletedTmpDir); File file1 = createFile(deletedTmpDir, "file1.txt", "content1"); File file2 = createFile(deletedTmpDir, "file2.txt", "content2"); contentFileCommitRollbackService.commit(context); assertFalse(file1.exists()); assertFalse(file2.exists()); assertFalse(deletedTmpDir.exists()); }