From: Lukasz Jarocki Date: Thu, 5 May 2022 13:40:20 +0000 (+0200) Subject: NO-JIRA fixing faulty test in ScoreMatricDumperImplTest X-Git-Tag: 9.5.0.56709~176 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=048cb4c9964e688b1b6316f15b5c4db22187a930;p=sonarqube.git NO-JIRA fixing faulty test in ScoreMatricDumperImplTest --- 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 listDumpFilesForTaskUuid(String taskUuid) { - return FileUtils.listFiles(tempDir.toFile(), new AbstractFileFilter() { - @Override - public boolean accept(File file) { + Collection 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; } }