static TaskExecutorResourceSpec resourceSpecFromConfig(Configuration config) {
        try {
            checkTaskExecutorResourceConfigSet(config);
        } catch (IllegalConfigurationException e) {
            throw new IllegalConfigurationException("Failed to create TaskExecutorResourceSpec", e);
        }
        return new TaskExecutorResourceSpec(
                new CPUResource(config.get(TaskManagerOptions.CPU_CORES)),
                config.get(TaskManagerOptions.TASK_HEAP_MEMORY),
                config.get(TaskManagerOptions.TASK_OFF_HEAP_MEMORY),
                config.get(TaskManagerOptions.NETWORK_MEMORY_MIN),
                config.get(TaskManagerOptions.MANAGED_MEMORY_SIZE),
                ExternalResourceUtils.getExternalResourcesCollection(config));
    }
@Test
    void testResourceSpecFromConfig() {
        TaskExecutorResourceSpec resourceSpec =
                TaskExecutorResourceUtils.resourceSpecFromConfig(createValidConfig());
        assertThat(resourceSpec.getCpuCores()).isEqualTo(new CPUResource(CPU_CORES));
        assertThat(resourceSpec.getTaskHeapSize()).isEqualTo(TASK_HEAP);
        assertThat(resourceSpec.getTaskOffHeapSize()).isEqualTo(TASK_OFF_HEAP);
        assertThat(resourceSpec.getNetworkMemSize()).isEqualTo(NETWORK);
        assertThat(resourceSpec.getManagedMemorySize()).isEqualTo(MANAGED);
        assertThat(
                        resourceSpec
                                .getExtendedResources()
                                .get(EXTERNAL_RESOURCE_NAME)
                                .getValue()
                                .longValue())
                .isEqualTo(EXTERNAL_RESOURCE_AMOUNT);
    }