@Test(expected = IllegalArgumentException.class)
public void simpleTemplateWithRegularExpressionsValidation() {

  String template = "https://www.example.com/{foo:[0-9]{4}}/{bar}";
  UriTemplate uriTemplate = UriTemplate.create(template, Util.UTF_8);
  assertThat(uriTemplate.getVariables()).contains("foo", "bar").hasSize(2);
  Map<String, Object> variables = new LinkedHashMap<>();
  variables.put("foo", "abcd");
  variables.put("bar", "stuff");
  /* the foo variable must be a number and no more than four, this should fail */
  uriTemplate.expand(variables);
  fail("Should not be able to expand, pattern does not match");
}