@Test(expected = NullPointerException.class) public void rollback_NULL_CONTEXT() throws IOException { contentFileCommitRollbackService.rollback(null); }
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); }
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); } }
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); }  }
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); }
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);  }