mirror of https://github.com/apache/nifi.git
Added more test for escape and unescape functions
Signed-off-by: Matt Burgess <mattyb149@apache.org>
This commit is contained in:
parent
8f74241a10
commit
219e0e96fb
|
@ -1320,8 +1320,40 @@ public class TestQuery {
|
|||
|
||||
attributes.put("string", "making air \"QUOTES\".");
|
||||
verifyEquals("${string:escapeJson()}", attributes, "making air \\\"QUOTES\\\".");
|
||||
|
||||
attributes.put("string", "M & M");
|
||||
verifyEquals("${string:escapeXml()}", attributes, "M & M");
|
||||
|
||||
attributes.put("string", "making air \"QUOTES\".");
|
||||
verifyEquals("${string:escapeCsv()}", attributes, "\"making air \"\"QUOTES\"\".\"");
|
||||
|
||||
attributes.put("string", "special ¡");
|
||||
verifyEquals("${string:escapeHtml3()}", attributes, "special ¡");
|
||||
|
||||
attributes.put("string", "special ♣");
|
||||
verifyEquals("${string:escapeHtml4()}", attributes, "special ♣");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnescapeFunctions() {
|
||||
final Map<String, String> attributes = new HashMap<>();
|
||||
|
||||
attributes.put("string", "making air \\\"QUOTES\\\".");
|
||||
verifyEquals("${string:unescapeJson()}", attributes, "making air \"QUOTES\".");
|
||||
|
||||
attributes.put("string", "M & M");
|
||||
verifyEquals("${string:unescapeXml()}", attributes, "M & M");
|
||||
|
||||
attributes.put("string", "\"making air \"\"QUOTES\"\".\"");
|
||||
verifyEquals("${string:unescapeCsv()}", attributes, "making air \"QUOTES\".");
|
||||
|
||||
attributes.put("string", "special ¡");
|
||||
verifyEquals("${string:unescapeHtml3()}", attributes, "special ¡");
|
||||
|
||||
attributes.put("string", "special ♣");
|
||||
verifyEquals("${string:unescapeHtml4()}", attributes, "special ♣");
|
||||
}
|
||||
|
||||
private void verifyEquals(final String expression, final Map<String, String> attributes, final Object expectedResult) {
|
||||
Query.validateExpression(expression, false);
|
||||
assertEquals(String.valueOf(expectedResult), Query.evaluateExpressions(expression, attributes, null));
|
||||
|
|
Loading…
Reference in New Issue