aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukasz Jarocki <lukasz.jarocki@sonarsource.com>2022-05-05 15:40:20 +0200
committersonartech <sonartech@sonarsource.com>2022-05-05 20:02:57 +0000
commit048cb4c9964e688b1b6316f15b5c4db22187a930 (patch)
tree51ef2f440fe02d8126a5262719853b2a10c04c81
parent725e0a5de61978d9452f1cf4779e93239452e8af (diff)
downloadsonarqube-048cb4c9964e688b1b6316f15b5c4db22187a930.tar.gz
sonarqube-048cb4c9964e688b1b6316f15b5c4db22187a930.zip
NO-JIRA fixing faulty test in ScoreMatricDumperImplTest
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/ScoreMatrixDumperImplTest.java22
1 files changed, 15 insertions, 7 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/ScoreMatrixDumperImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/ScoreMatrixDumperImplTest.java
index 5c9e2d851bb..a5d3be08755 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/ScoreMatrixDumperImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/filemove/ScoreMatrixDumperImplTest.java
@@ -26,9 +26,8 @@ import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.util.ArrayList;
import java.util.Collection;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.filefilter.AbstractFileFilter;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -122,12 +121,21 @@ public class ScoreMatrixDumperImplTest {
}
private Collection<File> listDumpFilesForTaskUuid(String taskUuid) {
- return FileUtils.listFiles(tempDir.toFile(), new AbstractFileFilter() {
- @Override
- public boolean accept(File file) {
+ Collection<File> dumpFiles = new ArrayList<>();
+ File dir = tempDir.toFile();
+ File[] files = dir.listFiles();
+ if (!dir.exists() || files == null) {
+ throw new IllegalStateException("Temp directory does not exist");
+ }
+ for (File file : files) {
+ if (file.exists()) {
String name = file.getName();
- return name.startsWith("score-matrix-" + taskUuid) && name.endsWith(".csv");
+ if (name.startsWith("score-matrix-" + taskUuid) && name.endsWith(".csv")) {
+ dumpFiles.add(file);
+ }
}
- }, null);
+ }
+
+ return dumpFiles;
}
}