aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDejan Milisavljevic <130993898+dejan-milisavljevic-sonarsource@users.noreply.github.com>2024-02-23 17:18:02 +0100
committersonartech <sonartech@sonarsource.com>2024-02-23 20:02:36 +0000
commite2e4ca5594431f7ed596d7da93dfc21656c02ddb (patch)
tree585e2577ba7d81436e1f0ea84d5abef7df30c19c
parentc2a76e27e6c123494613bdd4f563a04fdb3cd8be (diff)
downloadsonarqube-e2e4ca5594431f7ed596d7da93dfc21656c02ddb.tar.gz
sonarqube-e2e4ca5594431f7ed596d7da93dfc21656c02ddb.zip
SONAR-21643 Fix IT CompositeBlameCommandIT (#10709)
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scm/git/CompositeBlameCommandIT.java44
1 files changed, 23 insertions, 21 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/CompositeBlameCommandIT.java b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/CompositeBlameCommandIT.java
index c14c2f6b78e..d1332243431 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/CompositeBlameCommandIT.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/CompositeBlameCommandIT.java
@@ -125,28 +125,30 @@ class CompositeBlameCommandIT {
Path expectedBlameFiles = new File(Utils.class.getResource("expected-blame/" + expectedBlameFolder).toURI()).toPath();
Map<Path, List<BlameLine>> expectedBlame = new HashMap<>();
- List<Path> filesInExpectedBlameFolder = Files.walk(expectedBlameFiles).filter(Files::isRegularFile).toList();
- for (Path expectedFileBlamePath : filesInExpectedBlameFolder) {
- List<BlameLine> blameLines = new ArrayList<>();
- List<String> expectedBlameStrings = Files.readAllLines(expectedFileBlamePath);
- for (String line : expectedBlameStrings) {
- String revision = line.substring(0, 40);
-
- int beginningEmail = line.indexOf("<") + 1, endEmail = line.indexOf(">");
- String email = line.substring(beginningEmail, endEmail);
-
- int beginningDate = line.indexOf("2", endEmail), dateLength = 25;
- String sDate = line.substring(beginningDate, beginningDate + dateLength);
- Date parsedDate = new Date(OffsetDateTime.parse(sDate).toInstant().toEpochMilli());
-
- BlameLine blameLine = new BlameLine()
- .revision(revision)
- .author(email)
- .date(parsedDate);
-
- blameLines.add(blameLine);
+ try (Stream<Path> files = Files.walk(expectedBlameFiles)) {
+ List<Path> filesInExpectedBlameFolder = files.filter(Files::isRegularFile).toList();
+ for (Path expectedFileBlamePath : filesInExpectedBlameFolder) {
+ List<BlameLine> blameLines = new ArrayList<>();
+ List<String> expectedBlameStrings = Files.readAllLines(expectedFileBlamePath);
+ for (String line : expectedBlameStrings) {
+ String revision = line.substring(0, 40);
+
+ int beginningEmail = line.indexOf("<") + 1, endEmail = line.indexOf(">");
+ String email = line.substring(beginningEmail, endEmail);
+
+ int beginningDate = line.indexOf("2", endEmail), dateLength = 25;
+ String sDate = line.substring(beginningDate, beginningDate + dateLength);
+ Date parsedDate = new Date(OffsetDateTime.parse(sDate).toInstant().toEpochMilli());
+
+ BlameLine blameLine = new BlameLine()
+ .revision(revision)
+ .author(email)
+ .date(parsedDate);
+
+ blameLines.add(blameLine);
+ }
+ expectedBlame.put(expectedBlameFiles.relativize(expectedFileBlamePath), blameLines);
}
- expectedBlame.put(expectedBlameFiles.relativize(expectedFileBlamePath), blameLines);
}
return expectedBlame;
}