@Private
  @VisibleForTesting
  static void checkResourceRequestAgainstAvailableResource(Resource reqResource,
      Resource availableResource) throws InvalidResourceRequestException {
    for (int i = 0; i < ResourceUtils.getNumberOfCountableResourceTypes(); i++) {
      final ResourceInformation requestedRI =
          reqResource.getResourceInformation(i);
      final String reqResourceName = requestedRI.getName();

      if (requestedRI.getValue() < 0) {
        throwInvalidResourceException(reqResource, availableResource,
            reqResourceName, InvalidResourceType.LESS_THAN_ZERO);
      }

      boolean valid = checkResource(requestedRI, availableResource);
      if (!valid) {
        throwInvalidResourceException(reqResource, availableResource,
            reqResourceName, InvalidResourceType.GREATER_THEN_MAX_ALLOCATION);
      }
    }
  }
@Test
  public void testCustomResourceRequestedUnitIsSmallerThanAvailableUnit()
          throws InvalidResourceRequestException {
    Resource requestedResource =
            ResourceTypesTestHelper.newResource(1, 1,
                    ImmutableMap.of("custom-resource-1", "11"));

    Resource availableResource =
            ResourceTypesTestHelper.newResource(1, 1,
                    ImmutableMap.of("custom-resource-1", "0G"));

    exception.expect(InvalidResourceRequestException.class);
    exception.expectMessage(InvalidResourceRequestExceptionMessageGenerator
            .create().withRequestedResourceType("custom-resource-1")
            .withRequestedResource(requestedResource)
            .withAvailableAllocation(availableResource)
            .withMaxAllocation(configuredMaxAllocation)
            .withInvalidResourceType(GREATER_THEN_MAX_ALLOCATION)
            .build());

    SchedulerUtils.checkResourceRequestAgainstAvailableResource(
            requestedResource, availableResource);
  }