### Question:
DeleteOp { public void execute() throws IOException { try { prepare(); boolean commitResult = commit(); if (commitResult == false) { throw PatchLogger.ROOT_LOGGER.failedToDeleteBackup(); } } catch (PrepareException pe){ rollback(); throw PatchLogger.ROOT_LOGGER.failedToDelete(pe.getPath()); } } DeleteOp(File toDelete, FilenameFilter fileFilter); void execute(); static void execute(Collection<DeleteOp> deleteOps); static final String BACKUP_FOLDER; }### Answer:
@Test public void executeTwoDeleteOpsWithSameBackupDir() throws Exception { final File dir1 = createDir("dir1", createFile("dir1/test.txt", NOT_PROTECTED)); final File dir2 = createDir("dir2", createFile("dir2/test.txt", PROTECTED)); final DeleteOp op1 = new DeleteOp(dir1, INCLUDE_ALL); final DeleteOp op2 = new DeleteOp(dir2, INCLUDE_ALL); try { DeleteOp.execute(Arrays.asList(op1, op2)); fail("DeleteOp should throw an exception"); } catch(IOException e) { assertOriginalFileExists("dir1/test.txt"); assertOriginalFileExists("dir2/test.txt"); } }
@Test public void completeSuccesfullyIfAllFilesWereIgnored() throws Exception { final File dir = createDir("dir1"); final DeleteOp op1 = new DeleteOp(dir, (d,f)->false); DeleteOp.execute(Arrays.asList(op1)); assertOriginalFileExists("dir1"); assertBackupFolderWasRemoved(); }