@Test
  public void usePatternMatchingForRegexParameters() throws Exception {
    builder = newBuilder("/abc/{abc:a+b+c+}/def/{def}/ghi/{ghi}");

    builder.is(MyResource.class, method.getMethod());
    Route route = builder.build();

    assertFalse("invalid uri", route.canHandle("/abc/itIsInvalid/def/123/ghi/123.45"));
    assertTrue("valid uri", route.canHandle("/abc/aaabbccccc/def/-123/ghi/-1"));
  }
  @Test
  public void usingRegexesWithCurlyBracesNotOnTheEndAndOtherVar() throws Exception {
    builder = newBuilder("/abc/{abc:[0-9A-Z]{5}}/def/{def}");

    builder.is(MyResource.class, method.getMethod());
    Route route = builder.build();

    assertFalse("invalid uri", route.canHandle("/abc/notValid/def/12"));
    assertFalse("invalid uri", route.canHandle("/abc/ABC123/def/12"));
    assertTrue("valid uri", route.canHandle("/abc/10AB3/def/12"));
  }
  @Test
  public void usingRegexesWithAsterisksAtTheEnd() throws Exception {
    builder = newBuilder("/abc/{abc:[0-9A-Z]*}/def/{def}");

    builder.is(MyResource.class, method.getMethod());
    Route route = builder.build();

    assertFalse("invalid uri", route.canHandle("/abc/not_Valid/def/12"));
    assertTrue("valid uri", route.canHandle("/abc/ABC123/def/12"));
    assertTrue("valid uri", route.canHandle("/abc/10AB3/def/12"));
  }
  @Test
  public void usePatternMatchinForPrimitiveParameters() throws Exception {
    builder = newBuilder("/abc/{abc}/def/{def}/ghi/{ghi}");

    builder.is(MyResource.class, method.getMethod());
    Route route = builder.build();

    assertTrue("valid uri", route.canHandle("/abc/AnythingHere/def/123/ghi/123.45"));
    assertTrue("valid uri", route.canHandle("/abc/AnythingHere/def/-123/ghi/-1"));
    assertTrue(
        "valid uri with integer decimal", route.canHandle("/abc/AnythingHere/def/123/ghi/123"));
    assertFalse("invalid integer", route.canHandle("/abc/AnythingHere/def/Duh/ghi/123"));
    assertFalse("invalid decimal", route.canHandle("/abc/AnythingHere/def/123/ghi/kkk"));
  }
  @Override
  public Object[] deserialize(InputStream inputStream, ControllerMethod method) {
    Method javaMethod = method.getMethod();
    Class<?>[] types = javaMethod.getParameterTypes();
    if (types.length == 0) {
      throw new IllegalArgumentException(
          "Methods that consumes xml must receive just one argument: the xml root element");
    }
    XStream xStream = getConfiguredXStream(javaMethod, types);

    Object[] params = new Object[types.length];

    chooseParam(types, params, xStream.fromXML(inputStream));

    return params;
  }