Skip to content

Commit cb087f8

Browse files
committed
clean
Signed-off-by: David BRAQUART <[email protected]>
1 parent 24f76a3 commit cb087f8

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/main/java/org/gridsuite/securityanalysis/server/dto/PreContingencyLimitViolationResultDTO.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
import lombok.experimental.FieldNameConstants;
1515
import org.gridsuite.securityanalysis.server.entities.PreContingencyLimitViolationEntity;
1616

17-
import java.util.ArrayList;
1817
import java.util.List;
1918
import java.util.Map;
19+
import java.util.stream.Stream;
2020

2121
@Getter
2222
@AllArgsConstructor
@@ -41,12 +41,13 @@ public static PreContingencyLimitViolationResultDTO toDto(PreContingencyLimitVio
4141
}
4242

4343
public List<String> toCsvRow(Map<String, String> translations, String language) {
44-
if (this.getLimitViolation() == null) {
45-
return List.of();
44+
List<String> csvRow = List.of();
45+
46+
if (this.getLimitViolation() != null) {
47+
csvRow = List.of(this.getSubjectId());
48+
return Stream.concat(csvRow.stream(), this.getLimitViolation().toCsvRow(translations, language).stream()).toList();
4649
}
47-
List<String> csvRow = new ArrayList<>();
48-
csvRow.add(this.getSubjectId());
49-
csvRow.addAll(this.getLimitViolation().toCsvRow(translations, language));
50+
5051
return csvRow;
5152
}
5253
}

src/test/java/org/gridsuite/securityanalysis/server/util/TestUtils.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,11 @@ public static List<String> readLinesFromFilePath(String resourceFileName, int nb
7777
InputStream inputStream = Files.newInputStream(resourceFilePath);
7878
try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) {
7979
String line;
80-
int lineCount = 0;
81-
while ((line = br.readLine()) != null && (nbLines == -1 || lineCount < nbLines)) {
82-
if (lineCount == 0 && line.startsWith(utf8Bom)) {
80+
while ((line = br.readLine()) != null && (nbLines == -1 || lines.size() < nbLines)) {
81+
if (lines.isEmpty() && line.startsWith(utf8Bom)) {
8382
line = line.substring(utf8Bom.length()); // skip BOM
8483
}
8584
lines.add(line);
86-
lineCount++;
8785
}
8886
}
8987
} catch (IOException ex) {

0 commit comments

Comments
 (0)