@SuppressWarnings("unchecked")
  @Override
  public RestLiRequestData extractRequestData(RoutingResult routingResult, DataMap dataMap)
  {
    final RestLiRequestDataImpl.Builder builder = new RestLiRequestDataImpl.Builder();
    Set<?> ids = routingResult.getContext().getPathKeys().getBatchIds();
    // No entity for unstructured data requests
    if (UnstructuredDataUtil.isUnstructuredDataRouting(routingResult))
    {
      if (ids != null)
      {
        builder.batchKeys(ids);
      }
      return builder.build();
    }
    else
    {
      checkEntityNotNull(dataMap, ResourceMethod.BATCH_PARTIAL_UPDATE);
      @SuppressWarnings({"rawtypes"})
      Map inputMap = ArgumentBuilder.buildBatchRequestMap(routingResult, dataMap, PatchRequest.class, ids);
      if (inputMap != null)
      {
        builder.batchKeyEntityMap(inputMap);
      }
      return builder.build();
    }
  }
@Test(dataProvider = "failureData")
  public void testFailure(ProtocolVersion version, Key primaryKey, Key[] associationKeys, String requestEntity, Object[] keys, String errorMessage)
      throws Exception
  {
    Set<Object> batchKeys = new HashSet<>(Arrays.asList(keys));
    RestRequest request = RestLiArgumentBuilderTestHelper.getMockRequest(requestEntity, version);
    ResourceModel model = RestLiArgumentBuilderTestHelper.getMockResourceModel(MyComplexKey.class, primaryKey, associationKeys, batchKeys);
    ResourceMethodDescriptor descriptor = RestLiArgumentBuilderTestHelper.getMockResourceMethodDescriptor(
        model, 2,null, CollectionResourceAsyncTemplate.class.getMethod("batchUpdate", BatchPatchRequest.class, Callback.class));
    ServerResourceContext context = RestLiArgumentBuilderTestHelper.getMockResourceContext(batchKeys, version, false, false);
    RoutingResult routingResult = RestLiArgumentBuilderTestHelper.getMockRoutingResult(descriptor, context);

    RestLiArgumentBuilder argumentBuilder = new BatchPatchArgumentBuilder();
    try
    {
      argumentBuilder.extractRequestData(routingResult, DataMapUtils.readMapWithExceptions(request));
      fail("Expected RoutingException");
    }
    catch (RoutingException e)
    {
      assertTrue(e.getMessage().contains(errorMessage));
      assertEquals(HttpStatus.S_400_BAD_REQUEST.getCode(), e.getStatus());
    }

    verify(request, context, routingResult);
  }