From 048cb4c9964e688b1b6316f15b5c4db22187a930 Mon Sep 17 00:00:00 2001 From: Lukasz Jarocki Date: Thu, 5 May 2022 15:40:20 +0200 Subject: [PATCH] NO-JIRA fixing faulty test in ScoreMatricDumperImplTest --- .../filemove/ScoreMatrixDumperImplTest.java | 22 +++++++++++++------ 1 file 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 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; } } -- 2.39.5