### Question:
GroupKey { static void urlEncode(String str, StringBuilder sb) { for (int idx = 0; idx < str.length(); ++idx) { char c = str.charAt(idx); if ('+' == c) { sb.append("%2B"); } else if ('%' == c) { sb.append("%25"); } else { sb.append(c); } } }  static String getKey(String dataId, String group); static String getKeyTenant(String dataId, String group, String tenant); static String getKey(String dataId, String group, String datumStr); static String[] parseKey(String groupKey);  }### Answer:
@Test public void urlEncode_Plus() { final StringBuilder sb = new StringBuilder("????"); GroupKey.urlEncode("+", sb); Assert.assertNotNull(sb); Assert.assertEquals("????%2B", sb.toString()); }
@Test public void urlEncode_Percent() { final StringBuilder sb = new StringBuilder("??????"); GroupKey.urlEncode("%", sb); Assert.assertNotNull(sb); Assert.assertEquals("??????%25", sb.toString()); }
@Test public void urlEncode_NullStringBuilder() { thrown.expect(NullPointerException.class); GroupKey.urlEncode("+", null); }