### Question:
ContentFileCommitRollbackService { public void rollback(ContentFileTransactionContext context) throws IOException { Preconditions.checkNotNull(context); File contentDirectory = context.getContentDirectory(); File deletedTmpDirectory = context.getDeletedTmpDirectory(); while(!context.containsAnyAddedFile()) { String addedFilePath = context.pollAddedFile(); File addedFile = new File(contentDirectory, addedFilePath); addedFile.delete(); } FileUtils.copyDirectory(deletedTmpDirectory, contentDirectory); FileUtils.deleteDirectory(deletedTmpDirectory); }  void commit(ContentFileTransactionContext context); void rollback(ContentFileTransactionContext context);  }### Answer:
@Test(expected = NullPointerException.class) public void rollback_NULL_CONTEXT() throws IOException { contentFileCommitRollbackService.rollback(null); }
@Test public void rollback_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"); file1.createNewFile(); file2.createNewFile(); contentFileCommitRollbackService.rollback(context); assertFalse(file1.exists()); assertFalse(file2.exists()); assertFalse(deletedTmpDir.exists()); }
@Test public void rollback_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.rollback(context); assertFile(new File(contentDir, "file1.txt"), "content1"); assertFile(new File(contentDir, "file2.txt"), "content2"); assertFalse(file1.exists()); assertFalse(file2.exists()); assertFalse(deletedTmpDir.exists()); }