@Override
  public RestLiRequestData extractRequestData(RoutingResult routingResult, DataMap data)
  {
    ResourceMethodDescriptor resourceMethodDescriptor = routingResult.getResourceMethod();
    if (data == null)
    {
      data = new DataMap();
    }
    DynamicRecordTemplate template = new DynamicRecordTemplate(data, resourceMethodDescriptor.getRequestDataSchema());
    ValidationResult result =
        ValidateDataAgainstSchema.validate(data, template.schema(), getValidationOptions());
    if (!result.isValid())
    {
      throw new RoutingException("Parameters of method '" + resourceMethodDescriptor.getActionName()
          + "' failed validation with error '" + result.getMessages() + "'", HttpStatus.S_400_BAD_REQUEST.getCode());
    }
    return new RestLiRequestDataImpl.Builder().entity(template).build();
  }
@Test(dataProvider = "failureData")
  public void testExtractRequestDataFailure(String entity, List<Parameter<?>> params, String errorRegEx)
      throws IOException
  {
    RecordDataSchema dataSchema = DynamicRecordMetadata.buildSchema("testAction", params);
    RestRequest request = RestLiArgumentBuilderTestHelper.getMockRequest(false, entity);
    ResourceMethodDescriptor descriptor = RestLiArgumentBuilderTestHelper.getMockResourceMethodDescriptor(null, null, "testAction", dataSchema);
    RoutingResult routingResult = RestLiArgumentBuilderTestHelper.getMockRoutingResult(descriptor, 1, null, 1);

    RestLiArgumentBuilder argumentBuilder = new ActionArgumentBuilder();
    try
    {
      argumentBuilder.extractRequestData(routingResult, DataMapUtils.readMapWithExceptions(request));
      fail("Expected RoutingException");
    }
    catch (RoutingException e)
    {
      assertTrue(e.getMessage().matches(errorRegEx));
    }

    verify(request, descriptor, routingResult);
  }