@SmallTest public void testMatchDuplicate() throws Exception { UriTemplate template = new UriTemplate("/order/{c}/{c}/{c}"); Map<String, String> result = template.match("/order/cheeseburger/cheeseburger/cheeseburger"); Map<String, String> expected = Collections.singletonMap("c", "cheeseburger"); assertEquals("Invalid match", expected, result); }
@SmallTest public void testMatchMultipleInOneSegment() throws Exception { UriTemplate template = new UriTemplate("/{foo}-{bar}"); Map<String, String> result = template.match("/12-34"); Map<String, String> expected = new HashMap<String, String>(2); expected.put("foo", "12"); expected.put("bar", "34"); assertEquals("Invalid match", expected, result); }
@SmallTest public void testMatch() throws Exception { Map<String, String> expected = new HashMap<String, String>(2); expected.put("booking", "42"); expected.put("hotel", "1"); UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}"); Map<String, String> result = template.match("http://example.com/hotels/1/bookings/42"); assertEquals("Invalid match", expected, result); }