Skip to content

Commit

Permalink
Deprecate getOutput() to switch to more configurable getLines
Browse files Browse the repository at this point in the history
  • Loading branch information
MaisiKoleni committed Nov 5, 2020
1 parent f735fa8 commit 319f3cd
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/java/de/tum/in/test/api/io/OutputTester.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,22 @@ public void resetOutput() {
actualOutput.clear();
}

/**
* Returns the output as list of lines, always including all lines.
*
* @return all actual output as {@link Line}s.
* @deprecated Use {@link #getLines(OutputTestOptions...)} instead, which allows
* to specify options.
*/
@Deprecated(since = "1.3.2")
public List<Line> getOutput() {
return Collections.unmodifiableList(actualOutput);
}

public List<Line> getLines(OutputTestOptions... outputOptions) {
return Collections.unmodifiableList(processLines(outputOptions));
}

public String getOutputAsString(OutputTestOptions... outputOptions) {
return processLines(outputOptions).stream().map(Line::text)
.collect(Collectors.joining(IOTester.LINE_SEPERATOR));
Expand Down Expand Up @@ -288,7 +300,7 @@ private static boolean isRegExLine(String expectedLine) {

private List<Line> processLines(OutputTestOptions... outputOptions) {
boolean ignoreLastEmpty = !OutputTestOptions.DONT_IGNORE_LAST_EMPTY_LINE.isIn(outputOptions);
if (ignoreLastEmpty && actualOutput.size() > 0 && actualOutput.get(actualOutput.size() - 1).text().isEmpty())
if (ignoreLastEmpty && !actualOutput.isEmpty() && actualOutput.get(actualOutput.size() - 1).text().isEmpty())
return actualOutput.subList(0, actualOutput.size() - 1);
return actualOutput;
}
Expand Down

0 comments on commit 319f3cd

Please sign in to comment.