FINERACT-2081: Added some tests for LogParameterEscapeUtil
This commit is contained in:
committed by
Adam Saghy
parent
17d1aa580d
commit
53c2cabf01
+18
-1
@@ -25,17 +25,29 @@ import io.cucumber.java8.En;
|
||||
public class LogParameterEscapeUtilTest implements En {
|
||||
|
||||
private String logParameter;
|
||||
|
||||
private String escapedLogParameter;
|
||||
|
||||
public LogParameterEscapeUtilTest() {
|
||||
Given("A simple log message without any special character", () -> {
|
||||
logParameter = "This is a very simple String without any special character.";
|
||||
});
|
||||
|
||||
Given("A log message with new line, carriage return and tab characters", () -> {
|
||||
logParameter = "This String contains new line\n, carriage return\r and tab\t characters.";
|
||||
});
|
||||
|
||||
Given("A null log message", () -> {
|
||||
logParameter = null;
|
||||
});
|
||||
|
||||
Given("An empty log message", () -> {
|
||||
logParameter = "";
|
||||
});
|
||||
|
||||
Given("A log message with special characters {string}", (String input) -> {
|
||||
logParameter = input;
|
||||
});
|
||||
|
||||
When("Log parameter escape util escaping the special characters", () -> {
|
||||
escapedLogParameter = LogParameterEscapeUtil.escapeLogParameter(logParameter);
|
||||
});
|
||||
@@ -43,9 +55,14 @@ public class LogParameterEscapeUtilTest implements En {
|
||||
Then("The log message stays as it is", () -> {
|
||||
assertEquals(logParameter, escapedLogParameter);
|
||||
});
|
||||
|
||||
Then("The escape util changes the special characters to `_`", () -> {
|
||||
assertEquals("This String contains new line_, carriage return_ and tab_ characters.", escapedLogParameter);
|
||||
});
|
||||
|
||||
Then("The log message is escaped to {string}", (String expected) -> {
|
||||
assertEquals(expected, escapedLogParameter);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user