RouteUtils { public static String expand(String template, Object... variables) { if (variables.length == 0) { return template; } StringBuffer buf = new StringBuffer(); Matcher matcher = PARAMETER_PATTERN.matcher(template); int index = 0; while (matcher.find()) { matcher.appendReplacement(buf, encodeUriPathSegment(variables[index++].toString())); } matcher.appendTail(buf); return buf.toString(); } private  RouteUtils(); static String expand(String template, Object... variables); @Experimental static Map<String, String> createVariableMap(String template, Object... variables); static String expandQuery(String uri, @Nullable Multimap<String, Object> values); @Nullable static String getMajorParam(String template, String complete);  }
@Test public void testUriWithoutTemplateVariable() { String template = "/gateway"; assertEquals(template, RouteUtils.expand(template)); }
@Test public void testUriWithOneVariable() { String template = "/channel/{channel.id}"; String expected = "/channel/123456789"; assertEquals(expected, RouteUtils.expand(template, 123456789)); }
@Test public void testUriWithTwoVariables() { String template = "/channels/{channel.id}/messages/{message.id}"; String expected = "/channels/123456789/messages/987654321"; assertEquals(expected, RouteUtils.expand(template, 123456789, 987654321)); }