FINERACT-2081: Added some tests for LogParameterEscapeUtil

This commit is contained in:
a7med3del1973
2025-02-27 10:31:56 +01:00
committed by Adam Saghy
parent 17d1aa580d
commit 53c2cabf01
@@ -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);
});
}
}