@Test public void testCreateFileVisitorTestModeIsActionTestMode() { final DeleteAction delete = createAnyFilter("any", true, 0, false); assertFalse(delete.isTestMode()); final FileVisitor<Path> visitor = delete.createFileVisitor(delete.getBasePath(), delete.getPathConditions()); assertTrue(visitor instanceof DeletingVisitor); assertFalse(((DeletingVisitor) visitor).isTestMode()); final DeleteAction deleteTestMode = createAnyFilter("any", true, 0, true); assertTrue(deleteTestMode.isTestMode()); final FileVisitor<Path> testVisitor = deleteTestMode.createFileVisitor(delete.getBasePath(), delete.getPathConditions()); assertTrue(testVisitor instanceof DeletingVisitor); assertTrue(((DeletingVisitor) testVisitor).isTestMode()); } }
private void deleteSelectedFiles(final List<PathWithAttributes> selectedForDeletion) throws IOException { trace("Paths the script selected for deletion:", selectedForDeletion); for (final PathWithAttributes pathWithAttributes : selectedForDeletion) { final Path path = pathWithAttributes == null ? null : pathWithAttributes.getPath(); if (isTestMode()) { LOGGER.info("Deleting {} (TEST MODE: file not actually deleted)", path); } else { delete(path); } } }