@VisibleForTesting
    Map<String, Long> getAllResourceInfos(Object resource) {
        if (!isYarnResourceTypesAvailable) {
            return Collections.emptyMap();
        }

        final Map<String, Long> externalResources = new HashMap<>();
        final Object[] externalResourcesInfo;
        try {
            externalResourcesInfo = (Object[]) resourceGetResourcesMethod.invoke(resource);
            for (int i = 0; i < externalResourcesInfo.length; i++) {
                final String name =
                        (String) resourceInformationGetNameMethod.invoke(externalResourcesInfo[i]);
                final long value =
                        (long) resourceInformationGetValueMethod.invoke(externalResourcesInfo[i]);
                externalResources.put(name, value);
            }
        } catch (Exception e) {
            LOG.warn("Could not obtain the external resources supported by the given Resource.", e);
            return Collections.emptyMap();
        }
        return externalResources;
    }
@Test
    void testDefaultTwoResourceTypeWithYarnSupport() {
        assumeThat(HadoopUtils.isMinHadoopVersion(2, 10)).isTrue();

        final Resource resource = Resource.newInstance(100, 1);

        // make sure that Resource has at least two associated resources (cpu and memory)
        final Map<String, Long> resourcesResult =
                ResourceInformationReflector.INSTANCE.getAllResourceInfos(resource);
        assertThat(resourcesResult).hasSizeGreaterThanOrEqualTo(2);
    }