@Test
public void testGetTemplateParameters() {
MultivaluedMap<String, String> values = new MetadataMap<String, String>();
new URITemplate("/bar").match("/baz", values);
UriInfoImpl u = new UriInfoImpl(mockMessage("http://localhost:8080/baz", "/bar"),
values);
assertEquals("unexpected templates", 0, u.getPathParameters().size());
values.clear();
new URITemplate("/{id}").match("/bar%201", values);
u = new UriInfoImpl(mockMessage("http://localhost:8080/baz", "/bar%201"),
values);
MultivaluedMap<String, String> tps = u.getPathParameters(false);
assertEquals("Number of templates is wrong", 1, tps.size());
assertEquals("Wrong template value", tps.getFirst("id"), "bar%201");
values.clear();
new URITemplate("/{id}/{baz}").match("/1%202/bar", values);
u = new UriInfoImpl(mockMessage("http://localhost:8080/baz", "/1%202/bar"),
values);
tps = u.getPathParameters();
assertEquals("Number of templates is wrong", 2, tps.size());
assertEquals("Wrong template value", tps.getFirst("id"), "1 2");
assertEquals("Wrong template value", tps.getFirst("baz"), "bar");
// with suffix
values.clear();
new URITemplate("/bar").match("/bar", values);
u = new UriInfoImpl(mockMessage("http://localhost:8080/baz", "/bar"),
values);
assertEquals("unexpected templates", 0, u.getPathParameters().size());
}