diff --git a/core/src/test/java/org/jsmart/zerocode/core/utils/TokenUtilsTest.java b/core/src/test/java/org/jsmart/zerocode/core/utils/TokenUtilsTest.java index 9566c4dc..6c01ac6c 100644 --- a/core/src/test/java/org/jsmart/zerocode/core/utils/TokenUtilsTest.java +++ b/core/src/test/java/org/jsmart/zerocode/core/utils/TokenUtilsTest.java @@ -10,6 +10,8 @@ import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.is; import static org.jsmart.zerocode.core.utils.TokenUtils.absolutePathOf; +import static org.jsmart.zerocode.core.utils.TokenUtils.getMaskedTokensReplaced; +import static org.jsmart.zerocode.core.utils.TokenUtils.getMasksRemoved; import static org.jsmart.zerocode.core.utils.TokenUtils.resolveKnownTokens; import static org.junit.Assert.*; @@ -169,4 +171,48 @@ public void testAbsolutePathOf() { assertThat(absolutePathOf("unit_test_files/jks_files/dummy_key_store.jks"), containsString("zerocode/core/target/test-classes/unit_test_files/jks_files/dummy_key_store.jks")); } + + + @Test + public void testGetMaskedTokensReplaced_multipleOccurrences(){ + assertEquals("This is a ***masked*** message with ***masked*** tokens.", getMaskedTokensReplaced("This is a ${MASKED:secret} message with ${MASKED:masked} tokens.")); + } + + @Test + public void testGetMaskedTokensReplaced_noOccurrences(){ + assertEquals("This string has no masked tokens.", getMaskedTokensReplaced("This string has no masked tokens.")); + } + + @Test + public void testGetMaskedTokensReplaced_emptyString(){ + assertEquals("", getMaskedTokensReplaced("")); + } + + @Test + public void testGetMaskedTokensReplaced_specialCharacters(){ + assertEquals("***masked*** and ***masked***", getMaskedTokensReplaced("${MASKED:abc@123} and ${MASKED:!@#$%^}")); + } + + @Test + public void testGetMaskedTokensRemoved_multipleOccurrences(){ + assertEquals("This is a secret message with masked tokens.", getMasksRemoved("This is a ${MASKED:secret} message with ${MASKED:masked} tokens.")); + } + + @Test + public void testGetMaskedTokensRemoved_noOccurrences(){ + assertEquals("This string has no masked tokens.", getMasksRemoved("This string has no masked tokens.")); + } + + @Test + public void testGetMaskedTokensRemoved_emptyString(){ + assertEquals("", getMasksRemoved("")); + } + + @Test + public void testGetMaskedTokensRemoved_specialCharacters(){ + assertEquals("abc@123 and !@#$%^", getMasksRemoved("${MASKED:abc@123} and ${MASKED:!@#$%^}")); + } + + + } \ No newline at end of file