Use Guava's Escaper for percent-encoding
[netconf.git] / restconf / restconf-nb / src / test / java / org / opendaylight / restconf / nb / rfc8040 / utils / parser / YangInstanceIdentifierSerializerTest.java
index 10b9a564efbf309e615326283194ea72a4e4cfbc..13ab3d9b97c29e5573673da8f1d2797cafef98c4 100644 (file)
@@ -251,17 +251,21 @@ public class YangInstanceIdentifierSerializerTest {
         final char[] genDelims = { ':', '/', '?', '#', '[', ']', '@' };
         final char[] subDelims = { '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=' };
 
-        for (final char c : genDelims) {
-            assertTrue("Current character is reserved and should be percent encoded",
-                    YangInstanceIdentifierSerializer.PERCENT_ENCODE_CHARS.matches(c));
+        for (final char ch : genDelims) {
+            assertPercentEncoded(ch);
         }
 
-        for (final char c : subDelims) {
-            assertTrue("Current character is reserved and should be percent encoded",
-                    YangInstanceIdentifierSerializer.PERCENT_ENCODE_CHARS.matches(c));
+        for (final char ch : subDelims) {
+            assertPercentEncoded(ch);
         }
     }
 
+    private static void assertPercentEncoded(final char ch) {
+        final var str = YangInstanceIdentifierSerializer.PERCENT_ESCAPER.escape(String.valueOf(ch));
+        assertEquals(3, str.length());
+        assertEquals('%', str.charAt(0));
+    }
+
     /**
      * Test if URIs with percent encoded characters are all correctly serialized.
      */