### Question:
JsonPointerUtil { public static String encode(String s) { if (s == null || s.isEmpty()) { return s; } return replace(replace(s, "~", "~0"), "/", "~1"); } private  JsonPointerUtil(); static String encode(String s); static String decode(String s);  }### Answer:
@Test public void testEncodeNull() { assertNull(JsonPointerUtil.encode(null)); }
@Test public void testEncodeEmptyString() { String encodedString = JsonPointerUtil.encode(""); assertEquals("", encodedString); }
@Test public void testEncodeNoTransformation() { String encodedString = JsonPointerUtil.encode("TestString"); assertEquals("TestString", encodedString); }
@Test public void testEncodeFirstTransformation() { String encodedString = JsonPointerUtil.encode("~"); assertEquals("~0", encodedString); }
@Test public void testEncodeSecondTransformation() { String encodedString = JsonPointerUtil.encode("/"); assertEquals("~1", encodedString); }
@Test public void testEncodeWholeTransformation() { String decodedString = JsonPointerUtil.encode("~/"); assertEquals("~0~1", decodedString); }