From 50312cdbdfd5d20bb56db6668bb6eda9796aedbb Mon Sep 17 00:00:00 2001 From: baubakg Date: Mon, 13 May 2024 13:15:06 +0200 Subject: [PATCH] Fixed #78 upgraded Commons-io --- pom.xml | 4 ++-- .../tests/logparser/core/LogDataFactory.java | 7 +++++-- .../tests/logparser/core/LogDataTest.java | 15 ++++++++++++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 5db9462..752cb8d 100644 --- a/pom.xml +++ b/pom.xml @@ -345,9 +345,9 @@ test - org.apache.commons + commons-io commons-io - 1.3.2 + 2.16.1 org.apache.commons diff --git a/src/main/java/com/adobe/campaign/tests/logparser/core/LogDataFactory.java b/src/main/java/com/adobe/campaign/tests/logparser/core/LogDataFactory.java index 9e8336d..df834d1 100644 --- a/src/main/java/com/adobe/campaign/tests/logparser/core/LogDataFactory.java +++ b/src/main/java/com/adobe/campaign/tests/logparser/core/LogDataFactory.java @@ -15,6 +15,7 @@ package com.adobe.campaign.tests.logparser.core; import java.io.File; +import java.io.FileFilter; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -253,8 +254,10 @@ public static List findFilePaths(String in_rootDir, String in_fileFilter throw new IllegalArgumentException("The given root path " + in_rootDir + " is not a directory."); } - Iterator l_foundFilesIterator = FileUtils.iterateFiles(l_rootDir, new WildcardFileFilter(in_fileFilter), - TrueFileFilter.INSTANCE); + Iterator l_foundFilesIterator = FileUtils.iterateFiles(l_rootDir,WildcardFileFilter.builder().setWildcards(in_fileFilter).get(), TrueFileFilter.INSTANCE); + + FileFilter fileFilter = WildcardFileFilter.builder().setWildcards(in_fileFilter).get(); + List l_foundFilesList = new ArrayList<>(); l_foundFilesIterator.forEachRemaining(f -> l_foundFilesList.add(f.getAbsolutePath())); log.info("Searching within the {} matching files :", l_foundFilesList.size()); diff --git a/src/test/java/com/adobe/campaign/tests/logparser/core/LogDataTest.java b/src/test/java/com/adobe/campaign/tests/logparser/core/LogDataTest.java index 2871700..a1d1a36 100644 --- a/src/test/java/com/adobe/campaign/tests/logparser/core/LogDataTest.java +++ b/src/test/java/com/adobe/campaign/tests/logparser/core/LogDataTest.java @@ -1278,10 +1278,19 @@ public void testFileSearch_negative2() { } @Test - public void testFileSearch_negative3() { - String l_fileFilter=null; + public void testFileSearch_null() { + String l_fileFilter = null; String l_rootPath = "src/test/resources/nestedDirs"; - Assert.assertThrows(IllegalArgumentException.class, () -> LogDataFactory.findFilePaths(l_rootPath, l_fileFilter)); + assertThat("An empty or null filter should not return enything", + LogDataFactory.findFilePaths(l_rootPath, l_fileFilter), Matchers.empty()); + } + + @Test + public void testFileSearch_empty() { + String l_fileFilter = ""; + String l_rootPath = "src/test/resources/nestedDirs"; + assertThat("An empty or null filter should not return enything", + LogDataFactory.findFilePaths(l_rootPath, l_fileFilter), Matchers.empty()); } @Test