@VisibleForTesting
    void setResourceInformationUnSafe(Object resource, String resourceName, long amount) {
        if (!isYarnResourceTypesAvailable) {
            LOG.info(
                    "Will not request extended resource {} because the used YARN version does not support it.",
                    resourceName);
            return;
        }
        try {
            resourceSetResourceInformationMethod.invoke(
                    resource,
                    resourceName,
                    resourceInformationNewInstanceMethod.invoke(null, resourceName, amount));
        } catch (Exception e) {
            LOG.warn(
                    "Error in setting the external resource {}. Will not request this resource from YARN.",
                    resourceName,
                    e);
        }
    }
@Test
    void testSetResourceInformationIfMethodPresent() {
        final ResourceInformationReflector resourceInformationReflector =
                new ResourceInformationReflector(
                        ResourceWithMethod.class.getName(), ResourceInfoWithMethod.class.getName());
        final ResourceWithMethod resourceWithMethod = new ResourceWithMethod();
        resourceInformationReflector.setResourceInformationUnSafe(
                resourceWithMethod, RESOURCE_NAME, RESOURCE_VALUE);

        assertThat(resourceWithMethod.getResourceWithName(RESOURCE_NAME)).isNotNull();
        assertThat(resourceWithMethod.getResourceWithName(RESOURCE_NAME).getName())
                .isEqualTo(RESOURCE_NAME);
        assertThat(resourceWithMethod.getResourceWithName(RESOURCE_NAME).getValue())
                .isEqualTo(RESOURCE_VALUE);
    }